|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2015-03-18 02:50 UTC] laruence@php.net
-Status: Open
+Status: Feedback
[2015-03-18 02:50 UTC] laruence@php.net
[2015-03-24 17:07 UTC] bkfake-php at yahoo dot com
-Status: Feedback
+Status: Open
-PHP Version: 5.6.6
+PHP Version: 5.6.7
[2015-03-24 17:07 UTC] bkfake-php at yahoo dot com
[2018-07-02 18:21 UTC] nikic@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: nikic
[2018-07-02 18:21 UTC] nikic@php.net
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 02 21:00:01 2025 UTC |
Description: ------------ Calling ReflectionProperty::getDocComment() on a property that hasn't been declared in the class "core dumps". Simply returning null, false, or an empty string would be much more user friendly To safely call ReflectionProperty::getDocComment(), you must first check if the property exists in the class $docComment = property_exists('Test', $prop->getName()) ? $prop->getDocComment() : ''; Test script: --------------- $obj = new Test(); $obj->notDeclared = 'Not defined in class'; $reflectionObject = new \ReflectionObject($obj); $properties = $reflectionObject->getProperties(); while ($properties) { $prop = array_shift($properties); $prop->getDocComment(); } /** * Test */ class Test { // properties and methods... } Expected result: ---------------- script completes Actual result: -------------- Apache restarts