-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from permafrost-dev/add-result-nodes
Add Result Nodes
- Loading branch information
Showing
19 changed files
with
162 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace Permafrost\PhpCodeSearch\Results\Nodes; | ||
|
||
class FunctionCallNode implements ResultNode | ||
{ | ||
/** @var string */ | ||
public $name; | ||
|
||
public function __construct(string $name) | ||
{ | ||
$this->name = $name; | ||
} | ||
|
||
public static function create(string $name): self | ||
{ | ||
return new static(...func_get_args()); | ||
} | ||
|
||
public function name(): string | ||
{ | ||
return $this->name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace Permafrost\PhpCodeSearch\Results\Nodes; | ||
|
||
interface ResultNode | ||
{ | ||
public function name(): string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace Permafrost\PhpCodeSearch\Results\Nodes; | ||
|
||
class StaticMethodCallNode implements ResultNode | ||
{ | ||
/** @var string */ | ||
public $className; | ||
|
||
/** @var string */ | ||
public $methodName; | ||
|
||
/** @var string */ | ||
public $name; | ||
|
||
public function __construct(string $className, string $methodName) | ||
{ | ||
$this->className = $className; | ||
$this->methodName = $methodName; | ||
$this->name = $this->name(); | ||
} | ||
|
||
public static function create(string $className, string $methodName): self | ||
{ | ||
return new static(...func_get_args()); | ||
} | ||
|
||
public function name(): string | ||
{ | ||
return "{$this->className}::{$this->methodName}"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace Permafrost\PhpCodeSearch\Results\Nodes; | ||
|
||
class VariableNode implements ResultNode | ||
{ | ||
/** @var string */ | ||
public $name; | ||
|
||
public function __construct(string $name) | ||
{ | ||
$this->name = $name; | ||
} | ||
|
||
public static function create(string $name): self | ||
{ | ||
return new static(...func_get_args()); | ||
} | ||
|
||
public function name(): string | ||
{ | ||
return $this->name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
tests/__snapshots__/SearcherTest__it_searches_code_strings__1.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
- | ||
location: { name: strtolower, column: 0, endLine: 2, startLine: 2 } | ||
node: { name: strtolower } | ||
snippet: { code: { 1: '<?php', 2: '$myVar = strtolower(''test'');' } } |
1 change: 1 addition & 0 deletions
1
tests/__snapshots__/SearcherTest__it_searches_for_classes_created_by_new__1.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
- | ||
location: { name: MyClass, column: 0, endLine: 13, startLine: 13 } | ||
node: { name: MyClass } | ||
snippet: { code: { 9: ' {', 10: ' Ray::rateLimiter()->count(5);', 11: ' }', 12: '', 13: ' $obj = new MyClass();', 14: '', 15: ' $obj->withData([123])->send();', 16: '' } } |
2 changes: 2 additions & 0 deletions
2
tests/__snapshots__/SearcherTest__it_searches_for_function_calls__1.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
- | ||
location: { name: strtolower, column: 0, endLine: 4, startLine: 4 } | ||
node: { name: strtolower } | ||
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, column: 0, endLine: 6, startLine: 6 } | ||
node: { name: strtoupper } | ||
snippet: { code: { 2: ' ray(''12345'');', 3: '', 4: ' printf("%s\n", strtolower(''TEST''));', 5: '', 6: ' echo strtoupper(''test'') . PHP_EOL;', 7: '', 8: ' function test1()', 9: ' {' } } |
Oops, something went wrong.