This commit is contained in:
2020-12-15 18:25:03 +08:00
parent edad73659a
commit d8bcf9ebe0
4 changed files with 1 additions and 52 deletions
+1 -7
View File
@@ -198,22 +198,16 @@ class Node extends Application
* @return null|array
* @throws Exception
*/
private function getReflect(string $controller, string $action)
private function getReflect(string $controller, string $action): ?array
{
try {
$reflect = Snowflake::getDi()->getReflect($controller);
if (!$reflect->isInstantiable()) {
throw new Exception($controller . ' Class is con\'t Instantiable.');
}
if (!empty($action) && !$reflect->hasMethod($action)) {
throw new Exception('method ' . $action . ' not exists at ' . $controller . '.');
}
$annotation = Snowflake::app()->annotation->http;
if (!empty($annotations = $annotation->getAnnotation(Http::class))) {
$annotation->read($this, $reflect, $action, $annotations);
}
return [$reflect->newInstance(), $action];
} catch (\Throwable $exception) {
$this->_error = $exception->getMessage();