Bug #66034 [Opn->Nab]: defined not working on traits

From: Date: Tue, 05 Nov 2013 13:46:08 +0000
Subject: Bug #66034 [Opn->Nab]: defined not working on traits
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-182607@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 Updated by: laruence@php.net Reported by: karibou at ribouka dot com Summary: defined not working on traits -Status: Open +Status: Not a bug Type: Bug Package: Class/Object related Operating System: debian PHP Version: 5.4.21 Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php your test is wrong, you should: var_dump(defined("self::MY_CONST")); // notice the quotes Previous Comments: ------------------------------------------------------------------------ [2013-11-05 10:02:11] karibou at ribouka dot com In expected and actuel result, i mistype 'TEST' by 'Test'. :) ------------------------------------------------------------------------ [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

« previous php.bugs (#182607) next »