From ee7810ae27f1f6e78afecbc86851209a173eba8a Mon Sep 17 00:00:00 2001 From: Jim Mason Date: Tue, 12 Dec 2023 16:43:13 +0000 Subject: [PATCH] Updated for PHP dynamic property deprecation (#427) --- README.md | 2 +- composer.json | 2 +- engine/TemplateFactory.php | 14 ++++++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 2ce2f7eb..defd1ca7 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ https://zookeeper.ibinx.com/master/ ### Requirements -* PHP 7.2.5 or later with MySQL PDO driver +* PHP 7.4 or later with MySQL PDO driver * MySQL/MariaDB It is recommended to use PHP 8.2 or later, as older versions have diff --git a/composer.json b/composer.json index a4fd8cee..730979ab 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ ] }, "require": { - "php": ">=7.2.5", + "php": ">=7.4", "ext-curl": "*", "ext-pdo": "*", "ext-pdo_mysql": "*", diff --git a/engine/TemplateFactory.php b/engine/TemplateFactory.php index c5293374..758e4832 100644 --- a/engine/TemplateFactory.php +++ b/engine/TemplateFactory.php @@ -52,15 +52,21 @@ class LazyLoadParams { ]; public $request; // explicit, as we assign by reference later + private $params = []; public function __isset($name) { - return in_array($name, self::TEMPLATE_SAFE_PARAMS); + return key_exists($name, $this->params) || + in_array($name, self::TEMPLATE_SAFE_PARAMS); } public function __get($name) { - $this->$name = in_array($name, self::TEMPLATE_SAFE_PARAMS) ? - Engine::param($name) : null; - return $this->$name; + return $this->params[$name] ??= + in_array($name, self::TEMPLATE_SAFE_PARAMS) ? + Engine::param($name) : null; + } + + public function __set($name, $value) { + $this->params[$name] = $value; } }