8000 support indexing of template assignment expression for Twig template … · SylApps/idea-php-symfony2-plugin@63fb721 · GitHub
[go: up one dir, main page]

Skip to content

Commit 63fb721

Browse files
committed
support indexing of template assignment expression for Twig template names
1 parent 77be1ed commit 63fb721

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/util/PhpMethodVariableResolveUtil.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,12 @@ private void visitMethodReference(@NotNull MethodReference methodReference) {
327327
resolvePhpReference(methodReference, phpPsiElement);
328328
}
329329
}
330+
} else if(parameters[0] instanceof AssignmentExpression) {
331+
// $this->render($template = 'foo.html.twig')
332+
PhpPsiElement value = ((AssignmentExpression) parameters[0]).getValue();
333+
if(value != null) {
334+
resolveString(methodReference, value);
335+
}
330336
} else if(parameters[0] instanceof PhpReference) {
331337
resolvePhpReference(methodReference, parameters[0]);
332338
} else if(parameters[0] instanceof BinaryExpression) {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public void testThatTwigRenderMethodsAreInIndex() {
2828
" $foo->render($foobar ?? self::FOO_COALESCE);\n" +
2929
" $foo->render('@!Foo/overwrite.html.twig');\n" +
3030
" $foo->renderView('foo-renderView.html.twig');\n" +
31+
" $foo->renderView($t = 'foo-var-assignment-expression.html.twig');\n" +
3132
" $foo->renderResponse('foo-renderResponse.html.twig');\n" +
3233
" $foo->render(self::FOO);\n" +
3334
" $foo->render($var);\n" +
@@ -46,7 +47,8 @@ public void testThatTwigRenderMethodsAreInIndex() {
4647
PhpTwigTemplateUsageStubIndex.KEY,
4748
"foo-render.html.twig", "foo-renderView.html.twig", "foo-renderResponse.html.twig",
4849
"@Foo/overwrite.html.twig", "const.html.twig", "var.html.twig", "private.html.twig", "foobar-render.twig",
49-
"foo-render-ternary.html.twig", "const-ternary.html.twig", "foo-render-coalesce.html.twig", "const-coalesce.html.twig"
50+
"foo-render-ternary.html.twig", "const-ternary.html.twig", "foo-render-coalesce.html.twig", "const-coalesce.html.twig",
51+
"foo-var-assignment-expression.html.twig"
5052
);
5153

5254
assertIndexContainsKeyWithValue(PhpTwigTemplateUsageStubIndex.KEY, "foo-render.html.twig", value ->

0 commit comments

Comments
 (0)
0