Skip to content

Commit db78595

Browse files
authored
[phpstan] fix next ingored errors (#6572)
1 parent 7e6353d commit db78595

File tree

9 files changed

+12
-20
lines changed

9 files changed

+12
-20
lines changed

bin/rector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function loadIfExistsAndNotLoadedYet(string $filePath): void
105105
return;
106106
}
107107

108-
/** @var string $realPath always string after file_exists() check */
108+
/** @var non-empty-string $realPath always string after file_exists() check */
109109
$realPath = realpath($filePath);
110110
$this->alreadyLoadedAutoloadFiles[] = $realPath;
111111

phpstan.neon

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,6 @@ parameters:
6969
-
7070
identifier: phpstanApi.constructor
7171

72-
# enforce native type
73-
-
74-
identifier: varTag.nativeType
75-
7672
# on runtime check
7773
-
7874
identifier: deadCode.unreachable
@@ -83,9 +79,6 @@ parameters:
8379
-
8480
identifier: argument.type
8581

86-
# -
87-
# identifier: phpstanApi.varTagAssumption
88-
8982
# is nested expr
9083
-
9184
message: '#Access to an undefined property PhpParser\\Node\\Expr\:\:\$expr#'
@@ -315,3 +308,12 @@ parameters:
315308
-
316309
path: src/NodeTypeResolver/PHPStan/Type/TypeFactory.php
317310
message: '#Method Rector\\NodeTypeResolver\\PHPStan\\Type\\TypeFactory\:\:uniquateTypes\(\) should return array<TType of PHPStan\\Type\\Type> but returns list<PHPStan\\Type\\Type>#'
311+
312+
# known types
313+
-
314+
message: '#PHPDoc tag @var with type array<string, int> is not subtype of native type array<int<1, max>>#'
315+
path: rules/Naming/PhpArray/ArrayFilter.php
316+
317+
-
318+
message: '#PHPDoc tag @var with type int is not subtype of native type array\|PHPStan\\PhpDocParser\\Ast\\ConstExpr\\ConstExprNode\|Rector\\BetterPhpDocParser\\PhpDoc\\DoctrineAnnotationTagValueNode\|Rector\\BetterPhpDocParser\\PhpDoc\\StringNode\|Rector\\BetterPhpDocParser\\ValueObject\\PhpDoc\\DoctrineAnnotation\\CurlyListNode\|string#'
319+
path: src/BetterPhpDocParser/PhpDocParser/StaticDoctrineAnnotationParser.php

rules/TypeDeclaration/TypeInferer/ReturnTypeInferer.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,5 @@ public function inferFunctionLike(ClassMethod|Function_|Closure $functionLike):
2929
}
3030

3131
return $originalType;
32-
// return $this->typeNormalizer->normalizeArrayTypeAndArrayNever($originalType);
3332
}
3433
}

src/Autoloading/BootstrapFilesIncluder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ private function requireRectorStubs(): void
4848

4949
$dir = new RecursiveDirectoryIterator($stubsRectorDirectory, RecursiveDirectoryIterator::SKIP_DOTS);
5050

51-
/** @var SplFileInfo[] $stubs */
5251
$stubs = new RecursiveIteratorIterator($dir);
5352

5453
foreach ($stubs as $stub) {
54+
/** @var SplFileInfo $stub */
5555
require_once $stub->getRealPath();
5656
}
5757
}

src/Caching/Detector/ChangedFilesDetector.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,7 @@ public function setFirstResolvedConfigFileInfo(string $filePath): void
8585

8686
private function resolvePath(string $filePath): string
8787
{
88-
/** @var string|false $realPath */
8988
$realPath = realpath($filePath);
90-
9189
if ($realPath === false) {
9290
return $filePath;
9391
}

src/PHPStanStaticTypeMapper/TypeMapper/ArrayTypeMapper.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace Rector\PHPStanStaticTypeMapper\TypeMapper;
66

77
use PhpParser\Node\Identifier;
8-
use PHPStan\PhpDocParser\Ast\Node;
98
use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode;
109
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
1110
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
@@ -178,7 +177,7 @@ private function createGenericArrayType(ArrayType $arrayType, bool $withKey = fa
178177
// @see https://github.com/phpstan/phpdoc-parser/blob/98a088b17966bdf6ee25c8a4b634df313d8aa531/tests/PHPStan/Parser/PhpDocParserTest.php#L2692-L2696
179178

180179
foreach ($genericTypes as $genericType) {
181-
/** @var Node $genericType */
180+
/** @var TypeNode $genericType */
182181
$genericType->setAttribute(self::HAS_GENERIC_TYPE_PARENT, $withKey);
183182
}
184183

src/Skipper/FileSystem/FnMatchPathNormalizer.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ public function normalizeForFnmatch(string $path): string
1616
}
1717

1818
if (\str_contains($path, '..')) {
19-
/** @var string|false $realPath */
2019
$realPath = realpath($path);
2120
if ($realPath === false) {
2221
return '';

src/Skipper/RealpathMatcher.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@ final class RealpathMatcher
1010
{
1111
public function match(string $matchingPath, string $filePath): bool
1212
{
13-
/** @var string|false $realPathMatchingPath */
1413
$realPathMatchingPath = realpath($matchingPath);
1514
if ($realPathMatchingPath === false) {
1615
return false;
1716
}
1817

19-
/** @var string|false $realpathFilePath */
2018
$realpathFilePath = realpath($filePath);
2119
if ($realpathFilePath === false) {
2220
return false;

tests/NodeTypeResolver/StaticTypeMapper/StaticTypeMapperTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use PhpParser\Node;
99
use PhpParser\Node\Identifier;
1010
use PhpParser\Node\Scalar\String_;
11-
use PHPStan\PhpDocParser\Ast\Type\ArrayTypeNode;
1211
use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode;
1312
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
1413
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
@@ -63,8 +62,6 @@ public function testMapPHPStanTypeToPHPStanPhpDocTypeNode(): void
6362

6463
$phpStanDocTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($iterableType);
6564
$this->assertInstanceOf(GenericTypeNode::class, $phpStanDocTypeNode);
66-
67-
/** @var ArrayTypeNode $phpStanDocTypeNode */
6865
$this->assertInstanceOf(IdentifierTypeNode::class, $phpStanDocTypeNode->type);
6966
}
7067

0 commit comments

Comments
 (0)