Bug #68931 [Nab]: Class with Trait is not contained in get_declared_classes()

From: Date: Wed, 28 Jan 2015 20:18:21 +0000
Subject: Bug #68931 [Nab]: Class with Trait is not contained in get_declared_classes()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-190282@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 Updated by: requinix@php.net 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: @bastian: see also my comment on bug #68936, which was coincidentally (?) created minutes before nikic replied here. It seems to me that it's not that classes using traits are not documented to not be early-bound, which is too many negatives for one sentence I know, but that classes using traits do not benefit from the undocumented early-binding "feature" that typical classes do. Previous Comments: ------------------------------------------------------------------------ [2015-01-28 16:40:00] bastian dot schneider at commerce-plus dot com 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! ------------------------------------------------------------------------ [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

« previous php.bugs (#190282) next »