Skip to content

Commit

Permalink
Bleeding edge - require rules to return list<IdentifierRuleError>
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed May 20, 2023
1 parent 3e498e1 commit 969e6fa
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
2 changes: 2 additions & 0 deletions conf/bleedingEdge.neon
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ parameters:
stricterFunctionMap: true
invalidPhpDocTagLine: true
detectDeadTypeInMultiCatch: true
stubFiles:
- ../stubs/bleedingEdge/Rule.stub
25 changes: 25 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,16 @@ parameters:
count: 1
path: src/Rules/Api/NodeConnectingVisitorAttributesRule.php

-
message: "#^Method PHPStan\\\\Rules\\\\Arrays\\\\AppendedArrayItemTypeRule\\:\\:processNode\\(\\) should return list\\<PHPStan\\\\Rules\\\\IdentifierRuleError\\> but returns array\\{PHPStan\\\\Rules\\\\TipRuleError\\}\\.$#"
count: 1
path: src/Rules/Arrays/AppendedArrayItemTypeRule.php

-
message: "#^Method PHPStan\\\\Rules\\\\Arrays\\\\AppendedArrayKeyTypeRule\\:\\:processNode\\(\\) should return list\\<PHPStan\\\\Rules\\\\IdentifierRuleError\\> but returns array\\{PHPStan\\\\Rules\\\\RuleError\\}\\.$#"
count: 1
path: src/Rules/Arrays/AppendedArrayKeyTypeRule.php

-
message: "#^Doing instanceof PHPStan\\\\Type\\\\ConstantScalarType is error\\-prone and deprecated\\. Use Type\\:\\:isConstantScalarValue\\(\\) or Type\\:\\:getConstantScalarTypes\\(\\) or Type\\:\\:getConstantScalarValues\\(\\) instead\\.$#"
count: 1
Expand Down Expand Up @@ -518,6 +528,11 @@ parameters:
count: 4
path: src/Rules/Comparison/MatchExpressionRule.php

-
message: "#^Method PHPStan\\\\Rules\\\\Comparison\\\\MatchExpressionRule\\:\\:processNode\\(\\) should return list\\<PHPStan\\\\Rules\\\\IdentifierRuleError\\> but returns list\\<PHPStan\\\\Rules\\\\IdentifierRuleError\\|PHPStan\\\\Rules\\\\LineRuleError\\>\\.$#"
count: 1
path: src/Rules/Comparison/MatchExpressionRule.php

-
message: "#^Doing instanceof PHPStan\\\\Type\\\\Constant\\\\ConstantBooleanType is error\\-prone and deprecated\\. Use Type\\:\\:isTrue\\(\\) or Type\\:\\:isFalse\\(\\) instead\\.$#"
count: 2
Expand All @@ -538,11 +553,21 @@ parameters:
count: 1
path: src/Rules/Comparison/UnreachableIfBranchesRule.php

-
message: "#^Method PHPStan\\\\Rules\\\\Comparison\\\\UnreachableIfBranchesRule\\:\\:processNode\\(\\) should return list\\<PHPStan\\\\Rules\\\\IdentifierRuleError\\> but returns list\\<PHPStan\\\\Rules\\\\RuleError\\>\\.$#"
count: 1
path: src/Rules/Comparison/UnreachableIfBranchesRule.php

-
message: "#^Doing instanceof PHPStan\\\\Type\\\\Constant\\\\ConstantBooleanType is error\\-prone and deprecated\\. Use Type\\:\\:isTrue\\(\\) or Type\\:\\:isFalse\\(\\) instead\\.$#"
count: 1
path: src/Rules/Comparison/UnreachableTernaryElseBranchRule.php

-
message: "#^Method PHPStan\\\\Rules\\\\Comparison\\\\UnreachableTernaryElseBranchRule\\:\\:processNode\\(\\) should return list\\<PHPStan\\\\Rules\\\\IdentifierRuleError\\> but returns array\\{PHPStan\\\\Rules\\\\LineRuleError\\}\\.$#"
count: 1
path: src/Rules/Comparison/UnreachableTernaryElseBranchRule.php

-
message: "#^Doing instanceof PHPStan\\\\Type\\\\Constant\\\\ConstantBooleanType is error\\-prone and deprecated\\. Use Type\\:\\:isTrue\\(\\) or Type\\:\\:isFalse\\(\\) instead\\.$#"
count: 1
Expand Down
26 changes: 26 additions & 0 deletions stubs/bleedingEdge/Rule.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php declare(strict_types = 1);

namespace PHPStan\Rules;

use PhpParser\Node;
use PHPStan\Analyser\Scope;

/**
* @api
* @phpstan-template TNodeType of Node
*/
interface Rule
{

/**
* @phpstan-return class-string<TNodeType>
*/
public function getNodeType(): string;

/**
* @phpstan-param TNodeType $node
* @return list<IdentifierRuleError>
*/
public function processNode(Node $node, Scope $scope): array;

}

0 comments on commit 969e6fa

Please sign in to comment.