@@ -25,7 +25,7 @@ |
||
25 | 25 | |
26 | 26 | $this->container = new Container(); |
27 | 27 | $this->container->bind(Tokenizer::class, $this->getTokenizer([ |
28 | - 'scopes' => ['foo' => ['directories' => [__DIR__ . '/Enums/Inner'], 'exclude' => []]], |
|
28 | + 'scopes' => ['foo' => ['directories' => [__DIR__.'/Enums/Inner'], 'exclude' => []]], |
|
29 | 29 | ])); |
30 | 30 | $this->container->bindSingleton(ScopedEnumsInterface::class, ScopedEnumLocator::class); |
31 | 31 | } |
@@ -25,7 +25,7 @@ |
||
25 | 25 | |
26 | 26 | $this->container = new Container(); |
27 | 27 | $this->container->bind(Tokenizer::class, $this->getTokenizer(['scopes' => [ |
28 | - 'foo' => ['directories' => [__DIR__ . '/Interfaces/Inner'], 'exclude' => []], |
|
28 | + 'foo' => ['directories' => [__DIR__.'/Interfaces/Inner'], 'exclude' => []], |
|
29 | 29 | ]])); |
30 | 30 | $this->container->bindSingleton(ScopedInterfacesInterface::class, ScopedInterfaceLocator::class); |
31 | 31 | } |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | |
78 | 78 | private function bootStorages(array $config): void |
79 | 79 | { |
80 | - foreach ($config['buckets'] as $name => $bucket) { |
|
81 | - if (!\is_string($name)) { |
|
80 | + foreach ($config['buckets'] as $name => $bucket){ |
|
81 | + if (!\is_string($name)){ |
|
82 | 82 | throw new InvalidArgumentException( |
83 | 83 | \vsprintf('Storage bucket config key must be a string, but %s defined', [ |
84 | 84 | \get_debug_type($name), |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | } |
88 | 88 | |
89 | 89 | $serverName = $bucket['server'] ?? null; |
90 | - if (!\is_string($serverName)) { |
|
90 | + if (!\is_string($serverName)){ |
|
91 | 91 | throw new InvalidArgumentException( |
92 | 92 | \vsprintf('Storage bucket `%s.server` config key required and must be a string, but %s defined', [ |
93 | 93 | $name, |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | } |
98 | 98 | |
99 | 99 | $server = $config['servers'][$serverName] ?? null; |
100 | - if (!\is_array($server)) { |
|
100 | + if (!\is_array($server)){ |
|
101 | 101 | throw new InvalidArgumentException( |
102 | 102 | \vsprintf('Storage bucket `%s` relates to non-existing server `%s`', [ |
103 | 103 | $name, |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | } |
108 | 108 | |
109 | 109 | $adapter = $server['adapter'] ?? null; |
110 | - if (!\is_string($adapter)) { |
|
110 | + if (!\is_string($adapter)){ |
|
111 | 111 | throw new InvalidArgumentException( |
112 | 112 | \vsprintf('Storage server `%s.adapter` config key required and must be a string, but %s defined', [ |
113 | 113 | $serverName, |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | |
121 | 121 | $this->adapters[$name] = $adapter; |
122 | 122 | |
123 | - if (isset($bucket['distribution'])) { |
|
123 | + if (isset($bucket['distribution'])){ |
|
124 | 124 | $this->distributions[$name] = $bucket['distribution']; |
125 | 125 | } |
126 | 126 | } |
@@ -138,9 +138,9 @@ discard block |
||
138 | 138 | |
139 | 139 | private function createS3Adapter(string $serverName, array $bucket, array $server, bool $async): FilesystemAdapter |
140 | 140 | { |
141 | - if (!$async && !\class_exists(Credentials::class)) { |
|
141 | + if (!$async && !\class_exists(Credentials::class)){ |
|
142 | 142 | throw new ConfigException( |
143 | - 'Can not create AWS credentials while creating "' . $serverName . '" server. ' |
|
143 | + 'Can not create AWS credentials while creating "'.$serverName.'" server. ' |
|
144 | 144 | . 'Perhaps you forgot to install the "league/flysystem-aws-s3-v3" package?' |
145 | 145 | ); |
146 | 146 | } |
@@ -148,8 +148,8 @@ discard block |
||
148 | 148 | $name = $bucket['bucket'] ?? $server['bucket']; |
149 | 149 | $visibility = $bucket['visibility'] ?? $server['visibility'] ?? Visibility::VISIBILITY_PUBLIC; |
150 | 150 | |
151 | - if ($async) { |
|
152 | - if (!\class_exists(AsyncAwsS3Adapter::class)) { |
|
151 | + if ($async){ |
|
152 | + if (!\class_exists(AsyncAwsS3Adapter::class)){ |
|
153 | 153 | throw new InvalidArgumentException( |
154 | 154 | 'Can not create async S3 client, please install "league/flysystem-async-aws-s3"' |
155 | 155 | ); |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | ); |
164 | 164 | } |
165 | 165 | |
166 | - if (!\class_exists(AwsS3V3Adapter::class)) { |
|
166 | + if (!\class_exists(AwsS3V3Adapter::class)){ |
|
167 | 167 | throw new InvalidArgumentException( |
168 | 168 | 'Can not create S3 client, please install "league/flysystem-aws-s3-v3"' |
169 | 169 | ); |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | |
180 | 180 | private function createLocalAdapter(string $serverName, array $bucket, array $server): FilesystemAdapter |
181 | 181 | { |
182 | - if (!\is_string($server['directory'] ?? null)) { |
|
182 | + if (!\is_string($server['directory'] ?? null)){ |
|
183 | 183 | throw new InvalidArgumentException( |
184 | 184 | \vsprintf('Storage server `%s.directory` config key required and must be a string, but %s defined', [ |
185 | 185 | $serverName, |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | $adapter = $server['adapter']; |
210 | 210 | $isFilesystemAdapter = \is_subclass_of($adapter, FilesystemAdapter::class, true); |
211 | 211 | |
212 | - if (!$isFilesystemAdapter) { |
|
212 | + if (!$isFilesystemAdapter){ |
|
213 | 213 | throw new InvalidArgumentException( |
214 | 214 | \vsprintf('Storage server `%s` must be a class string of %s, but `%s` defined', [ |
215 | 215 | $serverName, |
@@ -219,9 +219,9 @@ discard block |
||
219 | 219 | ); |
220 | 220 | } |
221 | 221 | |
222 | - try { |
|
222 | + try{ |
|
223 | 223 | return new $adapter(...\array_values($server['options'] ?? [])); |
224 | - } catch (\Throwable $e) { |
|
224 | + }catch (\Throwable $e){ |
|
225 | 225 | $message = 'An error occurred while server `%s` initializing: %s'; |
226 | 226 | throw new InvalidArgumentException(\sprintf($message, $serverName, $e->getMessage()), 0, $e); |
227 | 227 | } |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | 'endpoint' => $server['endpoint'] ?? null, |
235 | 235 | ] + ($server['options'] ?? []); |
236 | 236 | |
237 | - if (!$async) { |
|
237 | + if (!$async){ |
|
238 | 238 | $config['version'] = $server['version'] ?? 'latest'; |
239 | 239 | $config['credentials'] = new Credentials( |
240 | 240 | $server['key'] ?? null, |
@@ -77,8 +77,10 @@ discard block |
||
77 | 77 | |
78 | 78 | private function bootStorages(array $config): void |
79 | 79 | { |
80 | - foreach ($config['buckets'] as $name => $bucket) { |
|
81 | - if (!\is_string($name)) { |
|
80 | + foreach ($config['buckets'] as $name => $bucket) |
|
81 | + { |
|
82 | + if (!\is_string($name)) |
|
83 | + { |
|
82 | 84 | throw new InvalidArgumentException( |
83 | 85 | \vsprintf('Storage bucket config key must be a string, but %s defined', [ |
84 | 86 | \get_debug_type($name), |
@@ -87,7 +89,8 @@ discard block |
||
87 | 89 | } |
88 | 90 | |
89 | 91 | $serverName = $bucket['server'] ?? null; |
90 | - if (!\is_string($serverName)) { |
|
92 | + if (!\is_string($serverName)) |
|
93 | + { |
|
91 | 94 | throw new InvalidArgumentException( |
92 | 95 | \vsprintf('Storage bucket `%s.server` config key required and must be a string, but %s defined', [ |
93 | 96 | $name, |
@@ -97,7 +100,8 @@ discard block |
||
97 | 100 | } |
98 | 101 | |
99 | 102 | $server = $config['servers'][$serverName] ?? null; |
100 | - if (!\is_array($server)) { |
|
103 | + if (!\is_array($server)) |
|
104 | + { |
|
101 | 105 | throw new InvalidArgumentException( |
102 | 106 | \vsprintf('Storage bucket `%s` relates to non-existing server `%s`', [ |
103 | 107 | $name, |
@@ -107,7 +111,8 @@ discard block |
||
107 | 111 | } |
108 | 112 | |
109 | 113 | $adapter = $server['adapter'] ?? null; |
110 | - if (!\is_string($adapter)) { |
|
114 | + if (!\is_string($adapter)) |
|
115 | + { |
|
111 | 116 | throw new InvalidArgumentException( |
112 | 117 | \vsprintf('Storage server `%s.adapter` config key required and must be a string, but %s defined', [ |
113 | 118 | $serverName, |
@@ -120,7 +125,8 @@ discard block |
||
120 | 125 | |
121 | 126 | $this->adapters[$name] = $adapter; |
122 | 127 | |
123 | - if (isset($bucket['distribution'])) { |
|
128 | + if (isset($bucket['distribution'])) |
|
129 | + { |
|
124 | 130 | $this->distributions[$name] = $bucket['distribution']; |
125 | 131 | } |
126 | 132 | } |
@@ -138,7 +144,8 @@ discard block |
||
138 | 144 | |
139 | 145 | private function createS3Adapter(string $serverName, array $bucket, array $server, bool $async): FilesystemAdapter |
140 | 146 | { |
141 | - if (!$async && !\class_exists(Credentials::class)) { |
|
147 | + if (!$async && !\class_exists(Credentials::class)) |
|
148 | + { |
|
142 | 149 | throw new ConfigException( |
143 | 150 | 'Can not create AWS credentials while creating "' . $serverName . '" server. ' |
144 | 151 | . 'Perhaps you forgot to install the "league/flysystem-aws-s3-v3" package?' |
@@ -148,8 +155,10 @@ discard block |
||
148 | 155 | $name = $bucket['bucket'] ?? $server['bucket']; |
149 | 156 | $visibility = $bucket['visibility'] ?? $server['visibility'] ?? Visibility::VISIBILITY_PUBLIC; |
150 | 157 | |
151 | - if ($async) { |
|
152 | - if (!\class_exists(AsyncAwsS3Adapter::class)) { |
|
158 | + if ($async) |
|
159 | + { |
|
160 | + if (!\class_exists(AsyncAwsS3Adapter::class)) |
|
161 | + { |
|
153 | 162 | throw new InvalidArgumentException( |
154 | 163 | 'Can not create async S3 client, please install "league/flysystem-async-aws-s3"' |
155 | 164 | ); |
@@ -163,7 +172,8 @@ discard block |
||
163 | 172 | ); |
164 | 173 | } |
165 | 174 | |
166 | - if (!\class_exists(AwsS3V3Adapter::class)) { |
|
175 | + if (!\class_exists(AwsS3V3Adapter::class)) |
|
176 | + { |
|
167 | 177 | throw new InvalidArgumentException( |
168 | 178 | 'Can not create S3 client, please install "league/flysystem-aws-s3-v3"' |
169 | 179 | ); |
@@ -179,7 +189,8 @@ discard block |
||
179 | 189 | |
180 | 190 | private function createLocalAdapter(string $serverName, array $bucket, array $server): FilesystemAdapter |
181 | 191 | { |
182 | - if (!\is_string($server['directory'] ?? null)) { |
|
192 | + if (!\is_string($server['directory'] ?? null)) |
|
193 | + { |
|
183 | 194 | throw new InvalidArgumentException( |
184 | 195 | \vsprintf('Storage server `%s.directory` config key required and must be a string, but %s defined', [ |
185 | 196 | $serverName, |
@@ -209,7 +220,8 @@ discard block |
||
209 | 220 | $adapter = $server['adapter']; |
210 | 221 | $isFilesystemAdapter = \is_subclass_of($adapter, FilesystemAdapter::class, true); |
211 | 222 | |
212 | - if (!$isFilesystemAdapter) { |
|
223 | + if (!$isFilesystemAdapter) |
|
224 | + { |
|
213 | 225 | throw new InvalidArgumentException( |
214 | 226 | \vsprintf('Storage server `%s` must be a class string of %s, but `%s` defined', [ |
215 | 227 | $serverName, |
@@ -219,9 +231,12 @@ discard block |
||
219 | 231 | ); |
220 | 232 | } |
221 | 233 | |
222 | - try { |
|
234 | + try |
|
235 | + { |
|
223 | 236 | return new $adapter(...\array_values($server['options'] ?? [])); |
224 | - } catch (\Throwable $e) { |
|
237 | + } |
|
238 | + catch (\Throwable $e) |
|
239 | + { |
|
225 | 240 | $message = 'An error occurred while server `%s` initializing: %s'; |
226 | 241 | throw new InvalidArgumentException(\sprintf($message, $serverName, $e->getMessage()), 0, $e); |
227 | 242 | } |
@@ -234,7 +249,8 @@ discard block |
||
234 | 249 | 'endpoint' => $server['endpoint'] ?? null, |
235 | 250 | ] + ($server['options'] ?? []); |
236 | 251 | |
237 | - if (!$async) { |
|
252 | + if (!$async) |
|
253 | + { |
|
238 | 254 | $config['version'] = $server['version'] ?? 'latest'; |
239 | 255 | $config['credentials'] = new Credentials( |
240 | 256 | $server['key'] ?? null, |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | private readonly ConfiguratorInterface $config, |
33 | 33 | private readonly ContainerInterface $container, |
34 | 34 | private readonly FactoryInterface $factory |
35 | - ) { |
|
35 | + ){ |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | public function init(EnvironmentInterface $env): void |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | 'json' => new JsonSerializer(), |
59 | 59 | 'serializer' => new PhpSerializer(), |
60 | 60 | ]; |
61 | - if (\class_exists(Message::class)) { |
|
61 | + if (\class_exists(Message::class)){ |
|
62 | 62 | $serializers['proto'] = new ProtoSerializer(); |
63 | 63 | } |
64 | 64 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @throws \Psr\Container\ContainerExceptionInterface |
73 | 73 | * @throws \Psr\Container\NotFoundExceptionInterface |
74 | 74 | */ |
75 | - private function wire(string|Autowire|SerializerInterface $serializer): SerializerInterface |
|
75 | + private function wire(string | Autowire | SerializerInterface $serializer): SerializerInterface |
|
76 | 76 | { |
77 | 77 | return match (true) { |
78 | 78 | $serializer instanceof SerializerInterface => $serializer, |
@@ -58,7 +58,8 @@ |
||
58 | 58 | 'json' => new JsonSerializer(), |
59 | 59 | 'serializer' => new PhpSerializer(), |
60 | 60 | ]; |
61 | - if (\class_exists(Message::class)) { |
|
61 | + if (\class_exists(Message::class)) |
|
62 | + { |
|
62 | 63 | $serializers['proto'] = new ProtoSerializer(); |
63 | 64 | } |
64 | 65 |
@@ -27,7 +27,7 @@ |
||
27 | 27 | * @type string $url |
28 | 28 | * } |
29 | 29 | */ |
30 | - public function __construct($data = NULL) { |
|
30 | + public function __construct($data = NULL){ |
|
31 | 31 | \Spiral\Tests\Serializer\Fixture\GPBMetadata\Service::initOnce(); |
32 | 32 | parent::__construct($data); |
33 | 33 | } |
@@ -27,7 +27,8 @@ |
||
27 | 27 | * @type string $url |
28 | 28 | * } |
29 | 29 | */ |
30 | - public function __construct($data = NULL) { |
|
30 | + public function __construct($data = NULL) |
|
31 | + { |
|
31 | 32 | \Spiral\Tests\Serializer\Fixture\GPBMetadata\Service::initOnce(); |
32 | 33 | parent::__construct($data); |
33 | 34 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * @type string $url |
28 | 28 | * } |
29 | 29 | */ |
30 | - public function __construct($data = NULL) { |
|
30 | + public function __construct($data = null) { |
|
31 | 31 | \Spiral\Tests\Serializer\Fixture\GPBMetadata\Service::initOnce(); |
32 | 32 | parent::__construct($data); |
33 | 33 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function setUrl($var) |
50 | 50 | { |
51 | - GPBUtil::checkString($var, True); |
|
51 | + GPBUtil::checkString($var, true); |
|
52 | 52 | $this->url = $var; |
53 | 53 | |
54 | 54 | return $this; |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | { |
15 | 15 | public function __construct() |
16 | 16 | { |
17 | - if (!\class_exists(Message::class)) { |
|
17 | + if (!\class_exists(Message::class)){ |
|
18 | 18 | throw new SerializerException('Package `google/protobuf` is not installed.'); |
19 | 19 | } |
20 | 20 | } |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * @throws InvalidArgumentException |
24 | 24 | */ |
25 | - public function serialize(mixed $payload): string|\Stringable |
|
25 | + public function serialize(mixed $payload): string | \Stringable |
|
26 | 26 | { |
27 | - if (!$payload instanceof Message) { |
|
27 | + if (!$payload instanceof Message){ |
|
28 | 28 | throw new InvalidArgumentException(\sprintf( |
29 | 29 | 'Payload must be of type `%s`, received `%s`.', |
30 | 30 | Message::class, |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | * @throws UnserializeException |
40 | 40 | * @throws InvalidArgumentException |
41 | 41 | */ |
42 | - public function unserialize(\Stringable|string $payload, object|string|null $type = null): mixed |
|
42 | + public function unserialize(\Stringable | string $payload, object | string | null $type = null): mixed |
|
43 | 43 | { |
44 | - if (\is_object($type)) { |
|
44 | + if (\is_object($type)){ |
|
45 | 45 | $type = $type::class; |
46 | 46 | } |
47 | 47 | |
48 | - if ($type === null || !\class_exists($type) || !\is_a($type, Message::class, true)) { |
|
48 | + if ($type === null || !\class_exists($type) || !\is_a($type, Message::class, true)){ |
|
49 | 49 | throw new InvalidArgumentException(\sprintf( |
50 | 50 | 'Parameter `$type` must be of type: `%s`, received `%s`.', |
51 | 51 | Message::class, |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | |
56 | 56 | $object = new $type(); |
57 | 57 | |
58 | - try { |
|
59 | - $object->mergeFromString((string) $payload); |
|
60 | - } catch (\Throwable $e) { |
|
58 | + try{ |
|
59 | + $object->mergeFromString((string)$payload); |
|
60 | + }catch (\Throwable $e){ |
|
61 | 61 | throw new UnserializeException( |
62 | 62 | \sprintf('Failed to unserialize data: %s', $e->getMessage()), |
63 | 63 | $e->getCode(), |
@@ -14,7 +14,8 @@ discard block |
||
14 | 14 | { |
15 | 15 | public function __construct() |
16 | 16 | { |
17 | - if (!\class_exists(Message::class)) { |
|
17 | + if (!\class_exists(Message::class)) |
|
18 | + { |
|
18 | 19 | throw new SerializerException('Package `google/protobuf` is not installed.'); |
19 | 20 | } |
20 | 21 | } |
@@ -24,7 +25,8 @@ discard block |
||
24 | 25 | */ |
25 | 26 | public function serialize(mixed $payload): string|\Stringable |
26 | 27 | { |
27 | - if (!$payload instanceof Message) { |
|
28 | + if (!$payload instanceof Message) |
|
29 | + { |
|
28 | 30 | throw new InvalidArgumentException(\sprintf( |
29 | 31 | 'Payload must be of type `%s`, received `%s`.', |
30 | 32 | Message::class, |
@@ -41,11 +43,13 @@ discard block |
||
41 | 43 | */ |
42 | 44 | public function unserialize(\Stringable|string $payload, object|string|null $type = null): mixed |
43 | 45 | { |
44 | - if (\is_object($type)) { |
|
46 | + if (\is_object($type)) |
|
47 | + { |
|
45 | 48 | $type = $type::class; |
46 | 49 | } |
47 | 50 | |
48 | - if ($type === null || !\class_exists($type) || !\is_a($type, Message::class, true)) { |
|
51 | + if ($type === null || !\class_exists($type) || !\is_a($type, Message::class, true)) |
|
52 | + { |
|
49 | 53 | throw new InvalidArgumentException(\sprintf( |
50 | 54 | 'Parameter `$type` must be of type: `%s`, received `%s`.', |
51 | 55 | Message::class, |
@@ -55,9 +59,12 @@ discard block |
||
55 | 59 | |
56 | 60 | $object = new $type(); |
57 | 61 | |
58 | - try { |
|
62 | + try |
|
63 | + { |
|
59 | 64 | $object->mergeFromString((string) $payload); |
60 | - } catch (\Throwable $e) { |
|
65 | + } |
|
66 | + catch (\Throwable $e) |
|
67 | + { |
|
61 | 68 | throw new UnserializeException( |
62 | 69 | \sprintf('Failed to unserialize data: %s', $e->getMessage()), |
63 | 70 | $e->getCode(), |
@@ -70,7 +70,8 @@ discard block |
||
70 | 70 | |
71 | 71 | $this->configureIO($input, $output); |
72 | 72 | |
73 | - if ($command !== null) { |
|
73 | + if ($command !== null) |
|
74 | + { |
|
74 | 75 | $input = new InputProxy($input, ['firstArgument' => $command]); |
75 | 76 | } |
76 | 77 | |
@@ -89,18 +90,21 @@ discard block |
||
89 | 90 | */ |
90 | 91 | public function getApplication(): Application |
91 | 92 | { |
92 | - if ($this->application !== null) { |
|
93 | + if ($this->application !== null) |
|
94 | + { |
|
93 | 95 | return $this->application; |
94 | 96 | } |
95 | 97 | |
96 | 98 | $this->application = new Application($this->config->getName(), $this->config->getVersion()); |
97 | 99 | $this->application->setCatchExceptions(false); |
98 | 100 | $this->application->setAutoExit(false); |
99 | - if ($this->dispatcher instanceof SymfonyEventDispatcherInterface) { |
|
101 | + if ($this->dispatcher instanceof SymfonyEventDispatcherInterface) |
|
102 | + { |
|
100 | 103 | $this->application->setDispatcher($this->dispatcher); |
101 | 104 | } |
102 | 105 | |
103 | - if ($this->locator !== null) { |
|
106 | + if ($this->locator !== null) |
|
107 | + { |
|
104 | 108 | $this->addCommands($this->locator->locateCommands()); |
105 | 109 | } |
106 | 110 | |
@@ -120,13 +124,16 @@ discard block |
||
120 | 124 | { |
121 | 125 | $interceptors = $this->config->getInterceptors(); |
122 | 126 | |
123 | - foreach ($commands as $command) { |
|
124 | - if ($command instanceof Command) { |
|
127 | + foreach ($commands as $command) |
|
128 | + { |
|
129 | + if ($command instanceof Command) |
|
130 | + { |
|
125 | 131 | $command->setContainer($this->container); |
126 | 132 | $command->setInterceptors($interceptors); |
127 | 133 | } |
128 | 134 | |
129 | - if ($this->dispatcher !== null && $command instanceof EventDispatcherAwareInterface) { |
|
135 | + if ($this->dispatcher !== null && $command instanceof EventDispatcherAwareInterface) |
|
136 | + { |
|
130 | 137 | $command->setEventDispatcher($this->dispatcher); |
131 | 138 | } |
132 | 139 | |
@@ -141,22 +148,30 @@ discard block |
||
141 | 148 | */ |
142 | 149 | private function configureIO(InputInterface $input, OutputInterface $output): void |
143 | 150 | { |
144 | - if ($input->hasParameterOption(['--ansi'], true)) { |
|
151 | + if ($input->hasParameterOption(['--ansi'], true)) |
|
152 | + { |
|
145 | 153 | $output->setDecorated(true); |
146 | - } elseif ($input->hasParameterOption(['--no-ansi'], true)) { |
|
154 | + } |
|
155 | + elseif ($input->hasParameterOption(['--no-ansi'], true)) |
|
156 | + { |
|
147 | 157 | $output->setDecorated(false); |
148 | 158 | } |
149 | 159 | |
150 | - if ($input->hasParameterOption(['--no-interaction', '-n'], true)) { |
|
160 | + if ($input->hasParameterOption(['--no-interaction', '-n'], true)) |
|
161 | + { |
|
151 | 162 | $input->setInteractive(false); |
152 | - } elseif (\function_exists('posix_isatty')) { |
|
163 | + } |
|
164 | + elseif (\function_exists('posix_isatty')) |
|
165 | + { |
|
153 | 166 | $inputStream = null; |
154 | 167 | |
155 | - if ($input instanceof StreamableInputInterface) { |
|
168 | + if ($input instanceof StreamableInputInterface) |
|
169 | + { |
|
156 | 170 | $inputStream = $input->getStream(); |
157 | 171 | } |
158 | 172 | |
159 | - if ($inputStream !== null && !@posix_isatty($inputStream) && false === getenv('SHELL_INTERACTIVE')) { |
|
173 | + if ($inputStream !== null && !@posix_isatty($inputStream) && false === getenv('SHELL_INTERACTIVE')) |
|
174 | + { |
|
160 | 175 | $input->setInteractive(false); |
161 | 176 | } |
162 | 177 | } |
@@ -169,10 +184,13 @@ discard block |
||
169 | 184 | default => $shellVerbosity = 0 |
170 | 185 | }; |
171 | 186 | |
172 | - if ($input->hasParameterOption(['--quiet', '-q'], true)) { |
|
187 | + if ($input->hasParameterOption(['--quiet', '-q'], true)) |
|
188 | + { |
|
173 | 189 | $output->setVerbosity(OutputInterface::VERBOSITY_QUIET); |
174 | 190 | $shellVerbosity = -1; |
175 | - } else { |
|
191 | + } |
|
192 | + else |
|
193 | + { |
|
176 | 194 | if ( |
177 | 195 | $input->hasParameterOption('-vvv', true) |
178 | 196 | || $input->hasParameterOption('--verbose=3', true) |
@@ -180,14 +198,16 @@ discard block |
||
180 | 198 | ) { |
181 | 199 | $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG); |
182 | 200 | $shellVerbosity = 3; |
183 | - } elseif ( |
|
201 | + } |
|
202 | + elseif ( |
|
184 | 203 | $input->hasParameterOption('-vv', true) |
185 | 204 | || $input->hasParameterOption('--verbose=2', true) |
186 | 205 | || 2 === $input->getParameterOption('--verbose', false, true) |
187 | 206 | ) { |
188 | 207 | $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE); |
189 | 208 | $shellVerbosity = 2; |
190 | - } elseif ( |
|
209 | + } |
|
210 | + elseif ( |
|
191 | 211 | $input->hasParameterOption('-v', true) |
192 | 212 | || $input->hasParameterOption('--verbose=1', true) |
193 | 213 | || $input->hasParameterOption('--verbose', true) |
@@ -198,7 +218,8 @@ discard block |
||
198 | 218 | } |
199 | 219 | } |
200 | 220 | |
201 | - if (-1 === $shellVerbosity) { |
|
221 | + if (-1 === $shellVerbosity) |
|
222 | + { |
|
202 | 223 | $input->setInteractive(false); |
203 | 224 | } |
204 | 225 |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | #[Proxy] private readonly ContainerInterface $container = new Container(), |
39 | 39 | private readonly ScopeInterface $scope = new Container(), |
40 | 40 | private readonly ?EventDispatcherInterface $dispatcher = null, |
41 | - ) { |
|
41 | + ){ |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -63,14 +63,14 @@ discard block |
||
63 | 63 | */ |
64 | 64 | public function run( |
65 | 65 | ?string $command, |
66 | - array|InputInterface $input = [], |
|
66 | + array | InputInterface $input = [], |
|
67 | 67 | OutputInterface $output = new BufferedOutput(), |
68 | 68 | ): CommandOutput { |
69 | 69 | $input = \is_array($input) ? new ArrayInput($input) : $input; |
70 | 70 | |
71 | 71 | $this->configureIO($input, $output); |
72 | 72 | |
73 | - if ($command !== null) { |
|
73 | + if ($command !== null){ |
|
74 | 74 | $input = new InputProxy($input, ['firstArgument' => $command]); |
75 | 75 | } |
76 | 76 | |
@@ -97,18 +97,18 @@ discard block |
||
97 | 97 | */ |
98 | 98 | public function getApplication(): Application |
99 | 99 | { |
100 | - if ($this->application !== null) { |
|
100 | + if ($this->application !== null){ |
|
101 | 101 | return $this->application; |
102 | 102 | } |
103 | 103 | |
104 | 104 | $this->application = new Application($this->config->getName(), $this->config->getVersion()); |
105 | 105 | $this->application->setCatchExceptions(false); |
106 | 106 | $this->application->setAutoExit(false); |
107 | - if ($this->dispatcher instanceof SymfonyEventDispatcherInterface) { |
|
107 | + if ($this->dispatcher instanceof SymfonyEventDispatcherInterface){ |
|
108 | 108 | $this->application->setDispatcher($this->dispatcher); |
109 | 109 | } |
110 | 110 | |
111 | - if ($this->locator !== null) { |
|
111 | + if ($this->locator !== null){ |
|
112 | 112 | $this->addCommands($this->locator->locateCommands()); |
113 | 113 | } |
114 | 114 | |
@@ -128,13 +128,13 @@ discard block |
||
128 | 128 | { |
129 | 129 | $interceptors = $this->config->getInterceptors(); |
130 | 130 | |
131 | - foreach ($commands as $command) { |
|
132 | - if ($command instanceof Command) { |
|
131 | + foreach ($commands as $command){ |
|
132 | + if ($command instanceof Command){ |
|
133 | 133 | $command->setContainer($this->container); |
134 | 134 | $command->setInterceptors($interceptors); |
135 | 135 | } |
136 | 136 | |
137 | - if ($this->dispatcher !== null && $command instanceof EventDispatcherAwareInterface) { |
|
137 | + if ($this->dispatcher !== null && $command instanceof EventDispatcherAwareInterface){ |
|
138 | 138 | $command->setEventDispatcher($this->dispatcher); |
139 | 139 | } |
140 | 140 | |
@@ -149,22 +149,22 @@ discard block |
||
149 | 149 | */ |
150 | 150 | private function configureIO(InputInterface $input, OutputInterface $output): void |
151 | 151 | { |
152 | - if ($input->hasParameterOption(['--ansi'], true)) { |
|
152 | + if ($input->hasParameterOption(['--ansi'], true)){ |
|
153 | 153 | $output->setDecorated(true); |
154 | - } elseif ($input->hasParameterOption(['--no-ansi'], true)) { |
|
154 | + } elseif ($input->hasParameterOption(['--no-ansi'], true)){ |
|
155 | 155 | $output->setDecorated(false); |
156 | 156 | } |
157 | 157 | |
158 | - if ($input->hasParameterOption(['--no-interaction', '-n'], true)) { |
|
158 | + if ($input->hasParameterOption(['--no-interaction', '-n'], true)){ |
|
159 | 159 | $input->setInteractive(false); |
160 | - } elseif (\function_exists('posix_isatty')) { |
|
160 | + } elseif (\function_exists('posix_isatty')){ |
|
161 | 161 | $inputStream = null; |
162 | 162 | |
163 | - if ($input instanceof StreamableInputInterface) { |
|
163 | + if ($input instanceof StreamableInputInterface){ |
|
164 | 164 | $inputStream = $input->getStream(); |
165 | 165 | } |
166 | 166 | |
167 | - if ($inputStream !== null && !@posix_isatty($inputStream) && false === getenv('SHELL_INTERACTIVE')) { |
|
167 | + if ($inputStream !== null && !@posix_isatty($inputStream) && false === getenv('SHELL_INTERACTIVE')){ |
|
168 | 168 | $input->setInteractive(false); |
169 | 169 | } |
170 | 170 | } |
@@ -177,22 +177,22 @@ discard block |
||
177 | 177 | default => $shellVerbosity = 0 |
178 | 178 | }; |
179 | 179 | |
180 | - if ($input->hasParameterOption(['--quiet', '-q'], true)) { |
|
180 | + if ($input->hasParameterOption(['--quiet', '-q'], true)){ |
|
181 | 181 | $output->setVerbosity(OutputInterface::VERBOSITY_QUIET); |
182 | 182 | $shellVerbosity = -1; |
183 | - } else { |
|
183 | + }else{ |
|
184 | 184 | if ( |
185 | 185 | $input->hasParameterOption('-vvv', true) |
186 | 186 | || $input->hasParameterOption('--verbose=3', true) |
187 | 187 | || 3 === $input->getParameterOption('--verbose', false, true) |
188 | - ) { |
|
188 | + ){ |
|
189 | 189 | $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG); |
190 | 190 | $shellVerbosity = 3; |
191 | 191 | } elseif ( |
192 | 192 | $input->hasParameterOption('-vv', true) |
193 | 193 | || $input->hasParameterOption('--verbose=2', true) |
194 | 194 | || 2 === $input->getParameterOption('--verbose', false, true) |
195 | - ) { |
|
195 | + ){ |
|
196 | 196 | $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE); |
197 | 197 | $shellVerbosity = 2; |
198 | 198 | } elseif ( |
@@ -200,17 +200,17 @@ discard block |
||
200 | 200 | || $input->hasParameterOption('--verbose=1', true) |
201 | 201 | || $input->hasParameterOption('--verbose', true) |
202 | 202 | || $input->getParameterOption('--verbose', false, true) |
203 | - ) { |
|
203 | + ){ |
|
204 | 204 | $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE); |
205 | 205 | $shellVerbosity = 1; |
206 | 206 | } |
207 | 207 | } |
208 | 208 | |
209 | - if (-1 === $shellVerbosity) { |
|
209 | + if (-1 === $shellVerbosity){ |
|
210 | 210 | $input->setInteractive(false); |
211 | 211 | } |
212 | 212 | |
213 | - \putenv('SHELL_VERBOSITY=' . $shellVerbosity); |
|
213 | + \putenv('SHELL_VERBOSITY='.$shellVerbosity); |
|
214 | 214 | $_ENV['SHELL_VERBOSITY'] = $shellVerbosity; |
215 | 215 | $_SERVER['SHELL_VERBOSITY'] = $shellVerbosity; |
216 | 216 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | ->method('getArgument') |
38 | 38 | ->willReturnOnConsecutiveCalls(5, 'foo', ['foo', 'bar'], 0.5, true); |
39 | 39 | |
40 | - $command = new #[AsCommand('foo')] class extends Command { |
|
40 | + $command = new #[AsCommand('foo')] class extends Command{ |
|
41 | 41 | #[Argument] |
42 | 42 | public int $intVal; |
43 | 43 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | ->expects($this->never()) |
77 | 77 | ->method('getArgument'); |
78 | 78 | |
79 | - $command = new #[AsCommand('foo')] class extends Command { |
|
79 | + $command = new #[AsCommand('foo')] class extends Command{ |
|
80 | 80 | #[Argument] |
81 | 81 | public int $arg; |
82 | 82 | }; |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | ->method('getOption') |
100 | 100 | ->willReturnOnConsecutiveCalls(5, 'foo', ['foo', 'bar'], 0.5, true, true); |
101 | 101 | |
102 | - $command = new #[AsCommand('foo')] class extends Command { |
|
102 | + $command = new #[AsCommand('foo')] class extends Command{ |
|
103 | 103 | #[Option(mode: InputOption::VALUE_REQUIRED)] |
104 | 104 | public int $intVal; |
105 | 105 | |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | ->method('getOption') |
143 | 143 | ->willReturnOnConsecutiveCalls(1, null, 0); |
144 | 144 | |
145 | - $command = new #[AsCommand('foo')] class extends Command { |
|
145 | + $command = new #[AsCommand('foo')] class extends Command{ |
|
146 | 146 | #[Option(mode: InputOption::VALUE_REQUIRED)] |
147 | 147 | public Status $required; |
148 | 148 | |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | $input->expects($this->once())->method('hasOption')->willReturn(true); |
167 | 167 | $input->expects($this->once())->method('getOption')->willReturn('foo'); |
168 | 168 | |
169 | - $command = new #[AsCommand('foo')] class extends Command { |
|
169 | + $command = new #[AsCommand('foo')] class extends Command{ |
|
170 | 170 | #[Option] |
171 | 171 | public Status $status; |
172 | 172 | }; |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | ->expects($this->never()) |
189 | 189 | ->method('getOption'); |
190 | 190 | |
191 | - $command = new #[AsCommand('foo')] class extends Command { |
|
191 | + $command = new #[AsCommand('foo')] class extends Command{ |
|
192 | 192 | #[Option(mode: InputOption::VALUE_REQUIRED)] |
193 | 193 | public int $option; |
194 | 194 | }; |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | ->method('getOption') |
213 | 213 | ->willReturn(null); |
214 | 214 | |
215 | - $command = new #[AsCommand('foo')] class extends Command { |
|
215 | + $command = new #[AsCommand('foo')] class extends Command{ |
|
216 | 216 | #[Option(mode: InputOption::VALUE_REQUIRED)] |
217 | 217 | public int $option; |
218 | 218 | }; |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | ->method('getOption') |
236 | 236 | ->willReturn(null); |
237 | 237 | |
238 | - $command = new #[AsCommand('foo')] class extends Command { |
|
238 | + $command = new #[AsCommand('foo')] class extends Command{ |
|
239 | 239 | #[Option(mode: InputOption::VALUE_REQUIRED)] |
240 | 240 | public ?int $intVal; |
241 | 241 | }; |
@@ -37,7 +37,8 @@ discard block |
||
37 | 37 | ->method('getArgument') |
38 | 38 | ->willReturnOnConsecutiveCalls(5, 'foo', ['foo', 'bar'], 0.5, true); |
39 | 39 | |
40 | - $command = new #[AsCommand('foo')] class extends Command { |
|
40 | + $command = new #[AsCommand('foo')] class extends Command |
|
41 | + { |
|
41 | 42 | #[Argument] |
42 | 43 | public int $intVal; |
43 | 44 | |
@@ -76,7 +77,8 @@ discard block |
||
76 | 77 | ->expects($this->never()) |
77 | 78 | ->method('getArgument'); |
78 | 79 | |
79 | - $command = new #[AsCommand('foo')] class extends Command { |
|
80 | + $command = new #[AsCommand('foo')] class extends Command |
|
81 | + { |
|
80 | 82 | #[Argument] |
81 | 83 | public int $arg; |
82 | 84 | }; |
@@ -99,7 +101,8 @@ discard block |
||
99 | 101 | ->method('getOption') |
100 | 102 | ->willReturnOnConsecutiveCalls(5, 'foo', ['foo', 'bar'], 0.5, true, true); |
101 | 103 | |
102 | - $command = new #[AsCommand('foo')] class extends Command { |
|
104 | + $command = new #[AsCommand('foo')] class extends Command |
|
105 | + { |
|
103 | 106 | #[Option(mode: InputOption::VALUE_REQUIRED)] |
104 | 107 | public int $intVal; |
105 | 108 | |
@@ -142,7 +145,8 @@ discard block |
||
142 | 145 | ->method('getOption') |
143 | 146 | ->willReturnOnConsecutiveCalls(1, null, 0); |
144 | 147 | |
145 | - $command = new #[AsCommand('foo')] class extends Command { |
|
148 | + $command = new #[AsCommand('foo')] class extends Command |
|
149 | + { |
|
146 | 150 | #[Option(mode: InputOption::VALUE_REQUIRED)] |
147 | 151 | public Status $required; |
148 | 152 | |
@@ -166,7 +170,8 @@ discard block |
||
166 | 170 | $input->expects($this->once())->method('hasOption')->willReturn(true); |
167 | 171 | $input->expects($this->once())->method('getOption')->willReturn('foo'); |
168 | 172 | |
169 | - $command = new #[AsCommand('foo')] class extends Command { |
|
173 | + $command = new #[AsCommand('foo')] class extends Command |
|
174 | + { |
|
170 | 175 | #[Option] |
171 | 176 | public Status $status; |
172 | 177 | }; |
@@ -188,7 +193,8 @@ discard block |
||
188 | 193 | ->expects($this->never()) |
189 | 194 | ->method('getOption'); |
190 | 195 | |
191 | - $command = new #[AsCommand('foo')] class extends Command { |
|
196 | + $command = new #[AsCommand('foo')] class extends Command |
|
197 | + { |
|
192 | 198 | #[Option(mode: InputOption::VALUE_REQUIRED)] |
193 | 199 | public int $option; |
194 | 200 | }; |
@@ -212,7 +218,8 @@ discard block |
||
212 | 218 | ->method('getOption') |
213 | 219 | ->willReturn(null); |
214 | 220 | |
215 | - $command = new #[AsCommand('foo')] class extends Command { |
|
221 | + $command = new #[AsCommand('foo')] class extends Command |
|
222 | + { |
|
216 | 223 | #[Option(mode: InputOption::VALUE_REQUIRED)] |
217 | 224 | public int $option; |
218 | 225 | }; |
@@ -235,7 +242,8 @@ discard block |
||
235 | 242 | ->method('getOption') |
236 | 243 | ->willReturn(null); |
237 | 244 | |
238 | - $command = new #[AsCommand('foo')] class extends Command { |
|
245 | + $command = new #[AsCommand('foo')] class extends Command |
|
246 | + { |
|
239 | 247 | #[Option(mode: InputOption::VALUE_REQUIRED)] |
240 | 248 | public ?int $intVal; |
241 | 249 | }; |
@@ -103,7 +103,7 @@ |
||
103 | 103 | |
104 | 104 | $uri = $router->uri('test:id', [ |
105 | 105 | 'id' => 100, |
106 | - 'title' => new class implements \Stringable { |
|
106 | + 'title' => new class implements \Stringable{ |
|
107 | 107 | public function __toString() |
108 | 108 | { |
109 | 109 | return 'hello-world'; |