Edit report at https://bugs.php.net/bug.php?id=81698&edit=1
ID: 81698
User updated by: richiruizmartinez at gmail dot com
Reported by: richiruizmartinez at gmail dot com
Summary: getType()->getName() crashes on dynamic properties
Status: Open
Type: Bug
Package: Reflection related
Operating System: Ubuntu 20.04
PHP Version: 7.4.26
Block user comment: N
Private report: N
New Comment:
getType()->__toString() also crashes:
$foo = new stdClass;
$foo->bar = 1;
var_dump((new ReflectionObject($foo))->getProperties()[0]->getType()->__toString());
Previous Comments:
------------------------------------------------------------------------
[2021-12-04 17:55:06] richiruizmartinez at gmail dot com
Description:
------------
When I run the code shown below, PHP generates a segmentation fault. The object $o has a dynamic
property $p. When trying to find out the type of $p, the segmentation fault appears.
Test script:
---------------
class C { }
$o = new C();
$o->p = 0;
$ro = new \ReflectionObject($o);
foreach ($ro->getProperties() as $rp) {
echo $rp->getType()->getName();
}
Expected result:
----------------
segmentation fault (core dumped)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=81698&edit=1