Skip to content

Commit

Permalink
Merge pull request #2388 from Haehnchen/feature/fix-multiple-attributes
Browse files Browse the repository at this point in the history
fix indexing routing php attributes, when different attribtes in same method
  • Loading branch information
Haehnchen authored Aug 3, 2024
2 parents 63c305c + c351ef2 commit 593bdfb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,15 @@ public void visitFile(@NotNull PhpClass phpClass) {
PhpDocUtil.processTagElementsByPredicate(docComment, this::visitPhpDocTag, phpDocTag -> true);
}

PhpAttributesList childOfType = PsiTreeUtil.getChildOfType(method, PhpAttributesList.class);
if (childOfType != null) {
visitPhpAttributesList(childOfType, method, phpClass, false);
for (PhpAttributesList phpAttributesList : PsiTreeUtil.getChildrenOfTypeAsList(method, PhpAttributesList.class)) {
visitPhpAttributesList(phpAttributesList, method, phpClass, false);
}
}

Method invoke = phpClass.findOwnMethodByName("__invoke");
if (invoke != null) {
PhpAttributesList childOfType = PsiTreeUtil.getChildOfType(phpClass, PhpAttributesList.class);
if (childOfType != null) {
visitPhpAttributesList(childOfType, invoke, phpClass, true);
for (PhpAttributesList phpAttributesList : PsiTreeUtil.getChildrenOfTypeAsList(phpClass, PhpAttributesList.class)) {
visitPhpAttributesList(phpAttributesList, invoke, phpClass, true);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void testRouteIdIndex() {
assertIndexContains(RoutesStubIndex.KEY,
"foo_yaml_pattern", "foo_yaml_path", "foo_yaml_path_only",
"foo_xml_pattern", "foo_xml_path", "foo_xml_id_only", "attributes_action", "app_my_default_attributeswithoutname",
"my_post_emptyannotation", "myattributesprefix_prefixdefaultparameter_emptyattribute"
"my_post_emptyannotation", "myattributesprefix_prefixdefaultparameter_emptyattribute", "multiple_attributes"
);

assertIndexNotContains(RoutesStubIndex.KEY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ public function attributesAction()
{
}

#[IsFoobar()]
#[Route('/multiple_attributes', name: 'multiple_attributes')]
public function multipleAttributes()
{
}

#[Route('/attributesWithoutName', methods: ['GET', 'POST'])]
public function attributesWithoutName()
{
Expand Down

0 comments on commit 593bdfb

Please sign in to comment.