REDROOM
PHP 8.2.31
Path:
Logout
Edit File
Size: 3.12 KB
Close
/opt/cpanel/ea-wappspector/vendor/rector/rector/vendor/rector/rector-symfony/src/NodeAnalyzer/SymfonyClosureExtensionMatcher.php
Text
Base64
<?php declare (strict_types=1); namespace Rector\Symfony\NodeAnalyzer; use PhpParser\Node\Expr\Array_; use PhpParser\Node\Expr\Closure; use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Stmt\Expression; use Rector\Exception\ShouldNotHappenException; use Rector\NodeNameResolver\NodeNameResolver; use Rector\PhpParser\Node\Value\ValueResolver; use Rector\Symfony\ValueObject\ExtensionKeyAndConfiguration; final class SymfonyClosureExtensionMatcher { /** * @readonly * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; /** * @readonly * @var \Rector\PhpParser\Node\Value\ValueResolver */ private $valueResolver; public function __construct(NodeNameResolver $nodeNameResolver, ValueResolver $valueResolver) { $this->nodeNameResolver = $nodeNameResolver; $this->valueResolver = $valueResolver; } public function match(Closure $closure) : ?ExtensionKeyAndConfiguration { if (\count($closure->stmts) > 1) { $extensionNames = $this->resolveExtensionNames($closure); if (\count($extensionNames) > 2) { return null; } // warn use early about it, to avoid silent skip $errorMessage = \sprintf('Split extensions "%s" to multiple separated files first', \implode('", "', $extensionNames)); throw new ShouldNotHappenException($errorMessage); } // must be exactly single line if (\count($closure->stmts) !== 1) { return null; } $onlyStmt = $closure->stmts[0]; if (!$onlyStmt instanceof Expression) { return null; } if (!$onlyStmt->expr instanceof MethodCall) { return null; } $methodCall = $onlyStmt->expr; $args = $methodCall->getArgs(); $extensionKey = $this->matchExtensionName($methodCall); if (!\is_string($extensionKey)) { return null; } $secondArg = $args[1]; if (!$secondArg->value instanceof Array_) { return null; } return new ExtensionKeyAndConfiguration($extensionKey, $secondArg->value); } private function matchExtensionName(MethodCall $methodCall) : ?string { if (!$this->nodeNameResolver->isName($methodCall->name, 'extension')) { return null; } $args = $methodCall->getArgs(); $firstArg = $args[0]; return $this->valueResolver->getValue($firstArg->value); } /** * @return string[] */ private function resolveExtensionNames(Closure $closure) : array { $extensionNames = []; foreach ($closure->stmts as $stmt) { if (!$stmt instanceof Expression) { continue; } $expr = $stmt->expr; if (!$expr instanceof MethodCall) { continue; } $extensionName = $this->matchExtensionName($expr); if (!\is_string($extensionName)) { continue; } $extensionNames[] = $extensionName; } return $extensionNames; } }
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 2 × Files: 12
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
Annotations
DIR
-
drwxr-xr-x
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
FormType
DIR
-
drwxr-xr-x
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
ClassAnalyzer.php
730 B
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
DependencyInjectionMethodCallAnalyzer.php
3.83 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
FormAddMethodCallAnalyzer.php
1.49 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
FormCollectionAnalyzer.php
1.21 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
FormInstanceToFormClassConstFetchConverter.php
3.62 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
FormOptionsArrayMatcher.php
508 B
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
LiteralCallLikeConstFetchReplacer.php
1.43 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
RouteRequiredParamNameToTypesResolver.php
5.08 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
ServiceTypeMethodCallResolver.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
SymfonyClosureExtensionMatcher.php
3.12 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
SymfonyPhpClosureDetector.php
2.62 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
SymfonyTestCaseAnalyzer.php
1.18 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).