Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f9e23c59ef | |||
| f89e8106f5 | |||
| 2f02c5af12 | |||
| 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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+7
-1
@@ -37,7 +37,7 @@ class Scanner extends Component
|
||||
public function load_directory(string $path): void
|
||||
{
|
||||
$dir = new \DirectoryIterator($path);
|
||||
$skip = \config('scanner.skip', []);
|
||||
$skip = \config('site.scanner.skip', []);
|
||||
foreach ($dir as $value) {
|
||||
if ($value->isDot() || str_starts_with($value->getFilename(), '.')) {
|
||||
continue;
|
||||
@@ -82,7 +82,13 @@ class Scanner extends Component
|
||||
private function load_file(string $path): void
|
||||
{
|
||||
try {
|
||||
opcache_invalidate($path);
|
||||
opcache_compile_file($path);
|
||||
|
||||
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);
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@
|
||||
],
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": ">=8.0",
|
||||
"php": ">=8.4",
|
||||
"psr/container": "^2.0"
|
||||
},
|
||||
"autoload": {
|
||||
|
||||
Reference in New Issue
Block a user