This commit is contained in:
2023-04-16 13:36:35 +08:00
parent 2877f3faa5
commit 8890d03d2c
+5 -3
View File
@@ -151,14 +151,16 @@ class Container implements ContainerInterface
public function make(string $className, array $construct = [], array $config = []): object public function make(string $className, array $construct = [], array $config = []): object
{ {
$reflect = $this->getReflectionClass($className); $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); $object = self::configure($reflect->newInstanceArgs($construct), $config);
$this->resolveProperties($reflect, $object); $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']); call_user_func([$object, 'init']);
} }
return $object; return $object;