FAQ
2013/4/10 Frank Liepert <[email protected]>
Hello internals,

again an update on the RFC, see https://wiki.php.net/rfc/instance_counter:

- added support for object as argument
- added support for array argument (indexed array with class names)
- added more code examples


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
It is not entirely clear how the function treats subclasses. Does it count
only the *direct* instances of a class, or does it also count the instances
of subclasses?

class A {}
class B extends A {}

echo get_objects_count('A');
// 0

$a = new B;

echo $a instanceof A;
// 1 (true)

echo get_objects_count('A');
// ??? - 0 or 1 ?



Lazare Inepologlou
Ingénieur Logiciel

Search Discussions

  • Frank Liepert at Apr 11, 2013 at 11:59 am

    It is not entirely clear how the function treats subclasses. Does it
    count
    only the *direct* instances of a class, or does it also count the
    instances
    of subclasses?

    class A {}
    class B extends A {}

    echo get_objects_count('A');
    // 0

    $a = new B;

    echo $a instanceof A;
    // 1 (true)

    echo get_objects_count('A');
    // ??? - 0 or 1 ?



    Lazare Inepologlou
    Ingénieur Logiciel

    Short answer: only direct instances, so the result is 0!

    Added your question+answer to the RFC.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupphp-internals @
categoriesphp
postedApr 10, '13 at 10:32a
activeApr 11, '13 at 11:59a
posts2
users2
websitephp.net

People

Translate

site design / logo © 2023 Grokbase