Skip to content

Commit 969e6fa

Browse files
committed
Bleeding edge - require rules to return list<IdentifierRuleError>
1 parent 3e498e1 commit 969e6fa

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

Diff for: conf/bleedingEdge.neon

+2
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,5 @@ parameters:
3939
stricterFunctionMap: true
4040
invalidPhpDocTagLine: true
4141
detectDeadTypeInMultiCatch: true
42+
stubFiles:
43+
- ../stubs/bleedingEdge/Rule.stub

Diff for: phpstan-baseline.neon

+25
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,16 @@ parameters:
440440
count: 1
441441
path: src/Rules/Api/NodeConnectingVisitorAttributesRule.php
442442

443+
-
444+
message: "#^Method PHPStan\\\\Rules\\\\Arrays\\\\AppendedArrayItemTypeRule\\:\\:processNode\\(\\) should return list\\<PHPStan\\\\Rules\\\\IdentifierRuleError\\> but returns array\\{PHPStan\\\\Rules\\\\TipRuleError\\}\\.$#"
445+
count: 1
446+
path: src/Rules/Arrays/AppendedArrayItemTypeRule.php
447+
448+
-
449+
message: "#^Method PHPStan\\\\Rules\\\\Arrays\\\\AppendedArrayKeyTypeRule\\:\\:processNode\\(\\) should return list\\<PHPStan\\\\Rules\\\\IdentifierRuleError\\> but returns array\\{PHPStan\\\\Rules\\\\RuleError\\}\\.$#"
450+
count: 1
451+
path: src/Rules/Arrays/AppendedArrayKeyTypeRule.php
452+
443453
-
444454
message: "#^Doing instanceof PHPStan\\\\Type\\\\ConstantScalarType is error\\-prone and deprecated\\. Use Type\\:\\:isConstantScalarValue\\(\\) or Type\\:\\:getConstantScalarTypes\\(\\) or Type\\:\\:getConstantScalarValues\\(\\) instead\\.$#"
445455
count: 1
@@ -518,6 +528,11 @@ parameters:
518528
count: 4
519529
path: src/Rules/Comparison/MatchExpressionRule.php
520530

531+
-
532+
message: "#^Method PHPStan\\\\Rules\\\\Comparison\\\\MatchExpressionRule\\:\\:processNode\\(\\) should return list\\<PHPStan\\\\Rules\\\\IdentifierRuleError\\> but returns list\\<PHPStan\\\\Rules\\\\IdentifierRuleError\\|PHPStan\\\\Rules\\\\LineRuleError\\>\\.$#"
533+
count: 1
534+
path: src/Rules/Comparison/MatchExpressionRule.php
535+
521536
-
522537
message: "#^Doing instanceof PHPStan\\\\Type\\\\Constant\\\\ConstantBooleanType is error\\-prone and deprecated\\. Use Type\\:\\:isTrue\\(\\) or Type\\:\\:isFalse\\(\\) instead\\.$#"
523538
count: 2
@@ -538,11 +553,21 @@ parameters:
538553
count: 1
539554
path: src/Rules/Comparison/UnreachableIfBranchesRule.php
540555

556+
-
557+
message: "#^Method PHPStan\\\\Rules\\\\Comparison\\\\UnreachableIfBranchesRule\\:\\:processNode\\(\\) should return list\\<PHPStan\\\\Rules\\\\IdentifierRuleError\\> but returns list\\<PHPStan\\\\Rules\\\\RuleError\\>\\.$#"
558+
count: 1
559+
path: src/Rules/Comparison/UnreachableIfBranchesRule.php
560+
541561
-
542562
message: "#^Doing instanceof PHPStan\\\\Type\\\\Constant\\\\ConstantBooleanType is error\\-prone and deprecated\\. Use Type\\:\\:isTrue\\(\\) or Type\\:\\:isFalse\\(\\) instead\\.$#"
543563
count: 1
544564
path: src/Rules/Comparison/UnreachableTernaryElseBranchRule.php
545565

566+
-
567+
message: "#^Method PHPStan\\\\Rules\\\\Comparison\\\\UnreachableTernaryElseBranchRule\\:\\:processNode\\(\\) should return list\\<PHPStan\\\\Rules\\\\IdentifierRuleError\\> but returns array\\{PHPStan\\\\Rules\\\\LineRuleError\\}\\.$#"
568+
count: 1
569+
path: src/Rules/Comparison/UnreachableTernaryElseBranchRule.php
570+
546571
-
547572
message: "#^Doing instanceof PHPStan\\\\Type\\\\Constant\\\\ConstantBooleanType is error\\-prone and deprecated\\. Use Type\\:\\:isTrue\\(\\) or Type\\:\\:isFalse\\(\\) instead\\.$#"
548573
count: 1

Diff for: stubs/bleedingEdge/Rule.stub

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace PHPStan\Rules;
4+
5+
use PhpParser\Node;
6+
use PHPStan\Analyser\Scope;
7+
8+
/**
9+
* @api
10+
* @phpstan-template TNodeType of Node
11+
*/
12+
interface Rule
13+
{
14+
15+
/**
16+
* @phpstan-return class-string<TNodeType>
17+
*/
18+
public function getNodeType(): string;
19+
20+
/**
21+
* @phpstan-param TNodeType $node
22+
* @return list<IdentifierRuleError>
23+
*/
24+
public function processNode(Node $node, Scope $scope): array;
25+
26+
}

0 commit comments

Comments
 (0)