Skip to content

Commit

Permalink
Fix StrictArrayParamDimFetchRector on same named property (#4488)
Browse files Browse the repository at this point in the history
* Fix StrictArrayParamDimFetchRector on array append

* fix

* Update skip_same_name_property_append.php.inc
  • Loading branch information
staabm committed Jul 12, 2023
1 parent d4be167 commit d514a5a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\StrictArrayParamDimFetchRector\Fixture;

final class SkipSameNamePropertyFetch
{
public function addSuccessMessage($success)
{
$this->success[] = $success;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use PhpParser\Node;
use PhpParser\Node\Expr\ArrayDimFetch;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Identifier;
use PhpParser\Node\Param;
use PhpParser\Node\Stmt\ClassMethod;
Expand Down Expand Up @@ -115,6 +116,10 @@ private function isParamAccessedArrayDimFetch(Param $param, ClassMethod|Function
return null;
}

if (!$node->var instanceof Variable) {
return null;
}

if (! $this->isName($node->var, $paramName)) {
return null;
}
Expand Down

0 comments on commit d514a5a

Please sign in to comment.