Bug #67577 [NEW]: Unintuitive __CLASS__ magic const behaviour when in a closure from a trait.

From: Date: Sun, 06 Jul 2014 02:59:09 +0000
Subject: Bug #67577 [NEW]: Unintuitive __CLASS__ magic const behaviour when in a closure from a trait.
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-186489@lists.php.net to get a copy of this message
From: elliot at aanet dot com dot au Operating system: PHP version: 5.6.0RC2 Package: Scripting Engine problem Bug Type: Bug Bug description:Unintuitive __CLASS__ magic const behaviour when in a closure from a trait. Description: ------------ The __CLASS__ magic constant behaves very differently for closures defined in a trait. It seems to use the bound scope class for the closure rather than the class which it was actually used in. You can see the current behaviour here: http://3v4l.org/WIK1E#v540 This can get even more unintuitive when using normal methods and reflection to get them as a closure seen here: http://3v4l.org/EhVlW#v540 Considering traits are are essentially copy and pasted into the used class, would it not be more correct to use the class in which it was used in instead? Expected result: ---------------- Before bind: __CLASS__ in class: string(17) "ClassConstantTest" __CLASS__ in Trait: string(17) "ClassConstantTest" After bind: __CLASS__ in class: string(17) "ClassConstantTest" __CLASS__ in Trait: string(17) "ClassConstantTest" Actual result: -------------- Before bind: __CLASS__ in class: string(17) "ClassConstantTest" __CLASS__ in Trait: string(17) "ClassConstantTest" After bind: __CLASS__ in class: string(17) "ClassConstantTest" __CLASS__ in Trait: string(8) "stdClass" -- Edit bug report at https://bugs.php.net/bug.php?id=67577&edit=1 --

« previous php.bugs (#186489) next »