13 Commits

Author SHA1 Message Date
as2252258 f9e23c59ef 添加opcache重置
Signed-off-by: 向林 <as2252258@163.com>
2025-12-22 06:57:32 +00:00
as2252258 f89e8106f5 eee 2025-12-18 15:39:42 +08:00
as2252258 2f02c5af12 eee 2025-07-14 15:34:56 +08:00
as2252258 9e954135f6 eee 2025-07-11 15:55:15 +08:00
as2252258 7de790d65f eee 2025-07-11 15:32:33 +08:00
as2252258 855da03137 eee 2025-07-11 15:28:10 +08:00
as2252258 0081a30f22 eee 2025-07-11 15:25:06 +08:00
as2252258 3f2d3b0f04 eee 2025-07-11 15:22:52 +08:00
as2252258 5fa5646024 eee 2025-07-11 15:11:27 +08:00
as2252258 045c9293d5 eee 2025-07-11 11:51:05 +08:00
as2252258 6ae7f5a721 eee 2024-11-21 10:43:16 +08:00
as2252258 9775d16db5 eee 2024-11-06 21:47:21 +08:00
as2252258 03bffb5e5b eee 2024-11-06 21:41:43 +08:00
4 changed files with 18 additions and 7 deletions
+9 -4
View File
@@ -14,6 +14,7 @@ use Closure;
use Exception; use Exception;
use Kiri\Di\Interface\InjectTargetInterface; use Kiri\Di\Interface\InjectTargetInterface;
use Kiri\Router\Interface\ValidatorInterface; use Kiri\Router\Interface\ValidatorInterface;
use Kiri\Server\Task\OnTaskFinish;
use Psr\Container\ContainerInterface; use Psr\Container\ContainerInterface;
use ReflectionAttribute; use ReflectionAttribute;
use ReflectionClass; use ReflectionClass;
@@ -91,7 +92,8 @@ class Container implements ContainerInterface
*/ */
public function get(string $id): object 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])) { if (isset($this->_interfaces[$id])) {
return $this->_singletons[$id] = $this->make($this->_interfaces[$id]); return $this->_singletons[$id] = $this->make($this->_interfaces[$id]);
} else { } else {
@@ -165,15 +167,17 @@ class Container implements ContainerInterface
throw new ReflectionException('Class ' . $className . ' cannot be instantiated'); throw new ReflectionException('Class ' . $className . ' cannot be instantiated');
} }
if (($handler = $reflect->getConstructor()) !== null) { if (empty($construct) && ($handler = $reflect->getConstructor()) !== null) {
$construct = $this->getMethodParams($handler); $construct = $this->getMethodParams($handler);
} }
$newInstance = $reflect->newInstanceArgs($construct); $newInstance = $reflect->newInstanceArgs($construct);
return $this->runInit($reflect, static::configure($newInstance, $config)); return $this->runInit($reflect, static::configure($newInstance, $config));
} }
/** /**
* @param ReflectionClass $reflect * @param ReflectionClass $reflect
* @param array $construct * @param array $construct
@@ -191,7 +195,7 @@ class Container implements ContainerInterface
throw new ReflectionException('Class ' . $reflect->getName() . ' cannot be instantiated'); 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); $construct = $this->getMethodParams($handler);
} }
$newInstance = $reflect->newInstanceArgs($construct); $newInstance = $reflect->newInstanceArgs($construct);
@@ -304,7 +308,8 @@ class Container implements ContainerInterface
{ {
$className = $parameters->getDeclaringClass()->getName(); $className = $parameters->getDeclaringClass()->getName();
$methodName = $parameters->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])) { if (!isset($this->_parameters[$className][$methodName])) {
return $this->_parameters[$className][$methodName] = $this->resolveMethodParams($parameters); return $this->_parameters[$className][$methodName] = $this->resolveMethodParams($parameters);
} else { } else {
+1 -1
View File
@@ -14,7 +14,7 @@ class CoroutineContext implements ContextInterface
*/ */
public static function inCoroutine(): bool public static function inCoroutine(): bool
{ {
return true; return Coroutine::getCid() > -1;
} }
+7 -1
View File
@@ -37,7 +37,7 @@ class Scanner extends Component
public function load_directory(string $path): void public function load_directory(string $path): void
{ {
$dir = new \DirectoryIterator($path); $dir = new \DirectoryIterator($path);
$skip = \config('scanner.skip', []); $skip = \config('site.scanner.skip', []);
foreach ($dir as $value) { foreach ($dir as $value) {
if ($value->isDot() || str_starts_with($value->getFilename(), '.')) { if ($value->isDot() || str_starts_with($value->getFilename(), '.')) {
continue; continue;
@@ -82,7 +82,13 @@ class Scanner extends Component
private function load_file(string $path): void private function load_file(string $path): void
{ {
try { try {
opcache_invalidate($path);
opcache_compile_file($path);
require_once "$path"; require_once "$path";
if (!isset($_SERVER['PWD'])) {
$_SERVER['PWD'] = APP_PATH;
}
$path = str_replace($_SERVER['PWD'], '', $path); $path = str_replace($_SERVER['PWD'], '', $path);
$path = str_replace('.php', '', $path); $path = str_replace('.php', '', $path);
$this->parseFile($path); $this->parseFile($path);
+1 -1
View File
@@ -9,7 +9,7 @@
], ],
"license": "MIT", "license": "MIT",
"require": { "require": {
"php": ">=8.0", "php": ">=8.4",
"psr/container": "^2.0" "psr/container": "^2.0"
}, },
"autoload": { "autoload": {