Skip to content

Commit

Permalink
Updated Rector to commit 8e96b1b9dbd4a5fdf8da8d863aa9e153298d7427
Browse files Browse the repository at this point in the history
rectorphp/rector-src@8e96b1b [DeadCode] Skip from call with return docblock on ReduceAlwaysFalseIfOrRector (#6361)
  • Loading branch information
TomasVotruba committed Oct 7, 2024
1 parent 7822553 commit 68910d2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
19 changes: 17 additions & 2 deletions rules/DeadCode/NodeAnalyzer/SafeLeftTypeBooleanAndOrAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@
use PhpParser\Node\Expr\ArrayDimFetch;
use PhpParser\Node\Expr\BinaryOp\BooleanAnd;
use PhpParser\Node\Expr\BinaryOp\BooleanOr;
use PhpParser\Node\Expr\CallLike;
use PhpParser\Node\Expr\Instanceof_;
use PhpParser\Node\Expr\PropertyFetch;
use PhpParser\Node\Expr\StaticPropertyFetch;
use PhpParser\Node\Expr\Variable;
use PHPStan\Reflection\ClassReflection;
use PHPStan\Type\MixedType;
use Rector\NodeAnalyzer\ExprAnalyzer;
use Rector\NodeTypeResolver\NodeTypeResolver;
use Rector\PhpParser\Node\BetterNodeFinder;
use Rector\Reflection\ReflectionResolver;
final class SafeLeftTypeBooleanAndOrAnalyzer
Expand All @@ -32,11 +35,17 @@ final class SafeLeftTypeBooleanAndOrAnalyzer
* @var \Rector\Reflection\ReflectionResolver
*/
private $reflectionResolver;
public function __construct(BetterNodeFinder $betterNodeFinder, ExprAnalyzer $exprAnalyzer, ReflectionResolver $reflectionResolver)
/**
* @readonly
* @var \Rector\NodeTypeResolver\NodeTypeResolver
*/
private $nodeTypeResolver;
public function __construct(BetterNodeFinder $betterNodeFinder, ExprAnalyzer $exprAnalyzer, ReflectionResolver $reflectionResolver, NodeTypeResolver $nodeTypeResolver)
{
$this->betterNodeFinder = $betterNodeFinder;
$this->exprAnalyzer = $exprAnalyzer;
$this->reflectionResolver = $reflectionResolver;
$this->nodeTypeResolver = $nodeTypeResolver;
}
/**
* @param \PhpParser\Node\Expr\BinaryOp\BooleanAnd|\PhpParser\Node\Expr\BinaryOp\BooleanOr $booleanAnd
Expand All @@ -61,6 +70,12 @@ public function isSafe($booleanAnd) : bool
if ($classReflection instanceof ClassReflection && $classReflection->isTrait()) {
return !$booleanAnd->left instanceof Instanceof_;
}
return \true;
return !(bool) $this->betterNodeFinder->findFirst($booleanAnd->left, function (Node $node) : bool {
if (!$node instanceof CallLike) {
return \false;
}
$nativeType = $this->nodeTypeResolver->getNativeType($node);
return $nativeType instanceof MixedType && !$nativeType->isExplicitMixed();
});
}
}
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 = '748330a01994017fded43807745d77366fe3bff9';
public const PACKAGE_VERSION = '8e96b1b9dbd4a5fdf8da8d863aa9e153298d7427';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-10-06 19:25:08';
public const RELEASE_DATE = '2024-10-08 01:56:21';
/**
* @var int
*/
Expand Down
Loading

0 comments on commit 68910d2

Please sign in to comment.