Skip to content

Commit 593bdfb

Browse files
authoredAug 3, 2024
Merge pull request #2388 from Haehnchen/feature/fix-multiple-attributes
fix indexing routing php attributes, when different attribtes in same method
2 parents 63c305c + c351ef2 commit 593bdfb

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed
 

‎src/main/java/fr/adrienbrault/idea/symfony2plugin/stubs/indexes/visitor/AnnotationRouteElementVisitor.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,15 @@ public void visitFile(@NotNull PhpClass phpClass) {
5757
PhpDocUtil.processTagElementsByPredicate(docComment, this::visitPhpDocTag, phpDocTag -> true);
5858
}
5959

60-
PhpAttributesList childOfType = PsiTreeUtil.getChildOfType(method, PhpAttributesList.class);
61-
if (childOfType != null) {
62-
visitPhpAttributesList(childOfType, method, phpClass, false);
60+
for (PhpAttributesList phpAttributesList : PsiTreeUtil.getChildrenOfTypeAsList(method, PhpAttributesList.class)) {
61+
visitPhpAttributesList(phpAttributesList, method, phpClass, false);
6362
}
6463
}
6564

6665
Method invoke = phpClass.findOwnMethodByName("__invoke");
6766
if (invoke != null) {
68-
PhpAttributesList childOfType = PsiTreeUtil.getChildOfType(phpClass, PhpAttributesList.class);
69-
if (childOfType != null) {
70-
visitPhpAttributesList(childOfType, invoke, phpClass, true);
67+
for (PhpAttributesList phpAttributesList : PsiTreeUtil.getChildrenOfTypeAsList(phpClass, PhpAttributesList.class)) {
68+
visitPhpAttributesList(phpAttributesList, invoke, phpClass, true);
7169
}
7270
}
7371
}

‎src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/stubs/indexes/RoutesStubIndexTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public void testRouteIdIndex() {
3232
assertIndexContains(RoutesStubIndex.KEY,
3333
"foo_yaml_pattern", "foo_yaml_path", "foo_yaml_path_only",
3434
"foo_xml_pattern", "foo_xml_path", "foo_xml_id_only", "attributes_action", "app_my_default_attributeswithoutname",
35-
"my_post_emptyannotation", "myattributesprefix_prefixdefaultparameter_emptyattribute"
35+
"my_post_emptyannotation", "myattributesprefix_prefixdefaultparameter_emptyattribute", "multiple_attributes"
3636
);
3737

3838
assertIndexNotContains(RoutesStubIndex.KEY,

‎src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/stubs/indexes/fixtures/RoutesStubIndex.php

+6
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,12 @@ public function attributesAction()
187187
{
188188
}
189189

190+
#[IsFoobar()]
191+
#[Route('/multiple_attributes', name: 'multiple_attributes')]
192+
public function multipleAttributes()
193+
{
194+
}
195+
190196
#[Route('/attributesWithoutName', methods: ['GET', 'POST'])]
191197
public function attributesWithoutName()
192198
{

0 commit comments

Comments
 (0)
Failed to load comments.