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