mirror of
https://github.com/rectorphp/rector.git
synced 2025-03-14 20:39:43 +01:00
fix static
This commit is contained in:
parent
6398090e1a
commit
f6da9d2854
@ -18,23 +18,23 @@
|
||||
"nette/robot-loader": "^3.1",
|
||||
"nette/utils": "^2.5|^3.0",
|
||||
"nikic/php-parser": "^4.2.2",
|
||||
"phpstan/phpdoc-parser": "0.3.3",
|
||||
"phpstan/phpdoc-parser": "^0.3.4",
|
||||
"phpstan/phpstan": "0.11.6",
|
||||
"sebastian/diff": "^3.0",
|
||||
"symfony/console": "^3.4|^4.2",
|
||||
"symfony/dependency-injection": "^3.4|^4.2",
|
||||
"symfony/finder": "^3.4|^4.2",
|
||||
"symfony/process": "^3.4|^4.2",
|
||||
"symplify/package-builder": "^6.0"
|
||||
"symplify/package-builder": "^6.0.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"friendsofphp/php-cs-fixer": "^2.14",
|
||||
"ocramius/package-versions": "^1.4",
|
||||
"phpunit/phpunit": "^7.5|^8.0",
|
||||
"symplify/changelog-linker": "^6.0",
|
||||
"symplify/easy-coding-standard": "^6.0",
|
||||
"symplify/monorepo-builder": "^6.0",
|
||||
"symplify/phpstan-extensions": "^6.0",
|
||||
"symplify/changelog-linker": "^6.0.1",
|
||||
"symplify/easy-coding-standard": "^6.0.1",
|
||||
"symplify/monorepo-builder": "^6.0.1",
|
||||
"symplify/phpstan-extensions": "^6.0.1",
|
||||
"thecodingmachine/phpstan-strict-rules": "^0.11",
|
||||
"tracy/tracy": "^2.5"
|
||||
},
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
namespace Rector\CodeQuality\Rector\Array_;
|
||||
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Arg;
|
||||
use PhpParser\Node\Expr;
|
||||
@ -15,6 +14,7 @@ use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Param;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use PhpParser\Node\Stmt\Return_;
|
||||
use Rector\NodeContainer\ParsedNodesByType;
|
||||
use Rector\Rector\AbstractRector;
|
||||
|
@ -8,7 +8,6 @@ use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\Assign;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Stmt\Nop;
|
||||
use Rector\Exception\ShouldNotHappenException;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\Rector\AbstractRector;
|
||||
use Rector\RectorDefinition\CodeSample;
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
namespace Rector\Php\Rector\BinaryOp;
|
||||
|
||||
use PhpParser\Node\Expr\BinaryOp\Concat;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\BinaryOp;
|
||||
use PhpParser\Node\Expr\BinaryOp\Concat;
|
||||
use PhpParser\Node\Scalar\LNumber;
|
||||
use Rector\Rector\AbstractRector;
|
||||
use Rector\RectorDefinition\CodeSample;
|
||||
|
@ -93,15 +93,7 @@ CODE_SAMPLE
|
||||
return null;
|
||||
}
|
||||
|
||||
$parentNode = $node->getAttribute(AttributeKey::PARENT_NODE);
|
||||
if ($parentNode instanceof Assign || $this->isStaticVariable($parentNode)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/** @var Scope|null $nodeScope */
|
||||
$nodeScope = $node->getAttribute(AttributeKey::SCOPE);
|
||||
if ($nodeScope === null) {
|
||||
// possible in foreach variable
|
||||
if ($this->shouldSkipVariable($node)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -111,14 +103,12 @@ CODE_SAMPLE
|
||||
}
|
||||
|
||||
// defined 100 %
|
||||
/** @var Scope $nodeScope */
|
||||
$nodeScope = $node->getAttribute(AttributeKey::SCOPE);
|
||||
if ($nodeScope->hasVariableType($variableName)->yes()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($parentNode instanceof Unset_ || $parentNode instanceof Node\Expr\Cast\Unset_) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// @todo improve
|
||||
$this->undefinedVariables[] = $variableName;
|
||||
});
|
||||
@ -151,4 +141,23 @@ CODE_SAMPLE
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function shouldSkipVariable(Variable $variable): bool
|
||||
{
|
||||
$parentNode = $variable->getAttribute(AttributeKey::PARENT_NODE);
|
||||
if ($parentNode instanceof Node) {
|
||||
if ($parentNode instanceof Assign || $this->isStaticVariable($parentNode)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($parentNode instanceof Unset_ || $parentNode instanceof Node\Expr\Cast\Unset_) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** @var Scope|null $nodeScope */
|
||||
$nodeScope = $variable->getAttribute(AttributeKey::SCOPE);
|
||||
|
||||
return $nodeScope === null;
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,3 @@ parameters:
|
||||
|
||||
# so Rector code is still PHP 7.1 compatible
|
||||
php_version_features: '7.1'
|
||||
|
||||
services:
|
||||
Rector\CodingStyle\Rector\Namespace_\ImportFullyQualifiedNamesRector: ~
|
||||
|
@ -15,5 +15,7 @@ final class AutowiredEventDispatcher extends EventDispatcher
|
||||
foreach ($eventSubscribers as $eventSubscriber) {
|
||||
$this->addSubscriber($eventSubscriber);
|
||||
}
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user