From 7e642e6024970041a1c97eedb35037851e09be0c Mon Sep 17 00:00:00 2001 From: Gabriel Caruso Date: Sat, 12 May 2018 16:57:50 -0300 Subject: [PATCH] Revert change Sounds like isn't necessary --- phpstan.neon | 1 + .../ReplaceVariableByPropertyFetchRector.php | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/phpstan.neon b/phpstan.neon index 348ab8a7a81..ab7134fb785 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -19,6 +19,7 @@ parameters: # known values - '#Argument of an invalid type array\|null supplied for foreach, only iterables are supported#' # 1 - '#Access to an undefined property PHPStan\\PhpDocParser\\Ast\\Node::\$name#' # 2 + - '#Calling method getName\(\) on possibly null value of type Rector\\Builder\\Class_\\VariableInfo\|null#' # 1 - '#Method Rector\\Node\\NodeFactory::createNullConstant\(\) should return PhpParser\\Node\\Expr\\ConstFetch but returns PhpParser\\Node\\Expr#' # 1 - '#Method Rector\\Node\\NodeFactory::createNamespace\(\) should return PhpParser\\Node\\Stmt\\Namespace_ but returns PhpParser\\Node#' # 1 diff --git a/src/Rector/Architecture/DependencyInjection/ReplaceVariableByPropertyFetchRector.php b/src/Rector/Architecture/DependencyInjection/ReplaceVariableByPropertyFetchRector.php index 195250c9f5d..537fbcd4377 100644 --- a/src/Rector/Architecture/DependencyInjection/ReplaceVariableByPropertyFetchRector.php +++ b/src/Rector/Architecture/DependencyInjection/ReplaceVariableByPropertyFetchRector.php @@ -22,7 +22,7 @@ final class ReplaceVariableByPropertyFetchRector extends AbstractRector private $variablesToPropertyFetchCollection; /** - * @var VariableInfo + * @var VariableInfo|null */ private $activeVariableInfo; @@ -91,6 +91,8 @@ CODE_SAMPLE public function isCandidate(Node $node): bool { + $this->activeVariableInfo = null; + if (! $node instanceof Variable) { return false; }