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

From: Date: Sat, 09 Nov 2013 10:21:22 +0000
Subject: Bug #66034 [Nab->Csd]: defined not working on traits
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-182676@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: ab@php.net Reported by: karibou at ribouka dot com Summary: defined not working on traits -Status: Not a bug +Status: Closed Type: Bug Package: Class/Object related Operating System: debian PHP Version: 5.4.21 Block user comment: N Private report: N New Comment: Automatic comment on behalf of laruence Revision: http://git.php.net/?p=php-src.git;a=commit;h=e3d9e18e7b24ba2d5c9e420510e804330c94f955 Log: Fixed Bug #66034 (Segmentation Fault when constructor of PDO statement throws an exception) Previous Comments: ------------------------------------------------------------------------ [2013-11-05 13:46:07] laruence@php.net 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 ------------------------------------------------------------------------ [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 (#182676) next »