mirror of https://github.com/rectorphp/rector.git
Updated Rector to commit b93e285a4a72ef12d4892852118d5ab7b1b48bdd
b93e285a4a
[DX] Remove AddDefaultValueForUndefinedVariableRector as can generate broken code and depends on context (#4729)
This commit is contained in:
parent
dcc3c616a4
commit
e7097335cd
|
@ -5,11 +5,8 @@ namespace RectorPrefix202308;
|
|||
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\Php56\Rector\FuncCall\PowToExpRector;
|
||||
use Rector\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector;
|
||||
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->rule(PowToExpRector::class);
|
||||
$rectorConfig->ruleWithConfiguration(RenameFunctionRector::class, ['mcrypt_generic_end' => 'mcrypt_generic_deinit', 'set_socket_blocking' => 'stream_set_blocking', 'ocibindbyname' => 'oci_bind_by_name', 'ocicancel' => 'oci_cancel', 'ocicolumnisnull' => 'oci_field_is_null', 'ocicolumnname' => 'oci_field_name', 'ocicolumnprecision' => 'oci_field_precision', 'ocicolumnscale' => 'oci_field_scale', 'ocicolumnsize' => 'oci_field_size', 'ocicolumntype' => 'oci_field_type', 'ocicolumntyperaw' => 'oci_field_type_raw', 'ocicommit' => 'oci_commit', 'ocidefinebyname' => 'oci_define_by_name', 'ocierror' => 'oci_error', 'ociexecute' => 'oci_execute', 'ocifetch' => 'oci_fetch', 'ocifetchstatement' => 'oci_fetch_all', 'ocifreecursor' => 'oci_free_statement', 'ocifreestatement' => 'oci_free_statement', 'ociinternaldebug' => 'oci_internal_debug', 'ocilogoff' => 'oci_close', 'ocilogon' => 'oci_connect', 'ocinewcollection' => 'oci_new_collection', 'ocinewcursor' => 'oci_new_cursor', 'ocinewdescriptor' => 'oci_new_descriptor', 'ocinlogon' => 'oci_new_connect', 'ocinumcols' => 'oci_num_fields', 'ociparse' => 'oci_parse', 'ociplogon' => 'oci_pconnect', 'ociresult' => 'oci_result', 'ocirollback' => 'oci_rollback', 'ocirowcount' => 'oci_num_rows', 'ociserverversion' => 'oci_server_version', 'ocisetprefetch' => 'oci_set_prefetch', 'ocistatementtype' => 'oci_statement_type']);
|
||||
# inspired by level in psalm - https://github.com/vimeo/psalm/blob/82e0bcafac723fdf5007a31a7ae74af1736c9f6f/tests/FileManipulationTest.php#L1063
|
||||
$rectorConfig->rule(AddDefaultValueForUndefinedVariableRector::class);
|
||||
};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# 357 Rules Overview
|
||||
# 356 Rules Overview
|
||||
|
||||
<br>
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
|||
|
||||
- [Php55](#php55) (6)
|
||||
|
||||
- [Php56](#php56) (2)
|
||||
- [Php56](#php56) (1)
|
||||
|
||||
- [Php70](#php70) (19)
|
||||
|
||||
|
@ -3818,28 +3818,6 @@ return static function (RectorConfig $rectorConfig): void {
|
|||
|
||||
## Php56
|
||||
|
||||
### AddDefaultValueForUndefinedVariableRector
|
||||
|
||||
Adds default value for undefined variable
|
||||
|
||||
- class: [`Rector\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector`](../rules/Php56/Rector/FunctionLike/AddDefaultValueForUndefinedVariableRector.php)
|
||||
|
||||
```diff
|
||||
class SomeClass
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
+ $a = null;
|
||||
if (rand(0, 1)) {
|
||||
$a = 5;
|
||||
}
|
||||
echo $a;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
### PowToExpRector
|
||||
|
||||
Changes pow(val, val2) to ** (exp) parameter
|
||||
|
@ -7565,27 +7543,8 @@ return static function (RectorConfig $rectorConfig): void {
|
|||
|
||||
Add return type void to function like without any return
|
||||
|
||||
:wrench: **configure it!**
|
||||
|
||||
- class: [`Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector`](../rules/TypeDeclaration/Rector/ClassMethod/AddVoidReturnTypeWhereNoReturnRector.php)
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector;
|
||||
|
||||
return static function (RectorConfig $rectorConfig): void {
|
||||
$rectorConfig->ruleWithConfiguration(AddVoidReturnTypeWhereNoReturnRector::class, [
|
||||
AddVoidReturnTypeWhereNoReturnRector::USE_PHPDOC => false,
|
||||
]);
|
||||
};
|
||||
```
|
||||
|
||||
↓
|
||||
|
||||
```diff
|
||||
final class SomeClass
|
||||
{
|
||||
|
|
|
@ -66,13 +66,6 @@ final class RectorConfig extends ContainerConfigurator
|
|||
{
|
||||
SimpleParameterProvider::setParameter(Option::MEMORY_LIMIT, $memoryLimit);
|
||||
}
|
||||
/**
|
||||
* @param mixed $skipRule
|
||||
*/
|
||||
private function isRuleNoLongerExists($skipRule) : bool
|
||||
{
|
||||
return \is_string($skipRule) && \strpos($skipRule, '*') === \false && \realpath($skipRule) === \false && \substr_compare($skipRule, 'Rector', -\strlen('Rector')) === 0 && !\class_exists($skipRule);
|
||||
}
|
||||
/**
|
||||
* @param array<int|string, mixed> $criteria
|
||||
*/
|
||||
|
@ -245,6 +238,13 @@ final class RectorConfig extends ContainerConfigurator
|
|||
SimpleParameterProvider::setParameter(Option::INDENT_CHAR, $character);
|
||||
SimpleParameterProvider::setParameter(Option::INDENT_SIZE, $count);
|
||||
}
|
||||
/**
|
||||
* @param mixed $skipRule
|
||||
*/
|
||||
private function isRuleNoLongerExists($skipRule) : bool
|
||||
{
|
||||
return \is_string($skipRule) && \strpos($skipRule, '*') === \false && \realpath($skipRule) === \false && \substr_compare($skipRule, 'Rector', -\strlen('Rector')) === 0 && !\class_exists($skipRule);
|
||||
}
|
||||
/**
|
||||
* @param string[] $values
|
||||
* @return string[]
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
declare (strict_types=1);
|
||||
namespace Rector\VendorLocker;
|
||||
|
||||
use PHPStan\BetterReflection\Reflection\ReflectionClass;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PHPStan\BetterReflection\Reflection\ReflectionClass;
|
||||
use PHPStan\Reflection\ClassReflection;
|
||||
use PHPStan\Reflection\MethodReflection;
|
||||
use PHPStan\Type\Type;
|
||||
|
|
|
@ -1,217 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Php56\NodeAnalyzer;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\Array_;
|
||||
use PhpParser\Node\Expr\ArrayItem;
|
||||
use PhpParser\Node\Expr\ArrowFunction;
|
||||
use PhpParser\Node\Expr\AssignOp\Coalesce as AssignOpCoalesce;
|
||||
use PhpParser\Node\Expr\AssignRef;
|
||||
use PhpParser\Node\Expr\BinaryOp\Coalesce;
|
||||
use PhpParser\Node\Expr\Cast\Unset_ as UnsetCast;
|
||||
use PhpParser\Node\Expr\Closure;
|
||||
use PhpParser\Node\Expr\Empty_;
|
||||
use PhpParser\Node\Expr\Isset_;
|
||||
use PhpParser\Node\Expr\List_;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\FunctionLike;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\Case_;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Foreach_;
|
||||
use PhpParser\Node\Stmt\Function_;
|
||||
use PhpParser\Node\Stmt\Unset_;
|
||||
use PhpParser\NodeTraverser;
|
||||
use PHPStan\Analyser\Scope;
|
||||
use Rector\Core\NodeAnalyzer\VariableAnalyzer;
|
||||
use Rector\Core\PhpParser\Comparing\NodeComparator;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\PhpDocParser\NodeTraverser\SimpleCallableNodeTraverser;
|
||||
final class UndefinedVariableResolver
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\PhpDocParser\NodeTraverser\SimpleCallableNodeTraverser
|
||||
*/
|
||||
private $simpleCallableNodeTraverser;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\NodeNameResolver\NodeNameResolver
|
||||
*/
|
||||
private $nodeNameResolver;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\PhpParser\Comparing\NodeComparator
|
||||
*/
|
||||
private $nodeComparator;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\NodeAnalyzer\VariableAnalyzer
|
||||
*/
|
||||
private $variableAnalyzer;
|
||||
public function __construct(SimpleCallableNodeTraverser $simpleCallableNodeTraverser, NodeNameResolver $nodeNameResolver, NodeComparator $nodeComparator, VariableAnalyzer $variableAnalyzer)
|
||||
{
|
||||
$this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser;
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
$this->nodeComparator = $nodeComparator;
|
||||
$this->variableAnalyzer = $variableAnalyzer;
|
||||
}
|
||||
/**
|
||||
* @return string[]
|
||||
* @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure $node
|
||||
*/
|
||||
public function resolve($node) : array
|
||||
{
|
||||
$undefinedVariables = [];
|
||||
$checkedVariables = [];
|
||||
$currentStmt = null;
|
||||
$this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $node->stmts, function (Node $node) use(&$undefinedVariables, &$checkedVariables, &$currentStmt) : ?int {
|
||||
// entering new scope - break!
|
||||
if ($node instanceof FunctionLike && !$node instanceof ArrowFunction) {
|
||||
return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
|
||||
}
|
||||
if ($node instanceof Foreach_ || $node instanceof Case_) {
|
||||
// handled above
|
||||
return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
|
||||
}
|
||||
if ($node instanceof Stmt) {
|
||||
$currentStmt = $node;
|
||||
if ($currentStmt->getAttribute(AttributeKey::IS_UNREACHABLE) === \true) {
|
||||
return NodeTraverser::STOP_TRAVERSAL;
|
||||
}
|
||||
}
|
||||
if (!$node instanceof Variable) {
|
||||
$checkedVariables = $this->resolveCheckedVariables($node, $checkedVariables);
|
||||
return null;
|
||||
}
|
||||
// after variable variable, the variable name got unpredictable, just stop
|
||||
if ($node->name instanceof Variable) {
|
||||
return NodeTraverser::STOP_TRAVERSAL;
|
||||
}
|
||||
$variableName = (string) $this->nodeNameResolver->getName($node);
|
||||
if ($this->shouldSkipVariable($node, $variableName, $checkedVariables, $currentStmt)) {
|
||||
return null;
|
||||
}
|
||||
/** @var string $variableName */
|
||||
$undefinedVariables[] = $variableName;
|
||||
return null;
|
||||
});
|
||||
return \array_unique($undefinedVariables);
|
||||
}
|
||||
/**
|
||||
* @param string[] $checkedVariables
|
||||
* @return string[]
|
||||
*/
|
||||
private function resolveCheckedVariables(Node $node, array $checkedVariables) : array
|
||||
{
|
||||
if ($node instanceof Empty_ && $node->expr instanceof Variable) {
|
||||
$checkedVariables[] = (string) $this->nodeNameResolver->getName($node->expr);
|
||||
return $checkedVariables;
|
||||
}
|
||||
if ($node instanceof Isset_ || $node instanceof Unset_) {
|
||||
return $this->resolveCheckedVariablesFromIssetOrUnset($node, $checkedVariables);
|
||||
}
|
||||
if ($node instanceof UnsetCast && $node->expr instanceof Variable) {
|
||||
$checkedVariables[] = (string) $this->nodeNameResolver->getName($node->expr);
|
||||
return $checkedVariables;
|
||||
}
|
||||
if ($node instanceof Coalesce && $node->left instanceof Variable) {
|
||||
$checkedVariables[] = (string) $this->nodeNameResolver->getName($node->left);
|
||||
return $checkedVariables;
|
||||
}
|
||||
if ($node instanceof AssignOpCoalesce && $node->var instanceof Variable) {
|
||||
$checkedVariables[] = (string) $this->nodeNameResolver->getName($node->var);
|
||||
return $checkedVariables;
|
||||
}
|
||||
if ($node instanceof AssignRef && $node->var instanceof Variable) {
|
||||
$checkedVariables[] = (string) $this->nodeNameResolver->getName($node->var);
|
||||
}
|
||||
return $this->resolveCheckedVariablesFromArrayOrList($node, $checkedVariables);
|
||||
}
|
||||
/**
|
||||
* @param string[] $checkedVariables
|
||||
* @return string[]
|
||||
* @param \PhpParser\Node\Expr\Isset_|\PhpParser\Node\Stmt\Unset_ $node
|
||||
*/
|
||||
private function resolveCheckedVariablesFromIssetOrUnset($node, array $checkedVariables) : array
|
||||
{
|
||||
foreach ($node->vars as $expr) {
|
||||
if ($expr instanceof Variable) {
|
||||
$checkedVariables[] = (string) $this->nodeNameResolver->getName($expr);
|
||||
}
|
||||
}
|
||||
return $checkedVariables;
|
||||
}
|
||||
/**
|
||||
* @param string[] $checkedVariables
|
||||
* @return string[]
|
||||
*/
|
||||
private function resolveCheckedVariablesFromArrayOrList(Node $node, array $checkedVariables) : array
|
||||
{
|
||||
if (!$node instanceof Array_ && !$node instanceof List_) {
|
||||
return $checkedVariables;
|
||||
}
|
||||
foreach ($node->items as $item) {
|
||||
if (!$item instanceof ArrayItem) {
|
||||
continue;
|
||||
}
|
||||
if (!$item->value instanceof Variable) {
|
||||
continue;
|
||||
}
|
||||
$checkedVariables[] = (string) $this->nodeNameResolver->getName($item->value);
|
||||
}
|
||||
return $checkedVariables;
|
||||
}
|
||||
private function hasVariableTypeOrCurrentStmtUnreachable(Variable $variable, ?string $variableName, ?Stmt $currentStmt) : bool
|
||||
{
|
||||
if (!\is_string($variableName)) {
|
||||
return \true;
|
||||
}
|
||||
// defined 100 %
|
||||
/** @var Scope $scope */
|
||||
$scope = $variable->getAttribute(AttributeKey::SCOPE);
|
||||
if ($scope->hasVariableType($variableName)->yes()) {
|
||||
return \true;
|
||||
}
|
||||
return $currentStmt instanceof Stmt && $currentStmt->getAttribute(AttributeKey::IS_UNREACHABLE) === \true;
|
||||
}
|
||||
/**
|
||||
* @param string[] $checkedVariables
|
||||
*/
|
||||
private function shouldSkipVariable(Variable $variable, string $variableName, array &$checkedVariables, ?Stmt $currentStmt) : bool
|
||||
{
|
||||
$variableName = $this->nodeNameResolver->getName($variable);
|
||||
// skip $this, as probably in outer scope
|
||||
if ($variableName === 'this') {
|
||||
return \true;
|
||||
}
|
||||
if ($variableName === null) {
|
||||
return \true;
|
||||
}
|
||||
if ($this->isDifferentWithOriginalNodeOrNoScope($variable)) {
|
||||
return \true;
|
||||
}
|
||||
if ($this->variableAnalyzer->isStaticOrGlobal($variable)) {
|
||||
return \true;
|
||||
}
|
||||
if (\in_array($variableName, $checkedVariables, \true)) {
|
||||
return \true;
|
||||
}
|
||||
if ($variable->getAttribute(AttributeKey::IS_BEING_ASSIGNED) === \true) {
|
||||
return \true;
|
||||
}
|
||||
return $this->hasVariableTypeOrCurrentStmtUnreachable($variable, $variableName, $currentStmt);
|
||||
}
|
||||
private function isDifferentWithOriginalNodeOrNoScope(Variable $variable) : bool
|
||||
{
|
||||
$originalNode = $variable->getAttribute(AttributeKey::ORIGINAL_NODE);
|
||||
if (!$this->nodeComparator->areNodesEqual($variable, $originalNode)) {
|
||||
return \true;
|
||||
}
|
||||
$nodeScope = $variable->getAttribute(AttributeKey::SCOPE);
|
||||
return !$nodeScope instanceof Scope;
|
||||
}
|
||||
}
|
|
@ -1,147 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Php56\Rector\FunctionLike;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\Array_;
|
||||
use PhpParser\Node\Expr\ArrayDimFetch;
|
||||
use PhpParser\Node\Expr\Assign;
|
||||
use PhpParser\Node\Expr\Closure;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use PhpParser\Node\Stmt\Function_;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\Php56\NodeAnalyzer\UndefinedVariableResolver;
|
||||
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @changelog https://github.com/vimeo/psalm/blob/29b70442b11e3e66113935a2ee22e165a70c74a4/docs/fixing_code.md#possiblyundefinedvariable
|
||||
* @changelog https://3v4l.org/MZFel
|
||||
*
|
||||
* @see \Rector\Tests\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector\AddDefaultValueForUndefinedVariableRectorTest
|
||||
*/
|
||||
final class AddDefaultValueForUndefinedVariableRector extends AbstractRector implements MinPhpVersionInterface
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Php56\NodeAnalyzer\UndefinedVariableResolver
|
||||
*/
|
||||
private $undefinedVariableResolver;
|
||||
public function __construct(UndefinedVariableResolver $undefinedVariableResolver)
|
||||
{
|
||||
$this->undefinedVariableResolver = $undefinedVariableResolver;
|
||||
}
|
||||
public function provideMinPhpVersion() : int
|
||||
{
|
||||
return PhpVersionFeature::REQUIRE_DEFAULT_VALUE;
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Adds default value for undefined variable', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
class SomeClass
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
if (rand(0, 1)) {
|
||||
$a = 5;
|
||||
}
|
||||
echo $a;
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
class SomeClass
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$a = null;
|
||||
if (rand(0, 1)) {
|
||||
$a = 5;
|
||||
}
|
||||
echo $a;
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [ClassMethod::class, Function_::class, Closure::class];
|
||||
}
|
||||
/**
|
||||
* @param ClassMethod|Function_|Closure $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
if ($node->stmts === null) {
|
||||
return null;
|
||||
}
|
||||
$undefinedVariableNames = $this->undefinedVariableResolver->resolve($node);
|
||||
if ($undefinedVariableNames === []) {
|
||||
return null;
|
||||
}
|
||||
$variablesInitiation = $this->collectVariablesInitiation($undefinedVariableNames, $node->stmts);
|
||||
if ($variablesInitiation === []) {
|
||||
return null;
|
||||
}
|
||||
$node->stmts = \array_merge($variablesInitiation, $node->stmts);
|
||||
return $node;
|
||||
}
|
||||
/**
|
||||
* @param Stmt[] $stmts
|
||||
* @return Expression[]
|
||||
*/
|
||||
private function collectEarlyExpressionStmts(array $stmts) : array
|
||||
{
|
||||
$expressionStmts = [];
|
||||
foreach ($stmts as $stmt) {
|
||||
if (!$stmt instanceof Expression) {
|
||||
break;
|
||||
}
|
||||
$expressionStmts[] = $stmt;
|
||||
}
|
||||
return $expressionStmts;
|
||||
}
|
||||
/**
|
||||
* @param string[] $undefinedVariableNames
|
||||
* @param Stmt[] $stmts
|
||||
* @return Expression[]
|
||||
*/
|
||||
private function collectVariablesInitiation(array $undefinedVariableNames, array $stmts) : array
|
||||
{
|
||||
$variablesInitiation = [];
|
||||
$expressionStmts = $this->collectEarlyExpressionStmts($stmts);
|
||||
foreach ($undefinedVariableNames as $undefinedVariableName) {
|
||||
$value = $this->isArray($undefinedVariableName, $stmts) ? new Array_([]) : $this->nodeFactory->createNull();
|
||||
$assign = new Assign(new Variable($undefinedVariableName), $value);
|
||||
$expresssion = new Expression($assign);
|
||||
foreach ($expressionStmts as $expressionStmt) {
|
||||
if ($this->nodeComparator->areNodesEqual($expresssion, $expressionStmt)) {
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
$variablesInitiation[] = $expresssion;
|
||||
}
|
||||
return $variablesInitiation;
|
||||
}
|
||||
/**
|
||||
* @param Stmt[] $stmts
|
||||
*/
|
||||
private function isArray(string $undefinedVariable, array $stmts) : bool
|
||||
{
|
||||
return (bool) $this->betterNodeFinder->findFirst($stmts, function (Node $node) use($undefinedVariable) : bool {
|
||||
if (!$node instanceof ArrayDimFetch) {
|
||||
return \false;
|
||||
}
|
||||
return $this->isName($node->var, $undefinedVariable);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -3,7 +3,6 @@
|
|||
declare (strict_types=1);
|
||||
namespace Rector\Privatization\Guard;
|
||||
|
||||
use PHPStan\BetterReflection\Reflection\ReflectionClass;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\PropertyFetch;
|
||||
use PhpParser\Node\Expr\StaticPropertyFetch;
|
||||
|
@ -11,6 +10,7 @@ use PhpParser\Node\Expr\Variable;
|
|||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\Property;
|
||||
use PHPStan\BetterReflection\Reflection\ReflectionClass;
|
||||
use PHPStan\Reflection\ClassReflection;
|
||||
use Rector\Core\Enum\ObjectReference;
|
||||
use Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer;
|
||||
|
|
|
@ -19,12 +19,12 @@ final class VersionResolver
|
|||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '59cf4dd699aff10f3cd59bdfc11236651200383a';
|
||||
public const PACKAGE_VERSION = 'b93e285a4a72ef12d4892852118d5ab7b1b48bdd';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-08-09 11:09:15';
|
||||
public const RELEASE_DATE = '2023-08-09 11:53:17';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
declare (strict_types=1);
|
||||
namespace Rector\Core\PhpParser\Node\Value;
|
||||
|
||||
use PHPStan\BetterReflection\Reflection\ReflectionClass;
|
||||
use PhpParser\ConstExprEvaluationException;
|
||||
use PhpParser\ConstExprEvaluator;
|
||||
use PhpParser\Node\Expr;
|
||||
|
@ -14,6 +13,7 @@ use PhpParser\Node\Name;
|
|||
use PhpParser\Node\Scalar\MagicConst\Dir;
|
||||
use PhpParser\Node\Scalar\MagicConst\File;
|
||||
use PHPStan\Analyser\Scope;
|
||||
use PHPStan\BetterReflection\Reflection\ReflectionClass;
|
||||
use PHPStan\Reflection\ClassReflection;
|
||||
use PHPStan\Reflection\ReflectionProvider;
|
||||
use PHPStan\Type\Constant\ConstantArrayType;
|
||||
|
|
|
@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit2b34e9dcc0472662e43329a42359ee72::getLoader();
|
||||
return ComposerAutoloaderInit49fe253cd6feaf0ecb83e42669503603::getLoader();
|
||||
|
|
|
@ -2126,9 +2126,7 @@ return array(
|
|||
'Rector\\Php55\\Rector\\FuncCall\\PregReplaceEModifierRector' => $baseDir . '/rules/Php55/Rector/FuncCall/PregReplaceEModifierRector.php',
|
||||
'Rector\\Php55\\Rector\\String_\\StringClassNameToClassConstantRector' => $baseDir . '/rules/Php55/Rector/String_/StringClassNameToClassConstantRector.php',
|
||||
'Rector\\Php55\\RegexMatcher' => $baseDir . '/rules/Php55/RegexMatcher.php',
|
||||
'Rector\\Php56\\NodeAnalyzer\\UndefinedVariableResolver' => $baseDir . '/rules/Php56/NodeAnalyzer/UndefinedVariableResolver.php',
|
||||
'Rector\\Php56\\Rector\\FuncCall\\PowToExpRector' => $baseDir . '/rules/Php56/Rector/FuncCall/PowToExpRector.php',
|
||||
'Rector\\Php56\\Rector\\FunctionLike\\AddDefaultValueForUndefinedVariableRector' => $baseDir . '/rules/Php56/Rector/FunctionLike/AddDefaultValueForUndefinedVariableRector.php',
|
||||
'Rector\\Php70\\Enum\\BattleshipCompareOrder' => $baseDir . '/rules/Php70/Enum/BattleshipCompareOrder.php',
|
||||
'Rector\\Php70\\EregToPcreTransformer' => $baseDir . '/rules/Php70/EregToPcreTransformer.php',
|
||||
'Rector\\Php70\\Exception\\InvalidEregException' => $baseDir . '/rules/Php70/Exception/InvalidEregException.php',
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit2b34e9dcc0472662e43329a42359ee72
|
||||
class ComposerAutoloaderInit49fe253cd6feaf0ecb83e42669503603
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,17 +22,17 @@ class ComposerAutoloaderInit2b34e9dcc0472662e43329a42359ee72
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit2b34e9dcc0472662e43329a42359ee72', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit49fe253cd6feaf0ecb83e42669503603', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit2b34e9dcc0472662e43329a42359ee72', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit49fe253cd6feaf0ecb83e42669503603', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit2b34e9dcc0472662e43329a42359ee72::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit49fe253cd6feaf0ecb83e42669503603::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit2b34e9dcc0472662e43329a42359ee72::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit49fe253cd6feaf0ecb83e42669503603::$files;
|
||||
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit2b34e9dcc0472662e43329a42359ee72
|
||||
class ComposerStaticInit49fe253cd6feaf0ecb83e42669503603
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
|
@ -2380,9 +2380,7 @@ class ComposerStaticInit2b34e9dcc0472662e43329a42359ee72
|
|||
'Rector\\Php55\\Rector\\FuncCall\\PregReplaceEModifierRector' => __DIR__ . '/../..' . '/rules/Php55/Rector/FuncCall/PregReplaceEModifierRector.php',
|
||||
'Rector\\Php55\\Rector\\String_\\StringClassNameToClassConstantRector' => __DIR__ . '/../..' . '/rules/Php55/Rector/String_/StringClassNameToClassConstantRector.php',
|
||||
'Rector\\Php55\\RegexMatcher' => __DIR__ . '/../..' . '/rules/Php55/RegexMatcher.php',
|
||||
'Rector\\Php56\\NodeAnalyzer\\UndefinedVariableResolver' => __DIR__ . '/../..' . '/rules/Php56/NodeAnalyzer/UndefinedVariableResolver.php',
|
||||
'Rector\\Php56\\Rector\\FuncCall\\PowToExpRector' => __DIR__ . '/../..' . '/rules/Php56/Rector/FuncCall/PowToExpRector.php',
|
||||
'Rector\\Php56\\Rector\\FunctionLike\\AddDefaultValueForUndefinedVariableRector' => __DIR__ . '/../..' . '/rules/Php56/Rector/FunctionLike/AddDefaultValueForUndefinedVariableRector.php',
|
||||
'Rector\\Php70\\Enum\\BattleshipCompareOrder' => __DIR__ . '/../..' . '/rules/Php70/Enum/BattleshipCompareOrder.php',
|
||||
'Rector\\Php70\\EregToPcreTransformer' => __DIR__ . '/../..' . '/rules/Php70/EregToPcreTransformer.php',
|
||||
'Rector\\Php70\\Exception\\InvalidEregException' => __DIR__ . '/../..' . '/rules/Php70/Exception/InvalidEregException.php',
|
||||
|
@ -3004,9 +3002,9 @@ class ComposerStaticInit2b34e9dcc0472662e43329a42359ee72
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit2b34e9dcc0472662e43329a42359ee72::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit2b34e9dcc0472662e43329a42359ee72::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit2b34e9dcc0472662e43329a42359ee72::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit49fe253cd6feaf0ecb83e42669503603::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit49fe253cd6feaf0ecb83e42669503603::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit49fe253cd6feaf0ecb83e42669503603::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue