mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-19 14:27:14 +01:00
Updated Rector to commit 63201f76725831988f1484476f6f84e0976a5742
63201f7672
[CodeQuality] Skip Superglobals variable on SimplifyEmptyCheckOnEmptyArrayRector (#5369)
This commit is contained in:
parent
291e258902
commit
335a3861f8
@ -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;
|
||||
|
@ -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
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user