-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathAnnotateClientLocatorCommand.php
More file actions
54 lines (44 loc) · 1.59 KB
/
AnnotateClientLocatorCommand.php
File metadata and controls
54 lines (44 loc) · 1.59 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
namespace AwsBuild\Command;
final class AnnotateClientLocatorCommand extends AbstractCommand
{
public function getName(): string
{
return 'annotate-client-locator';
}
public function getDescription(): string
{
return 'Updates @method annotations on the Aws\Sdk class.';
}
public function getUsage(): string
{
return 'php build/WorkflowCommandRunner.php annotate-client-locator';
}
protected function doExecute(array $args): int
{
$namespaces = array_map(function (array $manifest) {
return $manifest['namespace'];
}, array_values(\Aws\manifest()));
sort($namespaces);
$annotations = [];
foreach ($namespaces as $namespace) {
$mrClient = "\\Aws\\{$namespace}\\{$namespace}MultiRegionClient";
$mrClient = class_exists($mrClient) ? $mrClient : "\\Aws\\MultiRegionClient";
$annotations[] = " * @method \\Aws\\{$namespace}\\{$namespace}Client"
. " create{$namespace}(array \$args = [])";
$annotations[] = " * @method $mrClient"
. " createMultiRegion{$namespace}(array \$args = [])";
}
$previousAnnotationPattern = '/^\* @method'
. ' \\\\Aws\\\\(?:[a-zA-Z0-9\\\\]+)Client'
. ' create(?:[a-zA-Z0-9]+)\\(array \$args = \\[\\]\\)/';
$updater = new \ClassAnnotationUpdater(
new \ReflectionClass(\Aws\Sdk::class),
$annotations,
'',
$previousAnnotationPattern
);
$updater->update();
return 0;
}
}