Skip to content

Commit

Permalink
support indexing of template assignment expression for Twig template …
Browse files Browse the repository at this point in the history
…names
  • Loading branch information
Haehnchen committed Dec 3, 2019
1 parent 77be1ed commit 63fb721
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,12 @@ private void visitMethodReference(@NotNull MethodReference methodReference) {
resolvePhpReference(methodReference, phpPsiElement);
}
}
} else if(parameters[0] instanceof AssignmentExpression) {
// $this->render($template = 'foo.html.twig')
PhpPsiElement value = ((AssignmentExpression) parameters[0]).getValue();
if(value != null) {
resolveString(methodReference, value);
}
} else if(parameters[0] instanceof PhpReference) {
resolvePhpReference(methodReference, parameters[0]);
} else if(parameters[0] instanceof BinaryExpression) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public void testThatTwigRenderMethodsAreInIndex() {
" $foo->render($foobar ?? self::FOO_COALESCE);\n" +
" $foo->render('@!Foo/overwrite.html.twig');\n" +
" $foo->renderView('foo-renderView.html.twig');\n" +
" $foo->renderView($t = 'foo-var-assignment-expression.html.twig');\n" +
" $foo->renderResponse('foo-renderResponse.html.twig');\n" +
" $foo->render(self::FOO);\n" +
" $foo->render($var);\n" +
Expand All @@ -46,7 +47,8 @@ public void testThatTwigRenderMethodsAreInIndex() {
PhpTwigTemplateUsageStubIndex.KEY,
"foo-render.html.twig", "foo-renderView.html.twig", "foo-renderResponse.html.twig",
"@Foo/overwrite.html.twig", "const.html.twig", "var.html.twig", "private.html.twig", "foobar-render.twig",
"foo-render-ternary.html.twig", "const-ternary.html.twig", "foo-render-coalesce.html.twig", "const-coalesce.html.twig"
"foo-render-ternary.html.twig", "const-ternary.html.twig", "foo-render-coalesce.html.twig", "const-coalesce.html.twig",
"foo-var-assignment-expression.html.twig"
);

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

0 comments on commit 63fb721

Please sign in to comment.