Bug #80564 [Opn->Ver]: ReflectionProperty::__toString() renders current value, not default value

From: Date: Wed, 30 Dec 2020 06:30:07 +0000
Subject: Bug #80564 [Opn->Ver]: ReflectionProperty::__toString() renders current value, not default value
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-231307@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 Updated by: requinix@php.net Reported by: david at grudl dot com -Summary: ReflectionProperty::__toString() converts property value to string +Summary: ReflectionProperty::__toString() renders current value, not default value -Status: Open +Status: Verified Type: Bug Package: Reflection related PHP Version: 8.0.1RC1 Block user comment: N Private report: N New Comment: 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 Previous Comments: ------------------------------------------------------------------------ [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 (#231307) next »