Bug #66034 [Opn]: defined not working on traits
| From: | karibou at ribouka dot com | Date: | Tue, 05 Nov 2013 10:02:11 +0000 |
| Subject: | Bug #66034 [Opn]: defined not working on traits | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-182603@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=66034&edit=1
ID: 66034
User updated by: karibou at ribouka dot com
Reported by: karibou at ribouka dot com
Summary: defined not working on traits
Status: Open
Type: Bug
Package: Class/Object related
Operating System: debian
PHP Version: 5.4.21
Block user comment: N
Private report: N
New Comment:
In expected and actuel result, i mistype 'TEST' by 'Test'. :)
Previous Comments:
------------------------------------------------------------------------
[2013-11-05 09:59:18] karibou at ribouka dot com
Description:
------------
I'm on 5.4.14
I won't upgrade to test this, if someone have 5.4.21, can he tests and reports.
If you call a constant of a class in a trait (of that class), it works.
BUT, if you want to test its existence by 'defined' it's always return false.
Test script:
---------------
class MyClass{
use MyTrait;
const MY_CONST = 'TEST';
}
Trait MyTrait{
public function testConst()
{
echo self::MY_CONST;
var_dump(defined(self::MY_CONST));
}
}
$myClass = new MyClass();
$myClass->testConst();
Expected result:
----------------
Test
boolean true
Actual result:
--------------
Test
boolean false
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=66034&edit=1