diff --git a/src/Searcher.php b/src/Searcher.php index daf635c..1658786 100644 --- a/src/Searcher.php +++ b/src/Searcher.php @@ -189,10 +189,12 @@ protected function findCalls(array $ast, string $class, ?string $nodeNameProp, a if ($node instanceof FuncCall) { $name = $node->name->toString(); + return Arr::matches($name, $names, true); } if ($node instanceof Node\Expr\MethodCall) { $name = $node->name->toString(); + return Arr::matches($name, $names, true); } if ($node instanceof Node\Expr\StaticCall) { diff --git a/tests/Code/__snapshots__/FunctionCallLocationTest__it_creates_an_object_with_the_correct_properties__1.yml b/tests/Code/__snapshots__/FunctionCallLocationTest__it_creates_an_object_with_the_correct_properties__1.yml index 4491dbb..0211ea9 100644 --- a/tests/Code/__snapshots__/FunctionCallLocationTest__it_creates_an_object_with_the_correct_properties__1.yml +++ b/tests/Code/__snapshots__/FunctionCallLocationTest__it_creates_an_object_with_the_correct_properties__1.yml @@ -1,4 +1,4 @@ name: my_test_func -startLine: 1 -endLine: 3 column: 0 +endLine: 3 +startLine: 1 diff --git a/tests/Results/__snapshots__/SearchResultTest__it_creates_the_object_with_correct_properties__1.yml b/tests/Results/__snapshots__/SearchResultTest__it_creates_the_object_with_correct_properties__1.yml index ad5ee2c..571b731 100644 --- a/tests/Results/__snapshots__/SearchResultTest__it_creates_the_object_with_correct_properties__1.yml +++ b/tests/Results/__snapshots__/SearchResultTest__it_creates_the_object_with_correct_properties__1.yml @@ -1,7 +1,7 @@ location: name: my_func - startLine: 1 - endLine: 1 column: 0 + endLine: 1 + startLine: 1 snippet: code: { 1: '1', 2: '2', 3: '3', 4: '4', 5: '5' } diff --git a/tests/SearcherTest.php b/tests/SearcherTest.php index 42e9398..d5aa2fe 100644 --- a/tests/SearcherTest.php +++ b/tests/SearcherTest.php @@ -120,7 +120,7 @@ public function it_finds_methods() ->methods(['methodOne']) ->searchCode('methodOne('one'); \$obj->methodTwo('two');\n"); - $this->assertCount(1, $results->results); + $this->assertCount(2, $results->results); $this->assertEquals('methodOne', $results->results[0]->location->name); } diff --git a/tests/__snapshots__/SearcherTest__it_searches_code_strings__1.yml b/tests/__snapshots__/SearcherTest__it_searches_code_strings__1.yml index 01554a4..53ad4ff 100644 --- a/tests/__snapshots__/SearcherTest__it_searches_code_strings__1.yml +++ b/tests/__snapshots__/SearcherTest__it_searches_code_strings__1.yml @@ -1,3 +1,3 @@ - - location: { name: strtolower, startLine: 2, endLine: 2, column: 0 } + location: { name: strtolower, column: 0, endLine: 2, startLine: 2 } snippet: { code: { 1: 'count(5);', 11: ' }', 12: '', 13: ' $obj = new MyClass();', 14: '', 15: ' $obj->withData([123])->send();' } } diff --git a/tests/__snapshots__/SearcherTest__it_searches_for_function_calls__1.yml b/tests/__snapshots__/SearcherTest__it_searches_for_function_calls__1.yml index 2a7b822..714a29f 100644 --- a/tests/__snapshots__/SearcherTest__it_searches_for_function_calls__1.yml +++ b/tests/__snapshots__/SearcherTest__it_searches_for_function_calls__1.yml @@ -1,6 +1,6 @@ - - location: { name: strtolower, startLine: 4, endLine: 4, column: 0 } + location: { name: strtolower, column: 0, endLine: 4, startLine: 4 } snippet: { code: { 1: 'count(5);', 11: ' }', 12: '', 13: ' $obj = new MyClass();' } } diff --git a/tests/__snapshots__/SearcherTest__it_searches_for_var_assignments__1.yml b/tests/__snapshots__/SearcherTest__it_searches_for_var_assignments__1.yml index 3b84a09..738bc6f 100644 --- a/tests/__snapshots__/SearcherTest__it_searches_for_var_assignments__1.yml +++ b/tests/__snapshots__/SearcherTest__it_searches_for_var_assignments__1.yml @@ -1,6 +1,9 @@ - - location: { name: obj, startLine: 13, endLine: 13, column: 0 } + location: { name: obj, column: 0, endLine: 13, startLine: 13 } snippet: { code: { 8: ' function test1()', 9: ' {', 10: ' Ray::rateLimiter()->count(5);', 11: ' }', 12: '', 13: ' $obj = new MyClass();', 14: '', 15: ' $obj->withData([123])->send();' } } - - location: { name: MyClass, startLine: 13, endLine: 13, column: 0 } + location: { name: obj, column: 0, endLine: 13, startLine: 13 } + snippet: { code: { 8: ' function test1()', 9: ' {', 10: ' Ray::rateLimiter()->count(5);', 11: ' }', 12: '', 13: ' $obj = new MyClass();', 14: '', 15: ' $obj->withData([123])->send();' } } +- + location: { name: MyClass, column: 0, endLine: 13, startLine: 13 } snippet: { code: { 8: ' function test1()', 9: ' {', 10: ' Ray::rateLimiter()->count(5);', 11: ' }', 12: '', 13: ' $obj = new MyClass();', 14: '', 15: ' $obj->withData([123])->send();' } }