diff --git a/src/Tests/Tests/epv_test_validate_php_functions.php b/src/Tests/Tests/epv_test_validate_php_functions.php index 1bc0913..52aaf29 100644 --- a/src/Tests/Tests/epv_test_validate_php_functions.php +++ b/src/Tests/Tests/epv_test_validate_php_functions.php @@ -399,11 +399,8 @@ private function validateMethodCalls(Node $node) { } else if (isset($node->expr) && $node->expr instanceof Node\Expr\MethodCall - && !($node->expr->name instanceof Variable - || $node->expr->name instanceof PropertyFetch - || $node->expr->name instanceof Concat - || $node->expr->name instanceof Node\Scalar\Encapsed - || $node->expr->name instanceof Node\Expr\Ternary + && ($node->expr->name instanceof Node\Identifier + || $node->expr->name instanceof Node\Name ) ) { diff --git a/tests/epv_test_validate_php_functions_test.php b/tests/epv_test_validate_php_functions_test.php index fe37ade..8fa9f4a 100644 --- a/tests/epv_test_validate_php_functions_test.php +++ b/tests/epv_test_validate_php_functions_test.php @@ -171,6 +171,18 @@ public function test_usage_variable() { $tester->validateFile($file); } + public function test_usage_dynamic_method_name_in_assignment() { + $output = $this->getOutputMock(); + $output->expects(self::exactly(0)) + ->method('addMessage') + ; + + $file = $this->getLoader()->loadFile('tests/testFiles/dynamic_method_call.php'); + + $tester = new epv_test_validate_php_functions(false, $output, '/a/b/', 'epv/test', false, '/a/'); + $tester->validateFile($file); + } + private function getLoader() { return new FileLoader(new Output(), false, '.', '.'); diff --git a/tests/testFiles/dynamic_method_call.php b/tests/testFiles/dynamic_method_call.php new file mode 100644 index 0000000..c70e366 --- /dev/null +++ b/tests/testFiles/dynamic_method_call.php @@ -0,0 +1,17 @@ +store->{$methods[$step]}(self::DELETE_STEP); + $other = $this->store->{$methods['a']}(); + $named = $this->store->delete_step(); + return $removed; + } +}