eee
This commit is contained in:
@@ -153,6 +153,60 @@ class Container implements ContainerInterface
|
||||
}
|
||||
|
||||
|
||||
public function forgetReflection(string $className): void
|
||||
{
|
||||
unset($this->_reflection[$className]);
|
||||
}
|
||||
|
||||
|
||||
public function forgetMethodParams(string $className, ?string $method = null): void
|
||||
{
|
||||
if (!isset($this->_parameters[$className])) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($method === null) {
|
||||
unset($this->_parameters[$className]);
|
||||
return;
|
||||
}
|
||||
|
||||
unset($this->_parameters[$className][$method]);
|
||||
if ($this->_parameters[$className] === []) {
|
||||
unset($this->_parameters[$className]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function forgetClass(string $className): void
|
||||
{
|
||||
unset($this->_singletons[$className]);
|
||||
$this->forgetReflection($className);
|
||||
$this->forgetMethodParams($className);
|
||||
}
|
||||
|
||||
|
||||
public function forgetNamespace(string $prefix): void
|
||||
{
|
||||
foreach (array_keys($this->_singletons) as $className) {
|
||||
if ($className !== ContainerInterface::class && str_starts_with($className, $prefix)) {
|
||||
unset($this->_singletons[$className]);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (array_keys($this->_reflection) as $className) {
|
||||
if (str_starts_with($className, $prefix)) {
|
||||
unset($this->_reflection[$className]);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (array_keys($this->_parameters) as $className) {
|
||||
if (str_starts_with($className, $prefix)) {
|
||||
unset($this->_parameters[$className]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $className
|
||||
* @param array $construct
|
||||
|
||||
Reference in New Issue
Block a user