modify plugin name
This commit is contained in:
+3
-1
@@ -5,13 +5,15 @@ namespace PHPSTORM_META {
|
|||||||
// Reflect
|
// Reflect
|
||||||
use Kiri\Di\Container;
|
use Kiri\Di\Container;
|
||||||
use Kiri\Di\ContainerInterface;
|
use Kiri\Di\ContainerInterface;
|
||||||
|
use Psr\Container\ContainerInterface as SC;
|
||||||
|
|
||||||
override(ContainerInterface::get(0), map('@'));
|
override(ContainerInterface::get(0), map('@'));
|
||||||
|
override(SC::get(0), map('@'));
|
||||||
override(Container::get(0), map('@'));
|
override(Container::get(0), map('@'));
|
||||||
override(Container::make(0), map('@'));
|
override(Container::make(0), map('@'));
|
||||||
override(Container::create(0), map('@'));
|
override(Container::create(0), map('@'));
|
||||||
// override(\Hyperf\Utils\Context::get(0), map('@'));
|
// override(\Hyperf\Utils\Context::get(0), map('@'));
|
||||||
// override(\make(0), map('@'));
|
override(\make(0), map('@'));
|
||||||
override(\di(0), map('@'));
|
override(\di(0), map('@'));
|
||||||
override(\duplicate(0), map('@'));
|
override(\duplicate(0), map('@'));
|
||||||
|
|
||||||
|
|||||||
@@ -13,9 +13,14 @@ use Exception;
|
|||||||
use Kiri;
|
use Kiri;
|
||||||
use Kiri\Abstracts\Component;
|
use Kiri\Abstracts\Component;
|
||||||
use Kiri\Core\Json;
|
use Kiri\Core\Json;
|
||||||
|
use Kiri\Annotation\Inject;
|
||||||
use Kiri\Events\EventDispatch;
|
use Kiri\Events\EventDispatch;
|
||||||
use Kiri\Message\Events\OnAfterRequest;
|
use Kiri\Message\Events\OnAfterRequest;
|
||||||
use Kiri\Message\Handler\Formatter\IFormatter;
|
use Kiri\Message\Handler\Formatter\IFormatter;
|
||||||
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
|
use Kiri\Server\Events\OnShutdown;
|
||||||
|
use ReflectionException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ErrorHandler
|
* Class ErrorHandler
|
||||||
@@ -31,6 +36,14 @@ class ErrorHandler extends Component implements ErrorInterface
|
|||||||
|
|
||||||
public string $category = 'app';
|
public string $category = 'app';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var EventDispatch
|
||||||
|
*/
|
||||||
|
#[Inject(EventDispatch::class)]
|
||||||
|
public EventDispatch $dispatch;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 错误处理注册
|
* 错误处理注册
|
||||||
*/
|
*/
|
||||||
@@ -42,9 +55,13 @@ class ErrorHandler extends Component implements ErrorInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @return void
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
|
* @throws ReflectionException
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function shutdown()
|
public function shutdown(): void
|
||||||
{
|
{
|
||||||
$lastError = error_get_last();
|
$lastError = error_get_last();
|
||||||
if (empty($lastError) || $lastError['type'] !== E_ERROR) {
|
if (empty($lastError) || $lastError['type'] !== E_ERROR) {
|
||||||
@@ -57,6 +74,8 @@ class ErrorHandler extends Component implements ErrorInterface
|
|||||||
|
|
||||||
$message = array_shift($messages);
|
$message = array_shift($messages);
|
||||||
|
|
||||||
|
$this->dispatch->dispatch(new OnShutdown());
|
||||||
|
|
||||||
$this->sendError($message, $lastError['file'], $lastError['line']);
|
$this->sendError($message, $lastError['file'], $lastError['line']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,22 +83,26 @@ class ErrorHandler extends Component implements ErrorInterface
|
|||||||
/**
|
/**
|
||||||
* @param \Throwable $exception
|
* @param \Throwable $exception
|
||||||
*
|
*
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
|
* @throws ReflectionException
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function exceptionHandler(\Throwable $exception)
|
public function exceptionHandler(\Throwable $exception)
|
||||||
{
|
{
|
||||||
$this->category = 'exception';
|
$this->category = 'exception';
|
||||||
|
|
||||||
di(EventDispatch::class)->dispatch(new OnAfterRequest());
|
$this->dispatch->dispatch(new OnAfterRequest());
|
||||||
|
|
||||||
$this->sendError($exception->getMessage(), $exception->getFile(), $exception->getLine());
|
$this->sendError($exception->getMessage(), $exception->getFile(), $exception->getLine());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws Exception
|
* @throws \ErrorException
|
||||||
*
|
* @throws ContainerExceptionInterface
|
||||||
* 以异常形式抛出错误,防止执行后续程序
|
* @throws NotFoundExceptionInterface
|
||||||
|
* @throws ReflectionException
|
||||||
*/
|
*/
|
||||||
public function errorHandler()
|
public function errorHandler()
|
||||||
{
|
{
|
||||||
@@ -95,7 +118,7 @@ class ErrorHandler extends Component implements ErrorInterface
|
|||||||
|
|
||||||
$this->logger->error('On error handler', [$data]);
|
$this->logger->error('On error handler', [$data]);
|
||||||
|
|
||||||
di(EventDispatch::class)->dispatch(new OnAfterRequest());
|
$this->dispatch->dispatch(new OnAfterRequest());
|
||||||
|
|
||||||
throw new \ErrorException($error[1], $error[0], 1, $error[2], $error[3]);
|
throw new \ErrorException($error[1], $error[0], 1, $error[2], $error[3]);
|
||||||
}
|
}
|
||||||
@@ -116,8 +139,6 @@ class ErrorHandler extends Component implements ErrorInterface
|
|||||||
|
|
||||||
file_put_contents('php://output', $data . PHP_EOL, FILE_APPEND);
|
file_put_contents('php://output', $data . PHP_EOL, FILE_APPEND);
|
||||||
|
|
||||||
write($data, $this->category);
|
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user