[CodeQuality] Fixes #4950 Skip IssetOnPropertyObjectToPropertyExistsRector on property as variable (#4953)

This commit is contained in:
Abdul Malik Ikhsan 2020-12-23 05:21:12 +07:00 committed by GitHub
parent 9e6365cc58
commit 48eaa5c950
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 2 deletions

View File

@ -12,6 +12,7 @@ use PhpParser\Node\Expr\BinaryOp\NotIdentical;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Expr\Isset_;
use PhpParser\Node\Expr\PropertyFetch;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Identifier;
use PhpParser\Node\Name;
use PhpParser\Node\Scalar\String_;
@ -96,10 +97,13 @@ CODE_SAMPLE
continue;
}
/** @var Identifier $name */
/** @var Identifier|Variable $name */
$name = $issetVar->name;
$property = $name->toString();
if (! $name instanceof Identifier) {
continue;
}
$property = $name->toString();
if ($type instanceof ObjectType) {
/** @var string $className */
$className = $type->getClassName();

View File

@ -0,0 +1,18 @@
<?php
namespace Rector\CodeQuality\Tests\Rector\Isset_\IssetOnPropertyObjectToPropertyExistsRector\Fixture;
class SkipPropertyAsVariable
{
public function run($name)
{
return isset($this->getStorage()->$name);
}
private function getStorage(): array
{
return [];
}
}
?>