Updated Rector to commit 63201f76725831988f1484476f6f84e0976a5742

63201f7672 [CodeQuality] Skip Superglobals variable on SimplifyEmptyCheckOnEmptyArrayRector (#5369)
This commit is contained in:
Tomas Votruba 2023-12-17 09:24:20 +00:00
parent 291e258902
commit 335a3861f8
2 changed files with 18 additions and 4 deletions

View File

@ -20,6 +20,7 @@ use PHPStan\Reflection\ClassReflection;
use PHPStan\Type\ArrayType;
use PHPStan\Type\MixedType;
use Rector\Core\NodeAnalyzer\ExprAnalyzer;
use Rector\Core\Php\ReservedKeywordAnalyzer;
use Rector\Core\PhpParser\AstResolver;
use Rector\Core\Rector\AbstractScopeAwareRector;
use Rector\Core\Reflection\ReflectionResolver;
@ -51,12 +52,18 @@ final class SimplifyEmptyCheckOnEmptyArrayRector extends AbstractScopeAwareRecto
* @var \Rector\TypeDeclaration\TypeInferer\PropertyTypeInferer\AllAssignNodePropertyTypeInferer
*/
private $allAssignNodePropertyTypeInferer;
public function __construct(ExprAnalyzer $exprAnalyzer, ReflectionResolver $reflectionResolver, AstResolver $astResolver, AllAssignNodePropertyTypeInferer $allAssignNodePropertyTypeInferer)
/**
* @readonly
* @var \Rector\Core\Php\ReservedKeywordAnalyzer
*/
private $reservedKeywordAnalyzer;
public function __construct(ExprAnalyzer $exprAnalyzer, ReflectionResolver $reflectionResolver, AstResolver $astResolver, AllAssignNodePropertyTypeInferer $allAssignNodePropertyTypeInferer, ReservedKeywordAnalyzer $reservedKeywordAnalyzer)
{
$this->exprAnalyzer = $exprAnalyzer;
$this->reflectionResolver = $reflectionResolver;
$this->astResolver = $astResolver;
$this->allAssignNodePropertyTypeInferer = $allAssignNodePropertyTypeInferer;
$this->reservedKeywordAnalyzer = $reservedKeywordAnalyzer;
}
public function getRuleDefinition() : RuleDefinition
{
@ -97,13 +104,20 @@ CODE_SAMPLE
}
return new Identical($node->expr, new Array_());
}
private function isAllowedVariable(Variable $variable) : bool
{
if (\is_string($variable->name) && $this->reservedKeywordAnalyzer->isNativeVariable($variable->name)) {
return \false;
}
return !$this->exprAnalyzer->isNonTypedFromParam($variable);
}
private function isAllowedExpr(Expr $expr, Scope $scope) : bool
{
if (!$scope->getType($expr) instanceof ArrayType) {
return \false;
}
if ($expr instanceof Variable) {
return !$this->exprAnalyzer->isNonTypedFromParam($expr);
return $this->isAllowedVariable($expr);
}
if (!$expr instanceof PropertyFetch && !$expr instanceof StaticPropertyFetch) {
return \false;

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '54491a53f081fd8785269513b1650a524a9077f1';
public const PACKAGE_VERSION = '63201f76725831988f1484476f6f84e0976a5742';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-12-17 07:27:47';
public const RELEASE_DATE = '2023-12-17 16:22:12';
/**
* @var int
*/