From 0f1616aeeb107c1ad6c2feeb724bd2caa150985d Mon Sep 17 00:00:00 2001 From: David Grudl Date: Mon, 24 Oct 2022 19:12:55 +0200 Subject: [PATCH] Revert "UI\PresenterComponent: removed references created by loadState() for persistent parameters. [Closes nette/nette#703][Closes nette/nette#703][Closes #69]" (possible BC break) This reverts commit cda17f460d020b0f042364d4e140742022a7e94d. See https://forum.nette.org/cs/35528-stejne-pojmenovany-parametr-akce-presenteru-a-persistentni-odlisne-chovani-v-nette-2-0-oproti-aktualnimu#p221742 BC break: Property must be nullable, ie: #[Persistent] public ?int $foo --- src/Application/UI/Component.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Application/UI/Component.php b/src/Application/UI/Component.php index 4eb8ee945..d3abe8c74 100644 --- a/src/Application/UI/Component.php +++ b/src/Application/UI/Component.php @@ -161,9 +161,9 @@ public function loadState(array $params): void )); } - $this->$name = $params[$name]; + $this->$name = &$params[$name]; } else { - $params[$name] = $this->$name ?? null; + $params[$name] = &$this->$name; } } @@ -236,7 +236,7 @@ final public function getParameter(string $name): mixed */ final public function getParameters(): array { - return $this->params; + return array_map(fn($item) => $item, $this->params); }