Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Oct 26, 2024
1 parent 02b566a commit 6864c5f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
5 changes: 0 additions & 5 deletions rules/DeadCode/PhpDoc/DeadVarTagValueNodeAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Rector\DeadCode\PhpDoc;

use PhpParser\Node\Stmt\Property;
use PHPStan\PhpDoc\Tag\TemplateTag;
use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode;
use PHPStan\Type\IntersectionType;
use PHPStan\Type\ObjectType;
Expand Down Expand Up @@ -36,10 +35,6 @@ public function isDead(VarTagValueNode $varTagValueNode, Property $property): bo
$propertyType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($property->type);
$docType = $this->staticTypeMapper->mapPHPStanPhpDocTypeNodeToPHPStanType($varTagValueNode->type, $property);

if ($docType instanceof TemplateTag) {
return false;
}

if ($propertyType instanceof UnionType && ! $docType instanceof UnionType) {
return ! $docType instanceof IntersectionType;
}
Expand Down
5 changes: 2 additions & 3 deletions rules/TypeDeclaration/PHPStan/ObjectTypeSpecifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\ReflectionProvider;
use PHPStan\Type\Generic\GenericObjectType;
use PHPStan\Type\Generic\TemplateType;
use PHPStan\Type\Generic\TemplateTypeFactory;
use PHPStan\Type\Generic\TemplateTypeScope;
use PHPStan\Type\MixedType;
use PHPStan\Type\ObjectType;
use PHPStan\Type\Type;
use PHPStan\Type\TypeWithClassName;
use PHPStan\Type\UnionType;
use Rector\Naming\Naming\UseImportsResolver;
Expand All @@ -43,7 +43,7 @@ public function narrowToFullyQualifiedOrAliasedObjectType(
Node $node,
ObjectType $objectType,
Scope|null $scope
): TypeWithClassName | NonExistingObjectType | UnionType | MixedType | Type {
): TypeWithClassName | NonExistingObjectType | UnionType | MixedType | TemplateType {
$uses = $this->useImportsResolver->resolve();

$aliasedObjectType = $this->matchAliasedObjectType($objectType, $uses);
Expand Down Expand Up @@ -76,7 +76,6 @@ public function narrowToFullyQualifiedOrAliasedObjectType(
$classReflection = $scope->getClassReflection();
if ($classReflection instanceof ClassReflection) {
$templateTags = $classReflection->getTemplateTags();
$types = [];
$nameScope = $this->nameScopeFactory->createNameScopeFromNodeWithoutTemplateTypes($node);
$templateTypeScope = $nameScope->getTemplateTypeScope();

Expand Down
5 changes: 5 additions & 0 deletions src/NodeTypeResolver/TypeComparator/TypeComparator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use PHPStan\Type\BooleanType;
use PHPStan\Type\Constant\ConstantBooleanType;
use PHPStan\Type\ConstantScalarType;
use PHPStan\Type\Generic\TemplateType;
use PHPStan\Type\MixedType;
use PHPStan\Type\ObjectType;
use PHPStan\Type\StaticType;
Expand Down Expand Up @@ -75,6 +76,10 @@ public function arePhpParserAndPhpStanPhpDocTypesEqual(
$node
);

if ($phpStanDocType instanceof TemplateType) {
return false;
}

if (! $this->areTypesEqual($phpParserNodeType, $phpStanDocType) && $this->isSubtype(
$phpStanDocType,
$phpParserNodeType
Expand Down

0 comments on commit 6864c5f

Please sign in to comment.