From 8890d03d2c55b45299f0dc8e880e94889fe7dd21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Sun, 16 Apr 2023 13:36:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Container.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Container.php b/Container.php index 112af7c..33b4e92 100644 --- a/Container.php +++ b/Container.php @@ -151,14 +151,16 @@ class Container implements ContainerInterface public function make(string $className, array $construct = [], array $config = []): object { $reflect = $this->getReflectionClass($className); - if (count($construct) < 1 && ($constructor = $reflect->getConstructor()) !== null) { - $construct = $this->getMethodParams($constructor); + + $constructorHandler = $reflect->getConstructor(); + if (count($construct) < 1 && $constructorHandler !== null) { + $construct = $this->getMethodParams($constructorHandler); } $object = self::configure($reflect->newInstanceArgs($construct), $config); $this->resolveProperties($reflect, $object); - if (method_exists($object, 'init') && $className !== 'Symfony\Component\Console\Application') { + if ($constructorHandler === null && method_exists($object, 'init')) { call_user_func([$object, 'init']); } return $object;