You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
return (static function() {
$class = new \ReflectionClass(\Test::class);
$object = $class->newInstanceWithoutConstructor();
$object->foo = 'bar';
return $object;
})();
Fatal error: Uncaught Error: Cannot initialize readonly property Test::$foo from global scope in test.php(19) : eval()'d code on line 5
Error: Cannot initialize readonly property Test::$foo from global scope in test.php(19) : eval()'d code on line 5
When loading a class with readonly properties, an error is thrown:
PHP Fatal error: Uncaught Error: Cannot initialize readonly property ...
This happens, because readonly properties
TestCase:
Output
Expected Output
Possible solution
instead of just setting the property on the object via
$object->foo = 'bar'
it should be set viabindTo
:one could use
$property-> isReadOnly
to determine if this is necessary.The text was updated successfully, but these errors were encountered: