Skip to content

Commit fd647cf

Browse files
Add compatibility with phpstan 0.12.25 (#122)
1 parent 2b2ae37 commit fd647cf

File tree

5 files changed

+17
-18
lines changed

5 files changed

+17
-18
lines changed

composer.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,13 @@
1919
"require": {
2020
"php": "^7.1",
2121
"nikic/php-parser": "^4.4",
22-
"phpstan/phpstan": "^0.12.18"
22+
"phpstan/phpstan": "^0.12.25"
2323
},
2424
"require-dev": {
2525
"nette/utils": "^3.0",
2626
"php-coveralls/php-coveralls": "^2.1",
2727
"php-parallel-lint/php-console-highlighter": "^0.4.0",
2828
"php-parallel-lint/php-parallel-lint": "^1.2.0",
29-
"phpstan/phpstan": "^0.12.18",
3029
"phpstan/phpstan-nette": "^0.12.0",
3130
"phpstan/phpstan-phpunit": "^0.12.0",
3231
"phpstan/phpstan-strict-rules": "^0.12.0",

phpstan.neon.dist

-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ parameters:
1212
excludes_analyse:
1313
- %rootDir%/../../../tests/*/data/*
1414

15-
ignoreErrors:
16-
- "#^Method Pepakriz\\\\PHPStanExceptionRules\\\\RuleTestCase\\:\\:getRule\\(\\) return type with generic interface PHPStan\\\\Rules\\\\Rule does not specify its types\\: TNodeType$#"
17-
1815
exceptionRules:
1916
reportUnusedCatchesOfUncheckedExceptions: true
2017
uncheckedExceptions:

src/Rules/DeadCatchUnionRule.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ public function getNodeType(): string
3737
*/
3838
public function processNode(Node $node, Scope $scope): array
3939
{
40-
if (!$node instanceof Catch_) {
41-
return [];
42-
}
40+
/** @var Catch_ $node */
41+
$node = $node;
4342

4443
if (count($node->types) <= 1) {
4544
return [];

src/Rules/ThrowsPhpDocInheritanceRule.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,8 @@ public function getNodeType(): string
7575
*/
7676
public function processNode(Node $node, Scope $scope): array
7777
{
78-
if (!$node instanceof ClassMethod) {
79-
return [];
80-
}
78+
/** @var ClassMethod $node */
79+
$node = $node;
8180

8281
$classReflection = $scope->getClassReflection();
8382
if ($classReflection === null) {

tests/src/RuleTestCase.php

+12-7
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use PHPStan\Dependency\DependencyResolver;
1717
use PHPStan\File\FileHelper;
1818
use PHPStan\File\SimpleRelativePathHelper;
19+
use PHPStan\PhpDoc\PhpDocInheritanceResolver;
1920
use PHPStan\PhpDoc\PhpDocNodeResolver;
2021
use PHPStan\PhpDoc\PhpDocStringResolver;
2122
use PHPStan\PhpDoc\TypeNodeResolverExtension;
@@ -88,16 +89,20 @@ private function getAnalyser(): Analyser
8889
$this->getStaticMethodTypeSpecifyingExtensions()
8990
);
9091

92+
$fileTypeMapper = new FileTypeMapper(
93+
$this->getParser(),
94+
self::getContainer()->getByType(PhpDocStringResolver::class),
95+
self::getContainer()->getByType(PhpDocNodeResolver::class),
96+
$this->createMock(Cache::class),
97+
$anonymousClassNameHelper
98+
);
99+
$phpDocInheritanceResolver = new PhpDocInheritanceResolver($fileTypeMapper);
100+
91101
$nodeScopeResolver = new NodeScopeResolver(
92102
$broker,
93103
$this->getParser(),
94-
new FileTypeMapper(
95-
$this->getParser(),
96-
self::getContainer()->getByType(PhpDocStringResolver::class),
97-
self::getContainer()->getByType(PhpDocNodeResolver::class),
98-
$this->createMock(Cache::class),
99-
$anonymousClassNameHelper
100-
),
104+
$fileTypeMapper,
105+
$phpDocInheritanceResolver,
101106
$fileHelper,
102107
$typeSpecifier,
103108
$this->shouldPolluteScopeWithLoopInitialAssignments(),

0 commit comments

Comments
 (0)