Skip to content

Commit

Permalink
Remove fixed phpstan errors (#6569)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba authored Dec 12, 2024
1 parent 3620443 commit ff49b20
Showing 1 changed file with 6 additions and 83 deletions.
89 changes: 6 additions & 83 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,13 @@ parameters:
identifier: missingType.generics

# phpstan class instance
-
identifier: phpstanApi.class
- identifier: phpstanApi.class

# phpstan class constant value
-
identifier: phpstanApi.classConstant
- identifier: phpstanApi.classConstant

# phpstan instanceof
-
identifier: phpstanApi.instanceofAssumption
- identifier: phpstanApi.instanceofAssumption

# assert phpunit
-
Expand Down Expand Up @@ -106,8 +103,6 @@ parameters:
message: '#Method (.*?) should return (.*?)\|null but returns PhpParser\\Node\|null#'
path: src/PhpParser/Node/BetterNodeFinder.php

- '#Method (.*?) should return array<T of PhpParser\\Node\> but returns array<PhpParser\\Node\>#'

-
message: '#Function "property_exists\(\)" cannot be used/left in the code#'
paths:
Expand All @@ -126,9 +121,6 @@ parameters:
- src/BetterPhpDocParser/PhpDocManipulator/PhpDocClassRenamer.php
- src/NodeTypeResolver/PHPStan/Type/TypeFactory.php

# array_index on generic types
- '#Method Rector\\NodeTypeResolver\\PHPStan\\Type\\TypeFactory\:\:uniquateTypes\(\) should return array<TType of PHPStan\\Type\\Type\> but returns array<int, PHPStan\\Type\\Type\>#'

- '#Method Rector\\Arguments\\ArgumentDefaultValueReplacer\:\:processReplaces\(\) should return \(TCall of PhpParser\\Node\\Expr\\FuncCall\|PhpParser\\Node\\Expr\\MethodCall\|PhpParser\\Node\\Expr\\New_\|PhpParser\\Node\\Expr\\StaticCall\|PhpParser\\Node\\Stmt\\ClassMethod\)\|null but returns PhpParser\\Node\\Stmt\\ClassMethod\|null#'

# native filesystem calls, required for performance reasons
Expand All @@ -137,11 +129,6 @@ parameters:
paths:
- src/Caching/ValueObject/Storage/FileCacheStorage.php

-
message: '#Parameter \#2 \$length of function str_split expects int<1, max\>, int given#'
paths:
- rules/Php74/Rector/LNumber/AddLiteralSeparatorToNumberRector.php

# many internal cases
- '#Calling (.*?) is not covered by backward compatibility promise\. The method might change in a minor PHPStan version#'

Expand All @@ -157,12 +144,6 @@ parameters:
- rules/EarlyReturn/Rector/If_/ChangeNestedIfsToEarlyReturnRector.php
- rules/Php70/EregToPcreTransformer.php

# mapper re-use
- '#Parameter \#1 \$type of method Rector\\PHPStanStaticTypeMapper\\TypeMapper\\ObjectWithoutClassTypeMapper\:\:mapToPhpParserNode\(\) expects PHPStan\\Type\\ObjectWithoutClassType, PHPStan\\Type\\Accessory\\Has(Property|Method)Type given#'

# Scope vs MutatingScope interchangable false positive
- '#Parameter \#3 \$nodeCallback of method PHPStan\\Analyser\\NodeScopeResolver\:\:processNodes\(\) expects callable\(PhpParser\\Node, PHPStan\\Analyser\\Scope\)\: void, (callable|Closure)\(PhpParser\\Node, PHPStan\\Analyser\\MutatingScope\)\: void given#'

# internal reflection
- '#Instead of "new ClassReflection\(\)" use ReflectionProvider service or "\(new PHPStan\\Reflection\\ClassReflection\(<desired_type>\)\)" for static reflection to work#'

Expand Down Expand Up @@ -213,25 +194,11 @@ parameters:
# fixture class
- '#Class "Rector\\Tests\\Issues\\ScopeNotAvailable\\Variable\\ArrayItemForeachValueRector" is missing @see annotation with test case class reference#'

-
message: '#Parameter \#1 \$phpVersion of method Rector\\Config\\RectorConfig\:\:phpVersion\(\) expects 50200\|50300\|50400\|50500\|50600\|70000\|70100\|70200\|70300\|70400\|80000\|80100\|80200\|80300\|80400\|100000, (.*?) given#'
path: rules-tests

-
message: '#Class (.*?) not found#'
paths:
- rules-tests/*/config/*

# trusted items
- '#Parameter \#1 \$nodes of method PhpParser\\PrettyPrinterAbstract\:\:pCommaSeparatedMultiline\(\) expects array<PhpParser\\Node>, array<PhpParser\\Node\\Expr\\ArrayItem\|null> given#'


# class string
- '#Parameter \#1 \$name of method PHPStan\\BetterReflection\\Reflection\\Adapter\\ReflectionClass\:\:getAttributes\(\) expects class\-string\|null, string given#'

# useless
- '#Parameter \#1 \$suffix of method PHPUnit\\Framework\\Assert\:\:assertStringEndsWith\(\) expects non\-empty\-string, string given#'

-
message: '#Function "(function_exists|dump_node)\(\)" cannot be used/left in the code#'
path: src/functions/node_helper.php
Expand All @@ -242,13 +209,6 @@ parameters:
# stmts aware/expression generics
- '#PhpParser\\Node\\Stmt\\Expression is not generic#'

- '#Parameter \#3 \$assign of method Rector\\CodeQuality\\Rector\\FunctionLike\\SimplifyUselessVariableRector\:\:processSimplifyUselessVariable\(\) expects PhpParser\\Node\\Expr\\Assign\|PhpParser\\Node\\Expr\\AssignOp, PhpParser\\Node\\Expr given#'

# false positive
-
message: '#Offset 0 does not exist on array<PhpParser\\Node\\Stmt>\|null#'
path: rules/Php70/Rector/ClassMethod/Php4ConstructorRector.php

# chicken/egg
-
message: '#Function "(d|dd)\(\)" cannot be used/left in the code#'
Expand All @@ -264,11 +224,6 @@ parameters:
message: '#Function "(class_exists|interface_exists)\(\)" cannot be used/left in the code\: use ReflectionProvider\->has\*\(\) instead#'
path: src/Skipper/SkipCriteriaResolver/SkippedClassResolver.php

# ignore until PHPParser returns more precise types
-
message: '#Parameter \#1 \$useType of callable callable\(0\|1\|2\|3, PhpParser\\Node\\Stmt\\UseUse, string\): void expects 0\|1\|2\|3, int given.#'
path: rules/CodingStyle/ClassNameImport/UseImportsTraverser.php

- '#(.*?)\\Contract\\PhpParser\\Node\\StmtsAwareInterface\:\:\$stmts#'

# dev rule
Expand All @@ -277,9 +232,6 @@ parameters:
# optional as changes behavior, should be used explicitly outside PHP upgrade
- '#Register "Rector\\Php73\\Rector\\FuncCall\\JsonThrowOnErrorRector" service to "php73\.php" config set#'

# known enum from strings
- '#Method Rector\\Php\\PolyfillPackagesProvider\:\:filterPolyfillPackages\(\) should return array\<.*\> but returns array<int, non\-falsy\-string>#'

# closure detailed
- '#Method Rector\\Config\\RectorConfig\:\:singleton\(\) has parameter \$concrete with no signature specified for Closure#'

Expand All @@ -295,19 +247,13 @@ parameters:
message: '#Access to an undefined property PhpParser\\Node\\Scalar\:\:\$value#'
path: src/CustomRules/SimpleNodeDumper.php

-
message: '#Offset \(int\|string\) on non\-empty\-array<PHPStan\\PhpDocParser\\Ast\\PhpDoc\\PhpDocChildNode> in isset\(\) always exists and is not nullable#'
path: src/BetterPhpDocParser/PhpDocParser/DoctrineAnnotationDecorator.php

-
message: '#Avoid static access of constants, as they can change value\. Use interface and contract method instead#'
paths:
# caching and message of speicfic child Rector rules
- src/Rector/AbstractRector.php
# for cache
- src/Testing/PHPUnit/AbstractRectorTestCase.php
# specific error report
- src/Rector/AbstractScopeAwareRector.php

-
message: '#Interface "(.*?)" has only single implementer\. Consider using the class directly as there is no point in using the interface#'
Expand All @@ -325,9 +271,6 @@ parameters:
message: '#Parameters should have "PhpParser\\Node\\Stmt\\ClassMethod" types as the only types passed to this method#'
path: src/Reflection/ClassModifierChecker.php

# node / stmts
- '#Parameter \#3 \$stmts of method Rector\\PostRector\\Application\\PostFileProcessor\:\:shouldSkipPostRector\(\) expects array<PhpParser\\Node\\Stmt>, array<PhpParser\\Node> given#'

# false positive - should be fixed
-
message: '#Parameters should have "PhpParser\\Node\\Expr\\Closure" types as the only types passed to this method#'
Expand Down Expand Up @@ -364,31 +307,11 @@ parameters:
- '#Method Rector\\.*::providePolyfillPackage\(\) never returns#'
- '#Method Rector\\.*::filterPolyfillPackages\(\) should return array\<#'

# realpath() usage
-
message: '#should return string\|null but returns string\|false#'
paths:
- src/Bootstrap/RectorConfigsResolver.php
- src/ValueObject/Error/SystemError.php

-
message: '#should return array\<string\> but returns list\<string\|false\>#'
path: src/Set/SetManager.php

-
message: '#should return non-empty-string but returns non-empty-string\|false#'
identifier: typePerfect.noMixedMethodCaller
paths:
- src/Configuration/RectorConfigBuilder.php
- src/FileSystem/FilesFinder.php
- src/PhpParser/Parser/RectorParser.php

# collection of Type
-
message: '#Method Rector\\NodeTypeResolver\\PHPStan\\Type\\TypeFactory::uniquateTypes\(\) should return array\<TType of PHPStan\\Type\\Type\> but returns list\<PHPStan\\Type\\Type>#'
path: src/NodeTypeResolver/PHPStan/Type/TypeFactory.php

-
identifier: typePerfect.noMixedMethodCaller
paths:
- src/PhpParser/Parser/RectorParser.php
- src/functions/node_helper.php
- src/DependencyInjection/LazyContainerFactory.php
message: '#Method Rector\\NodeTypeResolver\\PHPStan\\Type\\TypeFactory\:\:uniquateTypes\(\) should return array<TType of PHPStan\\Type\\Type> but returns list<PHPStan\\Type\\Type>#'

0 comments on commit ff49b20

Please sign in to comment.