Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
patinthehat committed Jul 5, 2021
1 parent f07cfb9 commit fd7c3f9
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 18 deletions.
2 changes: 2 additions & 0 deletions src/Searcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: my_test_func
startLine: 1
endLine: 3
column: 0
endLine: 3
startLine: 1
Original file line number Diff line number Diff line change
@@ -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' }
2 changes: 1 addition & 1 deletion tests/SearcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function it_finds_methods()
->methods(['methodOne'])
->searchCode('<?' . "php \n\$myVar = \$obj->methodOne('one'); \$obj->methodTwo('two');\n");

$this->assertCount(1, $results->results);
$this->assertCount(2, $results->results);
$this->assertEquals('methodOne', $results->results[0]->location->name);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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: '<?php', 2: '$myVar = strtolower(''test'');' } }
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
-
location: { name: MyClass, startLine: 13, endLine: 13, column: 0 }
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();' } }
Original file line number Diff line number Diff line change
@@ -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: '<?php', 2: ' ray(''12345'');', 3: '', 4: ' printf("%s\n", strtolower(''TEST''));', 5: '', 6: ' echo strtoupper(''test'') . PHP_EOL;', 7: '', 8: ' function test1()' } }
-
location: { name: strtoupper, startLine: 6, endLine: 6, column: 0 }
location: { name: strtoupper, column: 0, endLine: 6, startLine: 6 }
snippet: { code: { 2: ' ray(''12345'');', 3: '', 4: ' printf("%s\n", strtolower(''TEST''));', 5: '', 6: ' echo strtoupper(''test'') . PHP_EOL;', 7: '', 8: ' function test1()', 9: ' {' } }
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
-
location: { name: printf, startLine: 4, endLine: 4, column: 0 }
location: { name: printf, column: 0, endLine: 4, startLine: 4 }
snippet: { code: { 1: '<?php', 2: ' ray(''12345'');', 3: '', 4: ' printf("%s\n", strtolower(''TEST''));', 5: '', 6: ' echo strtoupper(''test'') . PHP_EOL;', 7: '', 8: ' function test1()' } }
-
location: { name: strtolower, startLine: 4, endLine: 4, column: 0 }
location: { name: strtolower, column: 0, endLine: 4, startLine: 4 }
snippet: { code: { 1: '<?php', 2: ' ray(''12345'');', 3: '', 4: ' printf("%s\n", strtolower(''TEST''));', 5: '', 6: ' echo strtoupper(''test'') . PHP_EOL;', 7: '', 8: ' function test1()' } }
-
location: { name: strtolower, startLine: 4, endLine: 4, column: 0 }
location: { name: strtolower, column: 0, endLine: 4, startLine: 4 }
snippet: { code: { 1: '<?php', 2: ' ray(''12345'');', 3: '', 4: ' printf("%s\n", strtolower(''TEST''));', 5: '', 6: ' echo strtoupper(''test'') . PHP_EOL;', 7: '', 8: ' function test1()' } }
-
location: { name: strtoupper, startLine: 6, endLine: 6, column: 0 }
location: { name: strtoupper, column: 0, endLine: 6, startLine: 6 }
snippet: { code: { 2: ' ray(''12345'');', 3: '', 4: ' printf("%s\n", strtolower(''TEST''));', 5: '', 6: ' echo strtoupper(''test'') . PHP_EOL;', 7: '', 8: ' function test1()', 9: ' {' } }
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-
location: { name: strtolower, startLine: 4, endLine: 4, column: 0 }
location: { name: strtolower, column: 0, endLine: 4, startLine: 4 }
snippet: null
-
location: { name: strtoupper, startLine: 6, endLine: 6, column: 0 }
location: { name: strtoupper, column: 0, endLine: 6, startLine: 6 }
snippet: null
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
-
location: { name: Ray, startLine: 10, endLine: 10, column: 0 }
location: { name: Ray, column: 0, endLine: 10, startLine: 10 }
snippet: { code: { 6: ' echo strtoupper(''test'') . PHP_EOL;', 7: '', 8: ' function test1()', 9: ' {', 10: ' Ray::rateLimiter()->count(5);', 11: ' }', 12: '', 13: ' $obj = new MyClass();' } }
Original file line number Diff line number Diff line change
@@ -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();' } }

0 comments on commit fd7c3f9

Please sign in to comment.