-
-
Notifications
You must be signed in to change notification settings - Fork 861
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integration test for parent/previous/next node attributes
- Loading branch information
1 parent
d77a607
commit b60c8fb
Showing
5 changed files
with
71 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace NodeConnectingRule; | ||
|
||
use PhpParser\Node; | ||
use PhpParser\Node\Stmt\Echo_; | ||
use PHPStan\Analyser\Scope; | ||
|
||
/** @implements \PHPStan\Rules\Rule<Echo_> */ | ||
class Rule implements \PHPStan\Rules\Rule | ||
{ | ||
|
||
public function getNodeType(): string | ||
{ | ||
return Echo_::class; | ||
} | ||
|
||
public function processNode(Node $node, Scope $scope): array | ||
{ | ||
return [ | ||
sprintf( | ||
'Parent: %s, previous: %s, next: %s', | ||
get_class($node->getAttribute('parent')), | ||
get_class($node->getAttribute('previous')), | ||
get_class($node->getAttribute('next')) | ||
), | ||
]; | ||
} | ||
|
||
|
||
} |
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,7 @@ | ||
parameters: | ||
ignoreErrors: | ||
- | ||
message: "#^Parent\\: PhpParser\\\\Node\\\\Stmt\\\\ClassMethod, previous\\: PhpParser\\\\Node\\\\Stmt\\\\If_, next\\: PhpParser\\\\Node\\\\Stmt\\\\Do_$#" | ||
count: 1 | ||
path: src/test.php | ||
|
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,11 @@ | ||
includes: | ||
- phar://phpstan.phar/conf/bleedingEdge.neon | ||
- baseline.neon | ||
|
||
parameters: | ||
paths: | ||
- src | ||
level: 8 | ||
|
||
rules: | ||
- NodeConnectingRule\Rule |
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,19 @@ | ||
<?php | ||
|
||
namespace NodeConnecting; | ||
|
||
class Foo | ||
{ | ||
|
||
public function doFoo(bool $b): void | ||
{ | ||
if ($b) { | ||
|
||
} | ||
echo 'bar'; | ||
do { | ||
break; | ||
} while ($b); | ||
} | ||
|
||
} |