Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9e954135f6 | |||
| 7de790d65f | |||
| 855da03137 | |||
| 0081a30f22 | |||
| 3f2d3b0f04 | |||
| 5fa5646024 | |||
| 045c9293d5 | |||
| 6ae7f5a721 | |||
| 9775d16db5 | |||
| 03bffb5e5b |
+9
-4
@@ -14,6 +14,7 @@ use Closure;
|
||||
use Exception;
|
||||
use Kiri\Di\Interface\InjectTargetInterface;
|
||||
use Kiri\Router\Interface\ValidatorInterface;
|
||||
use Kiri\Server\Task\OnTaskFinish;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use ReflectionAttribute;
|
||||
use ReflectionClass;
|
||||
@@ -91,7 +92,8 @@ class Container implements ContainerInterface
|
||||
*/
|
||||
public function get(string $id): object
|
||||
{
|
||||
if (isset($this->_singletons[$id])) return $this->_singletons[$id];
|
||||
if (isset($this->_singletons[$id]))
|
||||
return $this->_singletons[$id];
|
||||
if (isset($this->_interfaces[$id])) {
|
||||
return $this->_singletons[$id] = $this->make($this->_interfaces[$id]);
|
||||
} else {
|
||||
@@ -165,15 +167,17 @@ class Container implements ContainerInterface
|
||||
throw new ReflectionException('Class ' . $className . ' cannot be instantiated');
|
||||
}
|
||||
|
||||
if (($handler = $reflect->getConstructor()) !== null) {
|
||||
if (empty($construct) && ($handler = $reflect->getConstructor()) !== null) {
|
||||
$construct = $this->getMethodParams($handler);
|
||||
}
|
||||
|
||||
$newInstance = $reflect->newInstanceArgs($construct);
|
||||
|
||||
return $this->runInit($reflect, static::configure($newInstance, $config));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param ReflectionClass $reflect
|
||||
* @param array $construct
|
||||
@@ -191,7 +195,7 @@ class Container implements ContainerInterface
|
||||
throw new ReflectionException('Class ' . $reflect->getName() . ' cannot be instantiated');
|
||||
}
|
||||
|
||||
if (($handler = $reflect->getConstructor()) !== null) {
|
||||
if (empty($construct) && ($handler = $reflect->getConstructor()) !== null) {
|
||||
$construct = $this->getMethodParams($handler);
|
||||
}
|
||||
$newInstance = $reflect->newInstanceArgs($construct);
|
||||
@@ -304,7 +308,8 @@ class Container implements ContainerInterface
|
||||
{
|
||||
$className = $parameters->getDeclaringClass()->getName();
|
||||
$methodName = $parameters->getName();
|
||||
if (!isset($this->_parameters[$className])) $this->_parameters[$className] = [];
|
||||
if (!isset($this->_parameters[$className]))
|
||||
$this->_parameters[$className] = [];
|
||||
if (!isset($this->_parameters[$className][$methodName])) {
|
||||
return $this->_parameters[$className][$methodName] = $this->resolveMethodParams($parameters);
|
||||
} else {
|
||||
|
||||
@@ -14,7 +14,7 @@ class CoroutineContext implements ContextInterface
|
||||
*/
|
||||
public static function inCoroutine(): bool
|
||||
{
|
||||
return true;
|
||||
return Coroutine::getCid() > -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -83,6 +83,9 @@ class Scanner extends Component
|
||||
{
|
||||
try {
|
||||
require_once "$path";
|
||||
if (!isset($_SERVER['PWD'])) {
|
||||
$_SERVER['PWD'] = APP_PATH;
|
||||
}
|
||||
$path = str_replace($_SERVER['PWD'], '', $path);
|
||||
$path = str_replace('.php', '', $path);
|
||||
$this->parseFile($path);
|
||||
|
||||
Reference in New Issue
Block a user