|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2019-08-13 20:25 UTC] nikic@php.net
-Status: Open
+Status: Feedback
[2019-08-13 20:25 UTC] nikic@php.net
[2019-08-13 20:48 UTC] tandrewbennett at hotmail dot com
[2019-08-13 20:51 UTC] nikic@php.net
-Status: Feedback
+Status: Duplicate
[2019-08-13 20:51 UTC] nikic@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 15 00:00:02 2025 UTC |
Description: ------------ When instantiating an object using reflectionClass::newInstanceWithoutConstructor, assigning values to uninitialized typed properties has no effect. Test script: --------------- class Foo { protected string $bar; protected string $baz; protected string $qux = 'initial qux'; public function fillValues() { $this->bar = 'bar'; $this->baz = 'baz'; $this->qux = 'qux'; } public function getBar() { return $this->bar; } public function getBaz() { return $this->baz; } public function getQux() { return $this->qux; } } $rc = new ReflectionClass(Foo); $foo = $rc->newInstanceWithoutConstructor(); $foo->fillValues(); echo $foo->getBar() . PHP_EOL; echo $foo->getBaz() . PHP_EOL; echo $foo->getQux() . PHP_EOL; Expected result: ---------------- bar baz qux Actual result: -------------- Fatal error: Uncaught Error: Typed property Foo::$bar must not be accessed before initialization