You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- [R] Real PHP8 compatible release.
- [!] эта минорная версия - latest перед полным переходом на PHP8
- [+] добавлена зависимость `psr/log: ^1 | ^2 | ^3`
- [+] внедрен код библиотеки FastRouter (отказ от внешней зависимости)
- [*] исправлена проблема с доп.информацией в Exceptions
- [*] если в dispatch выяснилось, что handler пустой - кидаем исключение `AppRouterHandlerError`
- [*] добавлена проверка в `is_handler()`, переданный пустой массив - ошибка (false)
- [*] исправлен `compileHandler()` - пустой массив является ошибкой
- [*] исправлен `getInternalRuleKey()` - для пустого массива или неуказанного класса генерится ключ на основе роута и метода.
thrownewAppRouterHandlerError("Handler not found or empty", 500, [
551
+
'uri' => self::$uri,
552
+
'method' => self::$httpMethod,
553
+
'info' => self::$routeInfo
554
+
]);
555
+
}
556
+
548
557
// dispatch errors
549
558
if ($state === Dispatcher::NOT_FOUND) {
550
-
thrownewAppRouterNotFoundException("URL not found", 404, null, [
559
+
thrownewAppRouterNotFoundException("URL not found", 404, [
551
560
'method' => self::$httpMethod,
552
561
'uri' => self::$uri
553
562
]);
554
563
}
555
564
556
565
if ($state === Dispatcher::METHOD_NOT_ALLOWED) {
557
-
thrownewAppRouterMethodNotAllowedException("Method " . self::$httpMethod . " not allowed for URI " . self::$uri, 405, null, [
566
+
thrownewAppRouterMethodNotAllowedException("Method " . self::$httpMethod . " not allowed for URI " . self::$uri, 405, [
558
567
'uri' => self::$uri,
559
568
'method' => self::$httpMethod,
560
569
'info' => self::$routeInfo
@@ -639,6 +648,10 @@ public static function getRoutingRules(): array
639
648
}
640
649
641
650
/**
651
+
* @todo: объединить is_handler и compileHandler - они выполняют одну и ту же работу, но сначала делается is_handler, а потом compileHandler перед выполнением
652
+
* Надо сразу компилировать хэндлэр сразу с проверкой и кидать исключение на раннем этапе. Возможно, вообще на этапе прописывания роута!
653
+
*
654
+
*
642
655
* Выясняет, является ли передаваемый аргумент допустимым хэндлером
643
656
*
644
657
* @todo: переделать код так, чтобы хэндлер `\Path\To\Class::method` вызывал не сразу статический класс,
@@ -656,6 +669,10 @@ public static function is_handler($handler = null, bool $validate_handlers = fal
656
669
} elseif ($handlerinstanceof \Closure) {
657
670
returntrue;
658
671
} elseif (\is_array($handler)) {
672
+
if (empty($handler)) {
673
+
returnfalse;
674
+
}
675
+
659
676
// [ \Path\To\Class:class, "method" ]
660
677
661
678
$class = $handler[0];
@@ -706,7 +723,7 @@ public static function is_handler($handler = null, bool $validate_handlers = fal
706
723
707
724
returntrue;
708
725
}
709
-
returnfalse;
726
+
710
727
} // is_handler()
711
728
712
729
/**
@@ -721,6 +738,10 @@ private static function compileHandler($handler)
721
738
if ($handlerinstanceof \Closure) {
722
739
$actor = $handler;
723
740
} elseif (\is_array($handler)) {
741
+
if (empty($handler)) {
742
+
return [];
743
+
}
744
+
724
745
// [ \Path\To\Class:class, "method" ]
725
746
726
747
$class = $handler[0];
@@ -774,10 +795,11 @@ private static function compileHandler($handler)
0 commit comments