Skip to content

Commit

Permalink
Updated Rector to commit 0482641eaf933bdb7ef52a89f7064126b61366c3
Browse files Browse the repository at this point in the history
rectorphp/rector-src@0482641 Use class name directly in RemoveDeadInstanceOfRector (#6087)
  • Loading branch information
TomasVotruba committed Jun 30, 2024
1 parent 33f4d6d commit f3e0e28
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
13 changes: 9 additions & 4 deletions rules/DeadCode/Rector/If_/RemoveDeadInstanceOfRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
use PhpParser\Node\Expr\PropertyFetch;
use PhpParser\Node\Expr\StaticPropertyFetch;
use PhpParser\Node\Name;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\Expression;
use PhpParser\Node\Stmt\If_;
use PhpParser\NodeTraverser;
use PHPStan\Reflection\ClassReflection;
use PHPStan\Type\MixedType;
use PHPStan\Type\ObjectType;
use Rector\NodeManipulator\IfManipulator;
use Rector\Rector\AbstractRector;
use Rector\Reflection\ReflectionResolver;
Expand Down Expand Up @@ -140,12 +142,15 @@ private function isInstanceofTheSameType(Instanceof_ $instanceof) : ?bool
if ($classReflection instanceof ClassReflection && $classReflection->isTrait()) {
return null;
}
$classType = $this->nodeTypeResolver->getType($instanceof->class);
if (!$instanceof->class instanceof FullyQualified) {
return null;
}
$exprType = $this->nodeTypeResolver->getNativeType($instanceof->expr);
if ($classType->equals($exprType)) {
return \true;
if (!$exprType instanceof ObjectType) {
return null;
}
return $classType->isSuperTypeOf($exprType)->yes();
$className = $instanceof->class->toString();
return $exprType->isInstanceOf($className)->yes();
}
private function refactorIfWithBooleanAnd(If_ $if) : ?\PhpParser\Node\Stmt\If_
{
Expand Down
4 changes: 2 additions & 2 deletions src/Application/VersionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'de0dda8f29453b36bcfa3728cf26662fb634fcd1';
public const PACKAGE_VERSION = '0482641eaf933bdb7ef52a89f7064126b61366c3';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-06-30 19:47:13';
public const RELEASE_DATE = '2024-06-30 19:47:32';
/**
* @var int
*/
Expand Down

0 comments on commit f3e0e28

Please sign in to comment.