变更
This commit is contained in:
+15
-2
@@ -12,7 +12,6 @@ namespace Kiri\Di;
|
||||
use Closure;
|
||||
use Exception;
|
||||
use Kiri;
|
||||
use Kiri\Di\ContainerInterface;
|
||||
use ReflectionClass;
|
||||
use ReflectionException;
|
||||
use ReflectionFunction;
|
||||
@@ -78,6 +77,20 @@ class Container implements ContainerInterface
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
*/
|
||||
public function copy($id): mixed
|
||||
{
|
||||
if ($id == ContainerInterface::class) {
|
||||
return $this;
|
||||
}
|
||||
return clone $this->make($id, [], []);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
@@ -148,7 +161,7 @@ class Container implements ContainerInterface
|
||||
if (is_string($object)) {
|
||||
$this->_interfaces[$interface] = $object;
|
||||
} else {
|
||||
$className = get_class($object);
|
||||
$className = get_class($object);
|
||||
$this->_interfaces[$interface] = $className;
|
||||
$this->_singletons[$className] = $object;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user