Java Code Examples for com.jetbrains.php.lang.psi.PhpPsiElementFactory#createFunction()
The following examples show how to use
com.jetbrains.php.lang.psi.PhpPsiElementFactory#createFunction() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PhpMethodVariableResolveUtilTest.java From idea-php-symfony2-plugin with MIT License | 6 votes |
/** * @see PhpMethodVariableResolveUtil#collectMethodVariables */ public void testCollectMethodVariablesForVariablesReferences() { Function function = PhpPsiElementFactory.createFunction(getProject(), "function foobar() {\n" + "$myVar = new \\MyVars\\MyVar();\n" + "$var['foobar'] = $myVar;\n" + "$var = ['foobar1' => $myVar];\n" + "\n" + "/** @var $x \\Symfony\\Component\\Templating\\EngineInterface */\n" + "$x->render('foo.html.twig', $var);\n" + "\n" + "}" ); Map<String, PsiVariable> vars = PhpMethodVariableResolveUtil.collectMethodVariables(function); assertContainsElements(vars.keySet(), "foobar"); assertContainsElements(vars.keySet(), "foobar1"); }
Example 2
Source File: PhpMethodVariableResolveUtilTest.java From idea-php-symfony2-plugin with MIT License | 6 votes |
/** * @see PhpMethodVariableResolveUtil#collectMethodVariables */ public void testCollectMethodVariablesForArrayCreation() { Function function = PhpPsiElementFactory.createFunction(getProject(), "function foobar() {\n" + "$myVar = new \\MyVars\\MyVar();\n" + "$var['foobar'] = $myVar;\n" + "\n" + "/** @var $x \\Symfony\\Component\\Templating\\EngineInterface */\n" + "$x->render('foo.html.twig', ['foobar' => $myVar]);\n" + "\n" + "}" ); Map<String, PsiVariable> vars = PhpMethodVariableResolveUtil.collectMethodVariables(function); assertContainsElements(vars.keySet(), "foobar"); }
Example 3
Source File: PhpMethodVariableResolveUtilTest.java From idea-php-symfony2-plugin with MIT License | 6 votes |
/** * @see PhpMethodVariableResolveUtil#collectMethodVariables */ public void testCollectMethodVariablesForArrayMerge() { Function function = PhpPsiElementFactory.createFunction(getProject(), "function foobar() {\n" + "$myVar = new \\MyVars\\MyVar();\n" + "$var['foobar'] = $myVar;\n" + "\n" + "/** @var $x \\Symfony\\Component\\Templating\\EngineInterface */\n" + "$x->render('foo.html.twig', array_merge($var, ['foobar1' => $myVar]));\n" + "\n" + "}" ); Map<String, PsiVariable> vars = PhpMethodVariableResolveUtil.collectMethodVariables(function); assertContainsElements(vars.keySet(), "foobar"); assertContainsElements(vars.keySet(), "foobar1"); }
Example 4
Source File: PhpMethodVariableResolveUtilTest.java From idea-php-symfony2-plugin with MIT License | 6 votes |
/** * @see PhpMethodVariableResolveUtil#collectMethodVariables */ public void testCollectMethodVariablesForBinaryExpression() { Function function = PhpPsiElementFactory.createFunction(getProject(), "function foobar() {\n" + "$myVar = new \\MyVars\\MyVar();\n" + "$var['foobar'] = $myVar;\n" + "\n" + "/** @var $x \\Symfony\\Component\\Templating\\EngineInterface */\n" + "$x->render('foo.html.twig', $var + ['foobar1' => $myVar]);\n" + "\n" + "}" ); Map<String, PsiVariable> vars = PhpMethodVariableResolveUtil.collectMethodVariables(function); assertContainsElements(vars.keySet(), "foobar"); assertContainsElements(vars.keySet(), "foobar1"); }
Example 5
Source File: PhpMethodVariableResolveUtilTest.java From idea-php-symfony2-plugin with MIT License | 6 votes |
/** * @see PhpMethodVariableResolveUtil#collectMethodVariables */ public void testCollectMethodVariablesForOperatorSelfAssignment() { Function function = PhpPsiElementFactory.createFunction(getProject(), "function foobar() {\n" + "$myVar = new \\MyVars\\MyVar();\n" + "$var['foobar'] = $myVar;\n" + "\n" + "/** @var $x \\Symfony\\Component\\Templating\\EngineInterface */\n" + "$x->render('foo.html.twig', $var += ['foobar1' => $myVar]);\n" + "\n" + "}" ); Map<String, PsiVariable> vars = PhpMethodVariableResolveUtil.collectMethodVariables(function); assertContainsElements(vars.keySet(), "foobar"); assertContainsElements(vars.keySet(), "foobar1"); }
Example 6
Source File: PhpMethodVariableResolveUtilTest.java From idea-php-symfony2-plugin with MIT License | 6 votes |
/** * @see PhpMethodVariableResolveUtil#collectMethodVariables */ public void testCollectMethodVariablesForTernary() { Function function = PhpPsiElementFactory.createFunction(getProject(), "function foobar() {\n" + "$myVar = new \\MyVars\\MyVar();\n" + "$var['foobar'] = $myVar;\n" + "\n" + "/** @var $x \\Symfony\\Component\\Templating\\EngineInterface */\n" + "$x->render(true === true ? 'foo.html.twig' : 'foo', $var += ['foobar1' => $myVar]);\n" + "\n" + "}" ); Map<String, PsiVariable> vars = PhpMethodVariableResolveUtil.collectMethodVariables(function); assertContainsElements(vars.keySet(), "foobar"); assertContainsElements(vars.keySet(), "foobar1"); }
Example 7
Source File: PhpMethodVariableResolveUtilTest.java From idea-php-symfony2-plugin with MIT License | 6 votes |
/** * @see PhpMethodVariableResolveUtil#collectMethodVariables */ public void testCollectMethodVariablesForCoalesce() { Function function = PhpPsiElementFactory.createFunction(getProject(), "function foobar() {\n" + "$test = 'foo.html.twig'\n" + "$var['foobar'] = $myVar;\n" + "\n" + "/** @var $x \\Symfony\\Component\\Templating\\EngineInterface */\n" + "$x->render($foobar ?? $test, $var += ['foobar1' => $myVar]);\n" + "\n" + "}" ); Map<String, PsiVariable> vars = PhpMethodVariableResolveUtil.collectMethodVariables(function); assertContainsElements(vars.keySet(), "foobar"); assertContainsElements(vars.keySet(), "foobar1"); }
Example 8
Source File: PhpMethodVariableResolveUtilTest.java From idea-php-symfony2-plugin with MIT License | 6 votes |
/** * @see PhpMethodVariableResolveUtil#collectMethodVariables */ public void testCollectMethodVariablesForVariable() { Function function = PhpPsiElementFactory.createFunction(getProject(), "function foobar() {\n" + "$test = 'foo.html.twig'\n" + "$var['foobar'] = $myVar;\n" + "\n" + "/** @var $x \\Symfony\\Component\\Templating\\EngineInterface */\n" + "$x->render($test, $var += ['foobar1' => $myVar]);\n" + "\n" + "}" ); Map<String, PsiVariable> vars = PhpMethodVariableResolveUtil.collectMethodVariables(function); assertContainsElements(vars.keySet(), "foobar"); assertContainsElements(vars.keySet(), "foobar1"); }
Example 9
Source File: PhpMethodVariableResolveUtilTest.java From idea-php-symfony2-plugin with MIT License | 6 votes |
/** * @see PhpMethodVariableResolveUtil#collectMethodVariables */ public void testCollectMethodVariablesForVariableWithInvalidTemplateNameString() { Function function = PhpPsiElementFactory.createFunction(getProject(), "function foobar() {\n" + "$test = 'foo.html'\n" + "$var['foobar'] = $myVar;\n" + "\n" + "/** @var $x \\Symfony\\Component\\Templating\\EngineInterface */\n" + "$x->render($test, $var += ['foobar1' => $myVar]);\n" + "\n" + "}" ); Map<String, PsiVariable> vars = PhpMethodVariableResolveUtil.collectMethodVariables(function); assertFalse(vars.containsKey("foobar")); }