|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-10-29 15:51 UTC] 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. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 10 23:00:01 2025 UTC |
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.