Skip to content

Commit

Permalink
Merge pull request #49 from paul999/test_for_concat
Browse files Browse the repository at this point in the history
Test for concat
  • Loading branch information
iMattPro authored Aug 4, 2016
2 parents cb9db0e + 626efec commit 219151f
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/Tests/Tests/epv_test_validate_php_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
use PHPParser_Error;
use PHPParser_Lexer_Emulative;
use PHPParser_Node;
use PHPParser_Node_Expr_Concat;
use PHPParser_Node_Expr_Exit;
use PHPParser_Node_Expr_FuncCall;
use PHPParser_Node_Expr_Print;
use PHPParser_Node_Expr_Variable;
use PHPParser_Node_Scalar_String;
use PHPParser_Node_Stmt_Class;
use PHPParser_Node_Stmt_Echo;
use PHPParser_Node_Stmt_If;
Expand Down Expand Up @@ -358,6 +360,16 @@ private function validateFunctionNames(PHPParser_Node $node)
// If function name is a variable.
$name = (string)$node->name->name;
}
else if ($node->name instanceof PHPParser_Node_Expr_Concat)
{
// Only test if both are a string
// This mean that if a user works around this test he can do so, but otherwise we will
// need to parse variables and stuff.
if ($node->left instanceof PHPParser_Node_Scalar_String && $node->right instanceof PHPParser_Node_Scalar_String)
{
$name = $node->left->value . $node->right->value;
}
}
else
{
$name = (string)$node->name;
Expand Down Expand Up @@ -389,6 +401,16 @@ private function validateMethodCalls(PHPParser_Node $node) {
// If function name is a variable.
$name = (string)$node->name->name;
}
else if ($node->name instanceof PHPParser_Node_Expr_Concat)
{
// Only test if both are a string
// This mean that if a user works around this test he can do so, but otherwise we will
// need to parse variables and stuff.
if ($node->left instanceof PHPParser_Node_Scalar_String && $node->right instanceof PHPParser_Node_Scalar_String)
{
$name = $node->left->value . $node->right->value;
}
}
else
{
$name = (string)$node->name;
Expand Down

0 comments on commit 219151f

Please sign in to comment.