AW: [PHP-DEV] [RFC] Class instances counter
| From: | Frank Liepert | Date: | Thu, 11 Apr 2013 11:59:22 +0000 |
| Subject: | AW: [PHP-DEV] [RFC] Class instances counter | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-67050@lists.php.net to get a copy of this message | ||
> 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.