Skip to content

Commit

Permalink
[NodeTypeResolver] Remove unused AttributeKey::INSIDE_ARRAY_ITEM on C…
Browse files Browse the repository at this point in the history
…ontextNodeVisitor (#4496)

* [NodeTypeResolver] Remove unused AttributeKey::INSIDE_ARRAY_ITEM on ContextNodeVisitor

* [ci-review] Rector Rectify

* Fix test

* Fix test

* Fix test

---------

Co-authored-by: GitHub Action <actions@github.com>
  • Loading branch information
samsonasik and actions-user committed Jul 12, 2023
1 parent 77167c7 commit 9e9a314
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 23 deletions.
5 changes: 0 additions & 5 deletions packages/NodeTypeResolver/Node/AttributeKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,4 @@ final class AttributeKey
* @var string
*/
public const INSIDE_ARRAY_DIM_FETCH = 'inside_array_dim_fetch';

/**
* @var string
*/
public const INSIDE_ARRAY_ITEM = 'inside_array_item';
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\Array_;
use PhpParser\Node\Expr\ArrayDimFetch;
use PhpParser\Node\Expr\ArrayItem;
use PhpParser\Node\Expr\Closure;
use PhpParser\Node\Expr\Isset_;
use PhpParser\Node\Expr\Match_;
use PhpParser\Node\Expr\PropertyFetch;
use PhpParser\Node\Expr\StaticPropertyFetch;
use PhpParser\Node\Expr\Variable;
Expand Down Expand Up @@ -51,13 +49,6 @@ private function processInsideArrayDimFetch(ArrayDimFetch $arrayDimFetch): void
}
}

private function processInsideArrayItem(ArrayItem $arrayItem): void
{
if ($arrayItem->value instanceof Match_) {
$arrayItem->value->setAttribute(AttributeKey::INSIDE_ARRAY_ITEM, true);
}
}

public function enterNode(Node $node): ?Node
{
if ($node instanceof For_ || $node instanceof Foreach_ || $node instanceof While_ || $node instanceof Do_) {
Expand All @@ -70,11 +61,6 @@ public function enterNode(Node $node): ?Node
return null;
}

if ($node instanceof ArrayItem && $node->value instanceof Match_) {
$this->processInsideArrayItem($node);
return null;
}

if ($node instanceof Isset_ || $node instanceof Unset_) {
$this->processContextInIssetOrUnset($node);
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\PHPUnit\Rector\MethodCall\AssertComparisonToSpecificMethodRector;
use Rector\PHPUnit\Rector\MethodCall\AssertFalseStrposToContainsRector;
use Rector\PHPUnit\Rector\MethodCall\AssertSameBoolNullToSpecificMethodRector;
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertComparisonToSpecificMethodRector;
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertFalseStrposToContainsRector;
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertSameBoolNullToSpecificMethodRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->rule(AssertComparisonToSpecificMethodRector::class);
Expand Down
2 changes: 1 addition & 1 deletion tests/Issues/UndefinedStmtIndex/config/configured_rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\StmtsAwareInterface\RemoveJustPropertyFetchForAssignRector;
use Rector\PHPUnit\Rector\Foreach_\SimplifyForeachInstanceOfRector;
use Rector\PHPUnit\CodeQuality\Rector\Foreach_\SimplifyForeachInstanceOfRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->rule(RemoveJustPropertyFetchForAssignRector::class);
Expand Down

0 comments on commit 9e9a314

Please sign in to comment.