Bug #80564 [Com]: ReflectionProperty::__toString() renders current value, not default value

From: Date: Mon, 11 Jan 2021 03:59:57 +0000
Subject: Bug #80564 [Com]: ReflectionProperty::__toString() renders current value, not default value
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-231482@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80564&edit=1 ID: 80564 Comment by: sydneymylee62 at gmail dot com Reported by: david at grudl dot com Summary: ReflectionProperty::__toString() renders current value, not default value Status: Verified Type: Bug Package: Reflection related PHP Version: 8.0.1RC1 Block user comment: N Private report: N New Comment: Thanks for the update and quick reply. I'll be sure to keep an eye on this thread. Looking for the same issue. Bumped into your thread. Thanks for creating it. Looking forward for solution. https://www.tellpizzahut.one/ Previous Comments: ------------------------------------------------------------------------ [2020-12-30 06:30:07] requinix@php.net Fails during zval *default_value = property_get_default(prop); if (!Z_ISUNDEF_P(default_value)) { smart_str_appends(str, " = "); if (format_default_value(str, default_value, prop->ce) == FAILURE) { return; } } Apparently it's trying to get a default value but is actually coming up with the current value. https://3v4l.org/g4OLG ------------------------------------------------------------------------ [2020-12-30 04:43:39] david at grudl dot com Description: ------------ ReflectionProperty::__toString() convert also value of property to string and it may fail, see https://3v4l.org/rfoGl Test script: --------------- <?php class A { public static $x; } A::$x = new stdClass; $rp = new ReflectionProperty('A', 'x'); echo $rp; Expected result: ---------------- Property [ public static $x ] Actual result: -------------- Fatal error: Uncaught Error: Object of class stdClass could not be converted to string ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=80564&edit=1

« previous php.bugs (#231482) next »