Skip to content

Commit 368bffa

Browse files
committed
Fix phpstan errors
1 parent f91db3b commit 368bffa

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

phpstan-baseline.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18793,11 +18793,5 @@
1879318793
'count' => 1,
1879418794
'path' => __DIR__ . '/tests/system/View/ViewTest.php',
1879518795
];
18796-
$ignoreErrors[] = [
18797-
// identifier: method.childParameterType
18798-
'message' => '#^Parameter \\#1 \\$node \\(PhpParser\\\\Node\\\\Stmt\\) of method Utils\\\\PHPStan\\\\CheckUseStatementsAfterLicenseRule\\:\\:processNode\\(\\) should be contravariant with parameter \\$node \\(PhpParser\\\\Node\\) of method PHPStan\\\\Rules\\\\Rule\\<PhpParser\\\\Node\\>\\:\\:processNode\\(\\)$#',
18799-
'count' => 1,
18800-
'path' => __DIR__ . '/utils/PHPStan/CheckUseStatementsAfterLicenseRule.php',
18801-
];
1880218796

1880318797
return ['parameters' => ['ignoreErrors' => $ignoreErrors]];

phpstan.neon.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ parameters:
1818
- app
1919
- system
2020
- tests
21-
- utils/PHPStan
21+
- utils/src/PHPStan
2222
excludePaths:
2323
- app/Views/errors/cli/*
2424
- app/Views/errors/html/*

utils/PHPStan/CheckUseStatementsAfterLicenseRule.php renamed to utils/src/PHPStan/CheckUseStatementsAfterLicenseRule.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@
1818
use PhpParser\Node\Stmt;
1919
use PhpParser\Node\Stmt\Use_;
2020
use PHPStan\Analyser\Scope;
21+
use PHPStan\Rules\IdentifierRuleError;
2122
use PHPStan\Rules\Rule;
23+
use PHPStan\Rules\RuleErrorBuilder;
2224

25+
/**
26+
* @implements Rule<Node\Stmt>
27+
*/
2328
final class CheckUseStatementsAfterLicenseRule implements Rule
2429
{
2530
private const ERROR_MESSAGE = 'Use statement must be located after license docblock';
@@ -32,6 +37,8 @@ public function getNodeType(): string
3237

3338
/**
3439
* @param Stmt $node
40+
*
41+
* @return list<IdentifierRuleError>
3542
*/
3643
public function processNode(Node $node, Scope $scope): array
3744
{
@@ -54,7 +61,11 @@ public function processNode(Node $node, Scope $scope): array
5461

5562
while ($previous) {
5663
if ($previous instanceof Use_) {
57-
return [self::ERROR_MESSAGE];
64+
return [
65+
RuleErrorBuilder::message(self::ERROR_MESSAGE)
66+
->identifier('codeigniter.useStmtAfterLicense')
67+
->build(),
68+
];
5869
}
5970

6071
$previous = $previous->getAttribute('previous');

0 commit comments

Comments
 (0)