From 6eabc35153292ff7d03719a81e6489b74544d558 Mon Sep 17 00:00:00 2001 From: "Bruno O. Notario" Date: Thu, 8 Feb 2024 23:11:50 -0300 Subject: [PATCH] Change getInstance order --- system/engine/registry.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/system/engine/registry.php b/system/engine/registry.php index ef58d9d..8ebb093 100644 --- a/system/engine/registry.php +++ b/system/engine/registry.php @@ -339,19 +339,18 @@ final class Registry { if($class === get_class($this)) return $this; + if (!$forceCreate && $autoInstance = $this->getInstance($originalClass ?: $class, [], true)) + return $autoInstance; + $refClass = new ReflectionClass($class); try { - if (!$forceCreate && $autoInstance = $this->getInstance($originalClass ?: $class, [], true)) - return $autoInstance; - if (!$refClass->getConstructor() && !$argsToInject) { if ($refClass->hasMethod('getInstance') && $refClass->getMethod('getInstance')->isStatic()) { return self::setAutoInstance($refClass->getMethod('getInstance')->invoke(null), ($originalClass ?: $class)); } return self::setAutoInstance($refClass->newInstanceWithoutConstructor(), ($originalClass ?: $class)); } - } catch (\Exception $th) { //throw $th; Don't make anything and retry create }