-
Notifications
You must be signed in to change notification settings - Fork 112
Expand file tree
/
Copy pathCommandArgumentsResolver.php
More file actions
38 lines (30 loc) · 1.03 KB
/
CommandArgumentsResolver.php
File metadata and controls
38 lines (30 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
declare(strict_types=1);
namespace Rector\Symfony\Symfony73\NodeAnalyzer;
use PhpParser\Node\Stmt\ClassMethod;
use Rector\Symfony\Symfony73\NodeFinder\MethodCallFinder;
use Rector\Symfony\Symfony73\ValueObject\CommandArgument;
final readonly class CommandArgumentsResolver
{
public function __construct(
private MethodCallFinder $methodCallFinder,
) {
}
/**
* @return CommandArgument[]
*/
public function resolve(ClassMethod $configureClassMethod): array
{
$addArgumentMethodCalls = $this->methodCallFinder->find($configureClassMethod, 'addArgument');
$commandArguments = [];
foreach ($addArgumentMethodCalls as $addArgumentMethodCall) {
$addArgumentArgs = $addArgumentMethodCall->getArgs();
$commandArguments[] = new CommandArgument(
$addArgumentArgs[0]->value,
$addArgumentArgs[1]->value ?? null,
$addArgumentArgs[2]->value ?? null,
);
}
return $commandArguments;
}
}