Bug #68931 [Com]: Class with Trait is not contained in get_declared_classes()
| From: | bastian dot schneider at commerce-plus dot com | Date: | Wed, 28 Jan 2015 16:40:00 +0000 |
| Subject: | Bug #68931 [Com]: Class with Trait is not contained in get_declared_classes() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-190276@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=68931&edit=1
ID: 68931
Comment by: bastian dot schneider at commerce-plus dot com
Reported by: bastian dot schneider at commerce-plus dot com
Summary: Class with Trait is not contained in
get_declared_classes()
Status: Not a bug
Type: Bug
Package: Class/Object related
Operating System: Windows 7 x64
PHP Version: 5.6.5
Block user comment: N
Private report: N
New Comment:
Yes, so it is. But in this case, the behavior is not documented.
If I check get_declared_classes() before a class with trait, the result is different from a class
without trait. If it's a feature and not a bug, it should be documented in http://php.net/manual/en/language.oop5.traits.php
or http://php.net/manual/en/function.get-declared-classes.php,
don't you think?
Thx and keep up the good work!
Previous Comments:
------------------------------------------------------------------------
[2015-01-28 16:01:19] nikic@php.net
You check get_declared_classes() before the class is defined ... Classes using traits are not
early-bound.
------------------------------------------------------------------------
[2015-01-28 10:57:09] bastian dot schneider at commerce-plus dot com
Description:
------------
Problem
- "TestClass" is not contained in get_declared_classes()
Circumstances
- the class uses a Trait
- get_declared_classes() is called before the declaration of the class
Test script:
---------------
trait CAS {}
// with use CAS = 135 classes
// without use CAS = 136 classes
var_dump(sizeof(get_declared_classes()));
class TestClass
{
use CAS;
}
Expected result:
----------------
I would always expect 136 classes
Actual result:
--------------
135 classes, TestClass is not contained
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=68931&edit=1