Bug #69249 [Opn->Fbk]: ReflectionProperty::getDocComment() non catchable fatal

From: Date: Wed, 18 Mar 2015 02:50:57 +0000
Subject: Bug #69249 [Opn->Fbk]: ReflectionProperty::getDocComment() non catchable fatal
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-191441@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69249&edit=1 ID: 69249 Updated by: laruence@php.net Reported by: bkfake-php at yahoo dot com Summary: ReflectionProperty::getDocComment() non catchable fatal -Status: Open +Status: Feedback Type: Bug Package: Reflection related Operating System: Win7 x64 PHP Version: 5.6.6 Block user comment: N Private report: N New Comment: Thank you for this bug report. To properly diagnose the problem, we need a backtrace to see what is happening behind the scenes. To find out how to generate a backtrace, please read http://bugs.php.net/bugs-generating-backtrace.php for *NIX and http://bugs.php.net/bugs-generating-backtrace-win32.php for Win32 Once you have generated a backtrace, please submit it to this bug report and change the status back to "Open". Thank you for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2015-03-17 15:03:36] bkfake-php at yahoo dot com 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=69249&edit=1

« previous php.bugs (#191441) next »