Skip to content

Commit

Permalink
[ci-review] Rector Rectify
Browse files Browse the repository at this point in the history
  • Loading branch information
kaizen-ci committed Apr 15, 2021
1 parent b570bf9 commit 4847022
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,23 @@ public function collectPropertyFetchByMethods(Class_ $class, array $propertyName
{
$propertyUsageByMethods = [];

foreach ($propertyNames as $privatePropertyName) {
foreach ($propertyNames as $propertyName) {
foreach ($class->getMethods() as $classMethod) {
// assigned in constructor injection → skip
if ($this->nodeNameResolver->isName($classMethod, MethodName::CONSTRUCT)) {
return [];
}

if (! $this->propertyFetchAnalyzer->containsLocalPropertyFetchName(
$classMethod,
$privatePropertyName
)) {
if (! $this->propertyFetchAnalyzer->containsLocalPropertyFetchName($classMethod, $propertyName)) {
continue;
}

if ($this->isPropertyChangingInMultipleMethodCalls($classMethod, $privatePropertyName)) {
if ($this->isPropertyChangingInMultipleMethodCalls($classMethod, $propertyName)) {
continue;
}

$classMethodName = $this->nodeNameResolver->getName($classMethod);
$propertyUsageByMethods[$privatePropertyName][] = $classMethodName;
$propertyUsageByMethods[$propertyName][] = $classMethodName;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use PhpParser\Node;
use PhpParser\Node\Stmt\Class_;
use Rector\Core\NodeAnalyzer\PropertyFetchAnalyzer;
use Rector\Core\NodeManipulator\ClassManipulator;
use Rector\Core\Rector\AbstractRector;
use Rector\Privatization\NodeAnalyzer\PropertyFetchByMethodAnalyzer;
Expand All @@ -24,11 +23,6 @@ final class ChangeLocalPropertyToVariableRector extends AbstractRector
*/
private $classManipulator;

/**
* @var PropertyFetchAnalyzer
*/
private $propertyFetchAnalyzer;

/**
* @var PropertyFetchWithVariableReplacer
*/
Expand All @@ -41,12 +35,10 @@ final class ChangeLocalPropertyToVariableRector extends AbstractRector

public function __construct(
ClassManipulator $classManipulator,
PropertyFetchAnalyzer $propertyFetchAnalyzer,
PropertyFetchWithVariableReplacer $propertyFetchWithVariableReplacer,
PropertyFetchByMethodAnalyzer $propertyFetchByMethodAnalyzer
) {
$this->classManipulator = $classManipulator;
$this->propertyFetchAnalyzer = $propertyFetchAnalyzer;
$this->propertyFetchWithVariableReplacer = $propertyFetchWithVariableReplacer;
$this->propertyFetchByMethodAnalyzer = $propertyFetchByMethodAnalyzer;
}
Expand Down

0 comments on commit 4847022

Please sign in to comment.