@@ -626,14 +626,13 @@ public static function dispatch()
626
626
// Fetch method and URI from somewhere
627
627
self ::$ routeInfo = $ routeInfo = (self ::$ dispatcher ->dispatcher ())->dispatch (self ::$ httpMethod , self ::$ uri );
628
628
629
+ // несмотря на то, что $routeInfo - Arris\AppRouter\FastRoute\Dispatcher\Result\Matched - доступ по [N] возможен, поскольку
630
+ // класс реализует метод ArrayAccess
631
+ //
629
632
$ state = $ routeInfo [0 ]; // тут ВСЕГДА что-то есть
630
633
$ handler = $ routeInfo [1 ] ?? [];
631
634
$ method_parameters = $ routeInfo [2 ] ?? [];
632
635
633
- // Так нельзя:
634
- // [$state, $handler, $method_parameters] = $routeInfo + [null, null, []];
635
- // Fatal error: Uncaught TypeError: Unsupported operand types: Arris\AppRouter\FastRoute\Dispatcher\Result\Matched + array
636
-
637
636
// dispatch errors
638
637
if ($ state === Dispatcher::NOT_FOUND ) {
639
638
throw new AppRouterNotFoundException ("URL not found " , 404 , [
@@ -655,8 +654,8 @@ public static function dispatch()
655
654
]);
656
655
}
657
656
658
- // Route Rule доступен только для Matched-роутов.
659
- self ::$ routeRule = $ rule = $ routeInfo [3 ] ?? [] ;
657
+ // Route Rule доступен только для Matched-роутов - 3=extra parameters - он всегда есть и не пустой
658
+ self ::$ routeRule = $ rule = $ routeInfo [3 ];
660
659
661
660
$ actor = self ::compileHandler ($ handler , false , 'default ' );
662
661
@@ -899,7 +898,14 @@ private static function compileHandler($handler, bool $is_middleware = false): a
899
898
900
899
// [ \Path\To\Class:class, "method" ]
901
900
if (is_array ($ handler )) {
902
- [$ class , $ method ] = $ handler + [null , '__invoke ' ];
901
+ // [$class, $method] = $handler + [null, '__invoke']; // Recommended by DeepSeek
902
+
903
+ if (count ($ handler ) == 2 ) {
904
+ list ($ class , $ method ) = $ handler ;
905
+ } else {
906
+ $ class = $ handler [0 ];
907
+ $ method = '__invoke ' ;
908
+ }
903
909
904
910
self ::checkClassExists ($ class );
905
911
self ::checkMethodExists ($ class , $ method );
0 commit comments