REDROOM
PHP 8.2.31
Path:
Logout
Edit File
Size: 2.01 KB
Close
/opt/cpanel/ea-wappspector/vendor/rector/rector/rules/Php74/Rector/FuncCall/ArrayKeyExistsOnPropertyRector.php
Text
Base64
<?php declare (strict_types=1); namespace Rector\Php74\Rector\FuncCall; use PhpParser\Node; use PhpParser\Node\Arg; use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Name; use PHPStan\Type\ObjectType; use Rector\Rector\AbstractRector; use Rector\ValueObject\PhpVersionFeature; use Rector\VersionBonding\Contract\MinPhpVersionInterface; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\Php74\Rector\FuncCall\ArrayKeyExistsOnPropertyRector\ArrayKeyExistsOnPropertyRectorTest */ final class ArrayKeyExistsOnPropertyRector extends AbstractRector implements MinPhpVersionInterface { public function provideMinPhpVersion() : int { return PhpVersionFeature::ARRAY_KEY_EXISTS_TO_PROPERTY_EXISTS; } public function getRuleDefinition() : RuleDefinition { return new RuleDefinition('Change array_key_exists() on property to property_exists()', [new CodeSample(<<<'CODE_SAMPLE' class SomeClass { public $value; } $someClass = new SomeClass; array_key_exists('value', $someClass); CODE_SAMPLE , <<<'CODE_SAMPLE' class SomeClass { public $value; } $someClass = new SomeClass; property_exists($someClass, 'value'); CODE_SAMPLE )]); } /** * @return array<class-string<Node>> */ public function getNodeTypes() : array { return [FuncCall::class]; } /** * @param FuncCall $node */ public function refactor(Node $node) : ?Node { if (!$this->isName($node, 'array_key_exists')) { return null; } if (!isset($node->args[1])) { return null; } if (!$node->args[1] instanceof Arg) { return null; } $firstArgStaticType = $this->getType($node->args[1]->value); if (!$firstArgStaticType instanceof ObjectType) { return null; } $node->name = new Name('property_exists'); $node->args = \array_reverse($node->args); return $node; } }
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 0 × Files: 6
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
ArrayKeyExistsOnPropertyRector.php
2.01 KB
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
FilterVarToAddSlashesRector.php
1.79 KB
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
HebrevcToNl2brHebrevRector.php
1.52 KB
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
MbStrrposEncodingArgumentPositionRector.php
1.85 KB
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
MoneyFormatToNumberFormatRector.php
2.91 KB
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
RestoreIncludePathToIniRestoreRector.php
1.69 KB
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).