Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -34,5 +35,7 @@
// bug remove @author annotation
__DIR__ . '/src/Util/ArrayParametersMerger.php',
],

LowercaseKeywordsFixer::class => [__DIR__ . '/src/ValueObject/Visibility.php'],
])
->withRootFiles();
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions rules/DeadCode/PhpDoc/DeadParamTagValueNodeAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions rules/DeadCode/PhpDoc/DeadReturnTagValueNodeAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions rules/DeadCode/PhpDoc/DeadVarTagValueNodeAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public function refactor(Node $node): ?Node
if (! $singlePassedExprType instanceof Type) {
continue;
}

if ($singlePassedExprType instanceof MixedType) {
continue;
}
Expand Down
Loading