@@ -514,14 +514,13 @@ public static Map<String, Route> getRoutesInsideUrlGeneratorFile(@NotNull PsiFil
514514                routes .put (routeArray .getKey (), route );
515515
516516                for  (ArrayCreationExpression  expression  : routeArrayOptions ) {
517-                     for  (ArrayHashElement  e  : expression .getHashElements ()) {
518-                         PhpPsiElement  key  = e .getKey ();
519-                         if  (key  != null  && "'_canonical_route'" .equals (key .getText ())) {
520-                             PhpPsiElement  value  = e .getValue ();
521-                             if  (value  != null ) {
522-                                 String  canonical  = value .getText ().replace ("'" , "" );
523-                                 if  (!routes .containsKey (canonical )) {
524-                                     routes .put (canonical , route );
517+                     for  (ArrayHashElement  arrayHashElement  : expression .getHashElements ()) {
518+                         if  (arrayHashElement .getKey () instanceof  StringLiteralExpression  stringLiteralExpression  && "_canonical_route" .equals (stringLiteralExpression .getContents ())) {
519+                             if  (arrayHashElement .getValue () instanceof  StringLiteralExpression  literalExpression ) {
520+                                 String  canonical  = literalExpression .getContents ();
521+                                 if  (!canonical .isBlank () && !routes .containsKey (canonical )) {
522+                                     Route  routeCanonical  = convertRouteConfigForReturnArray (canonical , routeArrayOptions );
523+                                     routes .put (canonical , routeCanonical );
525524                                }
526525                            }
527526                            break ;
@@ -621,7 +620,7 @@ private static void collectRoutesOnArrayCreation(@NotNull Map<String, Route> rou
621620    @ NotNull 
622621    private  static  Route  convertRouteConfigForReturnArray (@ NotNull  String  routeName , @ NotNull  List <ArrayCreationExpression > hashElementCollection ) {
623622        Set <String > variables  = new  HashSet <>();
624-         if (hashElementCollection .size () >=  1  && hashElementCollection .get (0 ) != null ) {
623+         if (! hashElementCollection .isEmpty ()  && hashElementCollection .get (0 ) != null ) {
625624            ArrayCreationExpression  value  = hashElementCollection .get (0 );
626625            if (value  != null ) {
627626                variables .addAll (PhpElementsUtil .getArrayValuesAsString (value ));
@@ -664,9 +663,9 @@ private static Route convertRouteConfigForReturnArray(@NotNull String routeName,
664663
665664                        List <String > collect  = foo .stream ()
666665                            .map (psiElement  -> psiElement .getFirstChild () instanceof  StringLiteralExpression  ? ((StringLiteralExpression ) psiElement .getFirstChild ()).getContents () : null )
667-                             .collect ( Collectors . toList () );
666+                             .toList ();
668667
669-                         if  (collect .size () >  0 ) {
668+                         if  (! collect .isEmpty () ) {
670669                            path .append (collect .get (1 ));
671670                        }
672671
@@ -683,7 +682,7 @@ private static Route convertRouteConfigForReturnArray(@NotNull String routeName,
683682        }
684683
685684        // hostTokens = 4 need them? 
686-         return  new  Route (routeName , variables , defaults , requirements , tokens , (path .length () ==  0 ) ? null  : path .toString ());
685+         return  new  Route (routeName , variables , defaults , requirements , tokens , (path .isEmpty () ) ? null  : path .toString ());
687686    }
688687
689688    /** 
@@ -695,7 +694,7 @@ private static Route convertRouteConfig(@NotNull String routeName, @NotNull Arra
695694        hashValue .getHashElements ().forEach (hashElementCollection ::add );
696695
697696        Set <String > variables  = new  HashSet <>();
698-         if (hashElementCollection .size () >=  1  && hashElementCollection .get (0 ).getValue () instanceof  ArrayCreationExpression  value ) {
697+         if (! hashElementCollection .isEmpty ()  && hashElementCollection .get (0 ).getValue () instanceof  ArrayCreationExpression  value ) {
699698            if (value  != null ) {
700699                variables .addAll (PhpElementsUtil .getArrayKeyValueMap (value ).values ());
701700            }
0 commit comments