|
14 | 14 | import com.jetbrains.php.lang.psi.elements.PhpAttribute; |
15 | 15 | import com.jetbrains.php.lang.psi.elements.PhpClass; |
16 | 16 | import com.jetbrains.php.lang.psi.elements.PhpNamedElement; |
17 | | -import com.jetbrains.php.lang.psi.stubs.indexes.expectedArguments.PhpExpectedFunctionArgument; |
18 | 17 | import fr.adrienbrault.idea.symfony2plugin.util.PhpElementsUtil; |
19 | | -import fr.adrienbrault.idea.symfony2plugin.util.PsiElementUtils; |
20 | | -import org.apache.commons.lang.StringUtils; |
| 18 | +import fr.adrienbrault.idea.symfony2plugin.util.PhpPsiAttributesUtil; |
21 | 19 | import org.jetbrains.annotations.NotNull; |
22 | 20 | import org.jetbrains.annotations.Nullable; |
23 | 21 |
|
24 | | -import java.util.Collection; |
25 | | - |
26 | 22 | /** |
27 | 23 | * @author Daniel Espendiller <daniel@espendiller.net> |
28 | 24 | */ |
@@ -69,20 +65,12 @@ public static String getCommandNameFromClass(@NotNull PhpClass phpClass) { |
69 | 65 | } |
70 | 66 |
|
71 | 67 | // php attributes: |
| 68 | + // #[AsCommand('app:create-user')] |
72 | 69 | // #[AsCommand(name: 'app:create-user')] |
73 | 70 | for (PhpAttribute attribute : phpClass.getAttributes("\\Symfony\\Component\\Console\\Attribute\\AsCommand")) { |
74 | | - for (PhpAttribute.PhpAttributeArgument argument : attribute.getArguments()) { |
75 | | - String name = argument.getName(); |
76 | | - if ("name".equals(name)) { |
77 | | - PhpExpectedFunctionArgument argument1 = argument.getArgument(); |
78 | | - if (argument1 != null) { |
79 | | - String value1 = PsiElementUtils.trimQuote(argument1.getValue()); |
80 | | - if (StringUtils.isNotBlank(value1)) { |
81 | | - return value1; |
82 | | - } |
83 | | - } |
84 | | - break; |
85 | | - } |
| 71 | + String name = PhpPsiAttributesUtil.getAttributeValueByNameAsStringWithDefaultParameterFallback(attribute, "name"); |
| 72 | + if (name != null) { |
| 73 | + return name; |
86 | 74 | } |
87 | 75 | } |
88 | 76 |
|
|
0 commit comments