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
* @return $this
*/
public function set($call)
public function set($call): static
{
$this->middleWares[] = $call;
return $this;
@@ -38,7 +38,7 @@ class Middleware
* @param array $array
* @return $this
*/
public function setMiddleWares(array $array)
public function setMiddleWares(array $array): static
{
$this->middleWares = $array;
return $this;
@@ -46,10 +46,10 @@ class Middleware
/**
* @param Node $node
* @return mixed
* @return array
* @throws Exception
*/
public function getGenerate(Node $node)
public function getGenerate(Node $node): array
{
return $node->callback = Reduce::reduce(function ($passable) use ($node) {
return Dispatch::create($node->handler, $passable)->dispatch();
@@ -61,7 +61,7 @@ class Middleware
* @param Node $node
* @return array
*/
protected function annotation(Node $node)
protected function annotation(Node $node): array
{
$middleWares = $this->middleWares;
$this->middleWares = [];
@@ -80,7 +80,7 @@ class Middleware
* @param $middleWares
* @return array
*/
protected function annotation_limit(Node $node, $middleWares)
protected function annotation_limit(Node $node, $middleWares): array
{
if (!$node->hasLimits()) {
return $middleWares;
+3 -3
View File
@@ -394,7 +394,7 @@ class Node extends Application
if (!($class instanceof \HttpServer\IInterface\Middleware)) {
return;
}
$class = [$class, 'handler'];
$class = [$class, 'onHandler'];
}
$this->middleware[] = $class;
$this->restructure();
@@ -420,7 +420,7 @@ class Node extends Application
* @return mixed
* @throws Exception
*/
public function dispatch()
public function dispatch(): mixed
{
if (empty($this->callback)) {
return JSON::to(404, $node->_error ?? 'Page not found.');
@@ -435,7 +435,7 @@ class Node extends Application
* @return array
* @throws Exception
*/
private function each($array, $_temp)
private function each($array, $_temp): array
{
if (!is_array($array)) {
return $_temp;