This commit is contained in:
2020-12-14 17:42:48 +08:00
parent 27f94b97a9
commit 1cb3def5b0
2 changed files with 9 additions and 9 deletions
+6 -6
View File
@@ -28,7 +28,7 @@ class Middleware
* @param $call * @param $call
* @return $this * @return $this
*/ */
public function set($call) public function set($call): static
{ {
$this->middleWares[] = $call; $this->middleWares[] = $call;
return $this; return $this;
@@ -38,7 +38,7 @@ class Middleware
* @param array $array * @param array $array
* @return $this * @return $this
*/ */
public function setMiddleWares(array $array) public function setMiddleWares(array $array): static
{ {
$this->middleWares = $array; $this->middleWares = $array;
return $this; return $this;
@@ -46,10 +46,10 @@ class Middleware
/** /**
* @param Node $node * @param Node $node
* @return mixed * @return array
* @throws Exception * @throws Exception
*/ */
public function getGenerate(Node $node) public function getGenerate(Node $node): array
{ {
return $node->callback = Reduce::reduce(function ($passable) use ($node) { return $node->callback = Reduce::reduce(function ($passable) use ($node) {
return Dispatch::create($node->handler, $passable)->dispatch(); return Dispatch::create($node->handler, $passable)->dispatch();
@@ -61,7 +61,7 @@ class Middleware
* @param Node $node * @param Node $node
* @return array * @return array
*/ */
protected function annotation(Node $node) protected function annotation(Node $node): array
{ {
$middleWares = $this->middleWares; $middleWares = $this->middleWares;
$this->middleWares = []; $this->middleWares = [];
@@ -80,7 +80,7 @@ class Middleware
* @param $middleWares * @param $middleWares
* @return array * @return array
*/ */
protected function annotation_limit(Node $node, $middleWares) protected function annotation_limit(Node $node, $middleWares): array
{ {
if (!$node->hasLimits()) { if (!$node->hasLimits()) {
return $middleWares; return $middleWares;
+3 -3
View File
@@ -394,7 +394,7 @@ class Node extends Application
if (!($class instanceof \HttpServer\IInterface\Middleware)) { if (!($class instanceof \HttpServer\IInterface\Middleware)) {
return; return;
} }
$class = [$class, 'handler']; $class = [$class, 'onHandler'];
} }
$this->middleware[] = $class; $this->middleware[] = $class;
$this->restructure(); $this->restructure();
@@ -420,7 +420,7 @@ class Node extends Application
* @return mixed * @return mixed
* @throws Exception * @throws Exception
*/ */
public function dispatch() public function dispatch(): mixed
{ {
if (empty($this->callback)) { if (empty($this->callback)) {
return JSON::to(404, $node->_error ?? 'Page not found.'); return JSON::to(404, $node->_error ?? 'Page not found.');
@@ -435,7 +435,7 @@ class Node extends Application
* @return array * @return array
* @throws Exception * @throws Exception
*/ */
private function each($array, $_temp) private function each($array, $_temp): array
{ {
if (!is_array($array)) { if (!is_array($array)) {
return $_temp; return $_temp;