Skip to content

Commit 2076826

Browse files
committed
Add class check in DI
1 parent 600e1c9 commit 2076826

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

src/Container.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ public function __call($method, $args)
3535
* TestClasses\Test::class,
3636
* TestClasses\Test::class."::__construct",
3737
* TestClasses\Test::class."::getStaticMethod",
38-
* @param array|null $args Pass argumnets to constructor staticMethod if you choose.
38+
* @param array|null $args Pass arguments to constructor staticMethod if you choose.
3939
* @param bool $overwrite Will throw exception if already been defined if not arg is set to TRUE.
4040
*/
41-
public function set(string $identifier, $value, ?array $args = null, bool $overwrite = false): ContainerInterface
41+
public function set(string $identifier, mixed $value, ?array $args = null, bool $overwrite = false): ContainerInterface
4242
{
4343
if (!$overwrite && $this->has($identifier)) {
4444
$type = ($this->isFactory($identifier)) ? "factory" : "container";

src/Interfaces/ContainerInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ public function has(string $identifier): bool;
4242
* TestClasses\Test::class,
4343
* TestClasses\Test::class."::__construct",
4444
* TestClasses\Test::class."::getStaticMethod",
45-
* @param array|null $args Pass argumnets to constructor staticMethod if you choose.
46-
* @param bool|boolean $overwrite Will throw exception if already been defined if not arg is set to TRUE.
45+
* @param array|null $args Pass arguments to constructor staticMethod if you choose.
46+
* @param bool $overwrite Will throw exception if already been defined if not arg is set to TRUE.
4747
*/
48-
public function set(string $identifier, $value, ?array $args = null, bool $overwrite = false): ContainerInterface;
48+
public function set(string $identifier, mixed $value, ?array $args = null, bool $overwrite = false): ContainerInterface;
4949
}

src/Reflection.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,10 @@ private function injectRecursion(array $params, string $fromClass, array $_args
187187
self::$class[$classNameA] = $this->newInstance($inst, (bool)$constructor, $_args);
188188
}
189189
}
190-
$_args[] = self::$class[$classNameA];
190+
if (isset(self::$class[$classNameA])) {
191+
$_args[] = self::$class[$classNameA];
192+
}
193+
191194
}
192195
}
193196
}

0 commit comments

Comments
 (0)