Edit report at http://bugs.php.net/bug.php?id=53202&edit=1
ID: 53202 Updated by: ras...@php.net Reported by: agent_harris at secure-mail dot biz Summary: unexpected return value getConstant -Status: Open +Status: Wont fix Type: Feature/Change Request Package: Reflection related Operating System: Ubuntu Linux 9.04 PHP Version: 5.3.3 Block user comment: N New Comment: I don't see how returning NULL helps here. You can just as easily have defined the constant to be NULL. There is no value we can return that is not definable, and throwing an exception isn't an option. You have 2 ways to check it further if you do get false back. defined('class::constant') will tell you if it is defined and ReflectionClass ::getConstants() will give you an array of all the defined constants along with their values. It is trivial to wrap this and throw your own exception if the constant isn't defined. Previous Comments: ------------------------------------------------------------------------ [2010-10-29 15:51:29] agent_harris at secure-mail dot biz Description: ------------ to make it short: if you try to get the value of a constant via ReflectionClass::getConstant(...) and the constant name you specified does not exist, the function returns bool(false). but maybe you have really defined a constant as bool(false). then you are not able to distinguish between these two possibilities. in that case the preferred behavior should be to throw and exception or return the null value. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=53202&edit=1