diff --git a/ecs.php b/ecs.php index 0843e496663..0497edc8d5b 100644 --- a/ecs.php +++ b/ecs.php @@ -2,6 +2,7 @@ declare(strict_types=1); +use PhpCsFixer\Fixer\Casing\LowercaseKeywordsFixer; use PhpCsFixer\Fixer\Phpdoc\GeneralPhpdocAnnotationRemoveFixer; use PhpCsFixer\Fixer\Phpdoc\PhpdocTypesFixer; use Symplify\EasyCodingStandard\Config\ECSConfig; @@ -34,5 +35,7 @@ // bug remove @author annotation __DIR__ . '/src/Util/ArrayParametersMerger.php', ], + + LowercaseKeywordsFixer::class => [__DIR__ . '/src/ValueObject/Visibility.php'], ]) ->withRootFiles(); diff --git a/rules/CodeQuality/Rector/Class_/RemoveReadonlyPropertyVisibilityOnReadonlyClassRector.php b/rules/CodeQuality/Rector/Class_/RemoveReadonlyPropertyVisibilityOnReadonlyClassRector.php index c55659eb984..e1bf1ed8e6a 100644 --- a/rules/CodeQuality/Rector/Class_/RemoveReadonlyPropertyVisibilityOnReadonlyClassRector.php +++ b/rules/CodeQuality/Rector/Class_/RemoveReadonlyPropertyVisibilityOnReadonlyClassRector.php @@ -5,8 +5,8 @@ namespace Rector\CodeQuality\Rector\Class_; use PhpParser\Node; -use PhpParser\Node\Stmt\ClassMethod; use PhpParser\Node\Stmt\Class_; +use PhpParser\Node\Stmt\ClassMethod; use Rector\Php81\NodeManipulator\AttributeGroupNewLiner; use Rector\Privatization\NodeManipulator\VisibilityManipulator; use Rector\Rector\AbstractRector; diff --git a/rules/DeadCode/PhpDoc/DeadParamTagValueNodeAnalyzer.php b/rules/DeadCode/PhpDoc/DeadParamTagValueNodeAnalyzer.php index 12380af8887..187cb79ed7f 100644 --- a/rules/DeadCode/PhpDoc/DeadParamTagValueNodeAnalyzer.php +++ b/rules/DeadCode/PhpDoc/DeadParamTagValueNodeAnalyzer.php @@ -9,6 +9,7 @@ use PhpParser\Node\Name; use PhpParser\Node\Param; use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode; +use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode; use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode; use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger; use Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareUnionTypeNode; @@ -51,6 +52,10 @@ public function isDead(ParamTagValueNode $paramTagValueNode, FunctionLike $funct return false; } + if ($paramTagValueNode->type instanceof GenericTypeNode) { + return false; + } + $docType = $this->staticTypeMapper->mapPHPStanPhpDocTypeNodeToPHPStanType( $paramTagValueNode->type, $functionLike diff --git a/rules/DeadCode/PhpDoc/DeadReturnTagValueNodeAnalyzer.php b/rules/DeadCode/PhpDoc/DeadReturnTagValueNodeAnalyzer.php index 89808203aaf..e55e247c9e1 100644 --- a/rules/DeadCode/PhpDoc/DeadReturnTagValueNodeAnalyzer.php +++ b/rules/DeadCode/PhpDoc/DeadReturnTagValueNodeAnalyzer.php @@ -10,6 +10,7 @@ use PhpParser\Node\Stmt\Function_; use PHPStan\Analyser\Scope; use PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode; +use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode; use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode; use PHPStan\PhpDocParser\Ast\Type\ThisTypeNode; use PHPStan\Type\TypeCombinator; @@ -49,6 +50,10 @@ public function isDead(ReturnTagValueNode $returnTagValueNode, ClassMethod|Funct return false; } + if ($returnTagValueNode->type instanceof GenericTypeNode) { + return false; + } + $docType = $this->staticTypeMapper->mapPHPStanPhpDocTypeNodeToPHPStanType( $returnTagValueNode->type, $functionLike diff --git a/rules/DeadCode/PhpDoc/DeadVarTagValueNodeAnalyzer.php b/rules/DeadCode/PhpDoc/DeadVarTagValueNodeAnalyzer.php index 5a0c2120a7f..9d0b078cee3 100644 --- a/rules/DeadCode/PhpDoc/DeadVarTagValueNodeAnalyzer.php +++ b/rules/DeadCode/PhpDoc/DeadVarTagValueNodeAnalyzer.php @@ -8,6 +8,7 @@ use PhpParser\Node\Stmt\ClassConst; use PhpParser\Node\Stmt\Property; use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode; +use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode; use PHPStan\Type\IntersectionType; use PHPStan\Type\ObjectType; use PHPStan\Type\TypeCombinator; @@ -35,6 +36,10 @@ public function isDead(VarTagValueNode $varTagValueNode, Property|ClassConst $pr return false; } + if ($varTagValueNode->type instanceof GenericTypeNode) { + return false; + } + // is strict type superior to doc type? keep strict type only $propertyType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($property->type); $docType = $this->staticTypeMapper->mapPHPStanPhpDocTypeNodeToPHPStanType($varTagValueNode->type, $property); diff --git a/rules/TypeDeclaration/Rector/FuncCall/AddArrayFunctionClosureParamTypeRector.php b/rules/TypeDeclaration/Rector/FuncCall/AddArrayFunctionClosureParamTypeRector.php index 14bc2b3b8c7..f9eb8e497de 100644 --- a/rules/TypeDeclaration/Rector/FuncCall/AddArrayFunctionClosureParamTypeRector.php +++ b/rules/TypeDeclaration/Rector/FuncCall/AddArrayFunctionClosureParamTypeRector.php @@ -106,6 +106,7 @@ public function refactor(Node $node): ?Node if (! $singlePassedExprType instanceof Type) { continue; } + if ($singlePassedExprType instanceof MixedType) { continue; }