REDROOM
PHP 8.2.31
Path:
Logout
Edit File
Size: 2.05 KB
Close
//opt/cpanel/ea-wappspector/vendor/rector/rector/rules/Php81/NodeAnalyzer/CoalesePropertyAssignMatcher.php
Text
Base64
<?php declare (strict_types=1); namespace Rector\Php81\NodeAnalyzer; use PhpParser\Node\Expr; use PhpParser\Node\Expr\Assign; use PhpParser\Node\Expr\BinaryOp\Coalesce; use PhpParser\Node\Expr\New_; use PhpParser\Node\Expr\PropertyFetch; use PhpParser\Node\Stmt; use PhpParser\Node\Stmt\Expression; use Rector\NodeNameResolver\NodeNameResolver; final class CoalesePropertyAssignMatcher { /** * @readonly * @var \Rector\Php81\NodeAnalyzer\ComplexNewAnalyzer */ private $complexNewAnalyzer; /** * @readonly * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; public function __construct(\Rector\Php81\NodeAnalyzer\ComplexNewAnalyzer $complexNewAnalyzer, NodeNameResolver $nodeNameResolver) { $this->complexNewAnalyzer = $complexNewAnalyzer; $this->nodeNameResolver = $nodeNameResolver; } /** * Matches * * $this->value = $param ?? 'default'; */ public function matchCoalesceAssignsToLocalPropertyNamed(Stmt $stmt, string $propertyName) : ?Coalesce { if (!$stmt instanceof Expression) { return null; } if (!$stmt->expr instanceof Assign) { return null; } $assign = $stmt->expr; if (!$assign->expr instanceof Coalesce) { return null; } $coalesce = $assign->expr; if (!$coalesce->right instanceof New_) { return null; } if ($this->complexNewAnalyzer->isDynamic($coalesce->right)) { return null; } if (!$this->isLocalPropertyFetchNamed($assign->var, $propertyName)) { return null; } return $assign->expr; } private function isLocalPropertyFetchNamed(Expr $expr, string $propertyName) : bool { if (!$expr instanceof PropertyFetch) { return \false; } if (!$this->nodeNameResolver->isName($expr->var, 'this')) { return \false; } return $this->nodeNameResolver->isName($expr->name, $propertyName); } }
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 0 × Files: 2
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
CoalesePropertyAssignMatcher.php
2.05 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
ComplexNewAnalyzer.php
2.00 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).