From f144231aad3fcc68367820417056c141947c754d Mon Sep 17 00:00:00 2001 From: "Bruno O. Notario" Date: Wed, 24 Jan 2024 15:08:24 -0300 Subject: [PATCH] Fix compatibility with PHP 5.6 and 8 --- system/arrayClass/CaseInsensitiveArray.php | 2 +- system/engine/registry.php | 27 ++++++++++++++++------ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/system/arrayClass/CaseInsensitiveArray.php b/system/arrayClass/CaseInsensitiveArray.php index 366b03d..b2fb012 100644 --- a/system/arrayClass/CaseInsensitiveArray.php +++ b/system/arrayClass/CaseInsensitiveArray.php @@ -7,7 +7,7 @@ namespace Phacil\Framework\ArrayClass; -if (version_compare(phpversion(), "7.1.0", "<")) { +if (version_compare(phpversion(), "8.0.0", "<")) { class supCaseComp extends \Phacil\Framework\ArrayClass\Aux\LegacyAux { diff --git a/system/engine/registry.php b/system/engine/registry.php index 7291db3..4a222bd 100644 --- a/system/engine/registry.php +++ b/system/engine/registry.php @@ -195,14 +195,27 @@ final class Registry { foreach ($params as $param) { //$param is an instance of ReflectionParameter try { - if ($param->getType()) { - $injectionClass = $param->getType()->getName(); - if (class_exists($injectionClass)) { - $argsToInject[$param->getPosition()] = $this->injectionClass($injectionClass); - continue; + if (version_compare(phpversion(), "7.2.0", "<")) { + if ($param->getClass()) { + $injectionClass = $param->getClass()->name; + if (class_exists($injectionClass)) { + $argsToInject[$param->getPosition()] = $this->injectionClass($injectionClass); + continue; + } + if (!$param->isOptional()) { + throw new \Phacil\Framework\Exception\ReflectionException("Error Processing Request: " . $injectionClass . "not exist"); + } } - if (!$param->isOptional()) { - throw new \Phacil\Framework\Exception\ReflectionException("Error Processing Request: " . $injectionClass . "not exist"); + } else { + if ($param->getType()) { + $injectionClass = $param->getType()->getName(); + if (class_exists($injectionClass)) { + $argsToInject[$param->getPosition()] = $this->injectionClass($injectionClass); + continue; + } + if (!$param->isOptional()) { + throw new \Phacil\Framework\Exception\ReflectionException("Error Processing Request: " . $injectionClass . "not exist"); + } } } } catch (\Exception $th) {