@@ -27,29 +27,29 @@ discard block |
||
| 27 | 27 | MagicCallTrait::class, |
| 28 | 28 | ] : []; |
| 29 | 29 | |
| 30 | - if (\str_contains($className, '\\')) { |
|
| 30 | + if (\str_contains($className, '\\')){ |
|
| 31 | 31 | $classShortName = \substr($className, \strrpos($className, '\\') + 1); |
| 32 | - $classNamespaceStr = 'namespace ' . \substr($className, 0, \strrpos($className, '\\')) . ';'; |
|
| 33 | - } else { |
|
| 32 | + $classNamespaceStr = 'namespace '.\substr($className, 0, \strrpos($className, '\\')).';'; |
|
| 33 | + }else{ |
|
| 34 | 34 | $classShortName = $className; |
| 35 | 35 | $classNamespaceStr = ''; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | $interface = $type->getName(); |
| 39 | 39 | $classBody = []; |
| 40 | - foreach ($type->getMethods() as $method) { |
|
| 41 | - if ($method->isConstructor()) { |
|
| 40 | + foreach ($type->getMethods() as $method){ |
|
| 41 | + if ($method->isConstructor()){ |
|
| 42 | 42 | throw new \LogicException('Constructor is not allowed in a proxy.'); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - if ($method->isDestructor()) { |
|
| 45 | + if ($method->isDestructor()){ |
|
| 46 | 46 | $classBody[] = self::renderMethod($method); |
| 47 | 47 | continue; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | $hasRefs = false; |
| 51 | 51 | $return = $method->hasReturnType() && (string)$method->getReturnType() === 'void' ? '' : 'return '; |
| 52 | - $call = ($method->isStatic() ? '::' : '->') . $method->getName(); |
|
| 52 | + $call = ($method->isStatic() ? '::' : '->').$method->getName(); |
|
| 53 | 53 | $context = $method->isStatic() ? 'null' : '$this->__container_proxy_context'; |
| 54 | 54 | $containerStr = match (false) { |
| 55 | 55 | $attachContainer => 'null', |
@@ -69,12 +69,12 @@ discard block |
||
| 69 | 69 | PHP; |
| 70 | 70 | |
| 71 | 71 | $args = []; |
| 72 | - foreach ($method->getParameters() as $param) { |
|
| 72 | + foreach ($method->getParameters() as $param){ |
|
| 73 | 73 | $hasRefs = $hasRefs || $param->isPassedByReference(); |
| 74 | - $args[] = ($param->isVariadic() ? '...' : '') . '$' . $param->getName(); |
|
| 74 | + $args[] = ($param->isVariadic() ? '...' : '').'$'.$param->getName(); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - if (!$hasRefs && !$method->isVariadic()) { |
|
| 77 | + if (!$hasRefs && !$method->isVariadic()){ |
|
| 78 | 78 | $classBody[] = self::renderMethod( |
| 79 | 79 | $method, |
| 80 | 80 | <<<PHP |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | |
| 87 | 87 | $argsStr = \implode(', ', $args); |
| 88 | 88 | |
| 89 | - if ($method->isVariadic()) { |
|
| 89 | + if ($method->isVariadic()){ |
|
| 90 | 90 | $classBody[] = self::renderMethod( |
| 91 | 91 | $method, |
| 92 | 92 | <<<PHP |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | $traitsStr = $traits === [] ? '' : \implode( |
| 110 | 110 | "\n ", |
| 111 | - \array_map(fn (string $trait): string => 'use \\' . \ltrim($trait, '\\') . ';', $traits) |
|
| 111 | + \array_map(fn (string $trait) : string => 'use \\'.\ltrim($trait, '\\').';', $traits) |
|
| 112 | 112 | ); |
| 113 | 113 | return <<<PHP |
| 114 | 114 | $classNamespaceStr |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | $m->getName(), |
| 132 | 132 | \implode(', ', \array_map(self::renderParameter(...), $m->getParameters())), |
| 133 | 133 | $m->hasReturnType() |
| 134 | - ? ': ' . self::renderParameterTypes($m->getReturnType(), $m->getDeclaringClass()) |
|
| 134 | + ? ': '.self::renderParameterTypes($m->getReturnType(), $m->getDeclaringClass()) |
|
| 135 | 135 | : '', |
| 136 | 136 | $body, |
| 137 | 137 | ); |
@@ -145,8 +145,8 @@ discard block |
||
| 145 | 145 | $param->hasType() ? 'mixed' : '', |
| 146 | 146 | $param->isPassedByReference() ? '&' : '', |
| 147 | 147 | $param->isVariadic() ? '...' : '', |
| 148 | - '$' . $param->getName(), |
|
| 149 | - $param->isOptional() && !$param->isVariadic() ? ' = ' . self::renderDefaultValue($param) : '', |
|
| 148 | + '$'.$param->getName(), |
|
| 149 | + $param->isOptional() && !$param->isVariadic() ? ' = '.self::renderDefaultValue($param) : '', |
|
| 150 | 150 | ), |
| 151 | 151 | ' ' |
| 152 | 152 | ); |
@@ -154,8 +154,8 @@ discard block |
||
| 154 | 154 | |
| 155 | 155 | public static function renderParameterTypes(\ReflectionType $types, \ReflectionClass $class): string |
| 156 | 156 | { |
| 157 | - if ($types instanceof \ReflectionNamedType) { |
|
| 158 | - return ($types->allowsNull() && $types->getName() !== 'mixed' ? '?' : '') . ($types->isBuiltin() |
|
| 157 | + if ($types instanceof \ReflectionNamedType){ |
|
| 158 | + return ($types->allowsNull() && $types->getName() !== 'mixed' ? '?' : '').($types->isBuiltin() |
|
| 159 | 159 | ? $types->getName() |
| 160 | 160 | : self::normalizeClassType($types, $class)); |
| 161 | 161 | } |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | }; |
| 168 | 168 | |
| 169 | 169 | $result = []; |
| 170 | - foreach ($types as $type) { |
|
| 170 | + foreach ($types as $type){ |
|
| 171 | 171 | $result[] = $type->isBuiltin() |
| 172 | 172 | ? $type->getName() |
| 173 | 173 | : self::normalizeClassType($type, $class); |
@@ -178,12 +178,12 @@ discard block |
||
| 178 | 178 | |
| 179 | 179 | public static function renderDefaultValue(\ReflectionParameter $param): string |
| 180 | 180 | { |
| 181 | - if ($param->isDefaultValueConstant()) { |
|
| 181 | + if ($param->isDefaultValueConstant()){ |
|
| 182 | 182 | $result = $param->getDefaultValueConstantName(); |
| 183 | 183 | |
| 184 | - return \explode('::', (string) $result)[0] === 'self' |
|
| 184 | + return \explode('::', (string)$result)[0] === 'self' |
|
| 185 | 185 | ? $result |
| 186 | - : '\\' . $result; |
|
| 186 | + : '\\'.$result; |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | $cut = self::cutDefaultValue($param); |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | |
| 196 | 196 | public static function normalizeClassType(\ReflectionNamedType $type, \ReflectionClass $class): string |
| 197 | 197 | { |
| 198 | - return '\\' . ($type->getName() === 'self' ? $class->getName() : $type->getName()); |
|
| 198 | + return '\\'.($type->getName() === 'self' ? $class->getName() : $type->getName()); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | private static function cutDefaultValue(\ReflectionParameter $param): string |
@@ -27,22 +27,28 @@ discard block |
||
| 27 | 27 | MagicCallTrait::class, |
| 28 | 28 | ] : []; |
| 29 | 29 | |
| 30 | - if (\str_contains($className, '\\')) { |
|
| 30 | + if (\str_contains($className, '\\')) |
|
| 31 | + { |
|
| 31 | 32 | $classShortName = \substr($className, \strrpos($className, '\\') + 1); |
| 32 | 33 | $classNamespaceStr = 'namespace ' . \substr($className, 0, \strrpos($className, '\\')) . ';'; |
| 33 | - } else { |
|
| 34 | + } |
|
| 35 | + else |
|
| 36 | + { |
|
| 34 | 37 | $classShortName = $className; |
| 35 | 38 | $classNamespaceStr = ''; |
| 36 | 39 | } |
| 37 | 40 | |
| 38 | 41 | $interface = $type->getName(); |
| 39 | 42 | $classBody = []; |
| 40 | - foreach ($type->getMethods() as $method) { |
|
| 41 | - if ($method->isConstructor()) { |
|
| 43 | + foreach ($type->getMethods() as $method) |
|
| 44 | + { |
|
| 45 | + if ($method->isConstructor()) |
|
| 46 | + { |
|
| 42 | 47 | throw new \LogicException('Constructor is not allowed in a proxy.'); |
| 43 | 48 | } |
| 44 | 49 | |
| 45 | - if ($method->isDestructor()) { |
|
| 50 | + if ($method->isDestructor()) |
|
| 51 | + { |
|
| 46 | 52 | $classBody[] = self::renderMethod($method); |
| 47 | 53 | continue; |
| 48 | 54 | } |
@@ -69,12 +75,14 @@ discard block |
||
| 69 | 75 | PHP; |
| 70 | 76 | |
| 71 | 77 | $args = []; |
| 72 | - foreach ($method->getParameters() as $param) { |
|
| 78 | + foreach ($method->getParameters() as $param) |
|
| 79 | + { |
|
| 73 | 80 | $hasRefs = $hasRefs || $param->isPassedByReference(); |
| 74 | 81 | $args[] = ($param->isVariadic() ? '...' : '') . '$' . $param->getName(); |
| 75 | 82 | } |
| 76 | 83 | |
| 77 | - if (!$hasRefs && !$method->isVariadic()) { |
|
| 84 | + if (!$hasRefs && !$method->isVariadic()) |
|
| 85 | + { |
|
| 78 | 86 | $classBody[] = self::renderMethod( |
| 79 | 87 | $method, |
| 80 | 88 | <<<PHP |
@@ -86,7 +94,8 @@ discard block |
||
| 86 | 94 | |
| 87 | 95 | $argsStr = \implode(', ', $args); |
| 88 | 96 | |
| 89 | - if ($method->isVariadic()) { |
|
| 97 | + if ($method->isVariadic()) |
|
| 98 | + { |
|
| 90 | 99 | $classBody[] = self::renderMethod( |
| 91 | 100 | $method, |
| 92 | 101 | <<<PHP |
@@ -154,7 +163,8 @@ discard block |
||
| 154 | 163 | |
| 155 | 164 | public static function renderParameterTypes(\ReflectionType $types, \ReflectionClass $class): string |
| 156 | 165 | { |
| 157 | - if ($types instanceof \ReflectionNamedType) { |
|
| 166 | + if ($types instanceof \ReflectionNamedType) |
|
| 167 | + { |
|
| 158 | 168 | return ($types->allowsNull() && $types->getName() !== 'mixed' ? '?' : '') . ($types->isBuiltin() |
| 159 | 169 | ? $types->getName() |
| 160 | 170 | : self::normalizeClassType($types, $class)); |
@@ -167,7 +177,8 @@ discard block |
||
| 167 | 177 | }; |
| 168 | 178 | |
| 169 | 179 | $result = []; |
| 170 | - foreach ($types as $type) { |
|
| 180 | + foreach ($types as $type) |
|
| 181 | + { |
|
| 171 | 182 | $result[] = $type->isBuiltin() |
| 172 | 183 | ? $type->getName() |
| 173 | 184 | : self::normalizeClassType($type, $class); |
@@ -178,7 +189,8 @@ discard block |
||
| 178 | 189 | |
| 179 | 190 | public static function renderDefaultValue(\ReflectionParameter $param): string |
| 180 | 191 | { |
| 181 | - if ($param->isDefaultValueConstant()) { |
|
| 192 | + if ($param->isDefaultValueConstant()) |
|
| 193 | + { |
|
| 182 | 194 | $result = $param->getDefaultValueConstantName(); |
| 183 | 195 | |
| 184 | 196 | return \explode('::', (string) $result)[0] === 'self' |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | private readonly Config $config, |
| 20 | 20 | private array $objects = [], |
| 21 | 21 | private readonly Options $options = new Options(), |
| 22 | - ) { |
|
| 22 | + ){ |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | public function set(string $name, object $value): void |
@@ -14,16 +14,16 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | public function __construct( |
| 16 | 16 | private readonly DateTimeFactoryInterface $factory = new DateTimeFactory() |
| 17 | - ) { |
|
| 17 | + ){ |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | public function create(mixed $duration): \DateInterval |
| 21 | 21 | { |
| 22 | - try { |
|
| 22 | + try{ |
|
| 23 | 23 | return $this->createOrFail($duration); |
| 24 | - } catch (\InvalidArgumentException $e) { |
|
| 24 | + }catch (\InvalidArgumentException $e){ |
|
| 25 | 25 | throw $e; |
| 26 | - } catch (\Throwable $e) { |
|
| 26 | + }catch (\Throwable $e){ |
|
| 27 | 27 | throw new \InvalidArgumentException($e->getMessage(), (int)$e->getCode(), $e); |
| 28 | 28 | } |
| 29 | 29 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | $duration instanceof \DateInterval => $duration, |
| 45 | 45 | $duration instanceof \DateTimeInterface => $this->factory->now()->diff($duration), |
| 46 | 46 | \is_string($duration) => new \DateInterval($duration), |
| 47 | - \is_int($duration) => new \DateInterval('PT' . $duration . 'S'), |
|
| 47 | + \is_int($duration) => new \DateInterval('PT'.$duration.'S'), |
|
| 48 | 48 | $duration === null => new \DateInterval('PT0S'), |
| 49 | 49 | default => throw new \InvalidArgumentException( |
| 50 | 50 | \sprintf(self::ERROR_INVALID_INTERVAL_TYPE, \get_debug_type($duration)) |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | string $privateKey, |
| 26 | 26 | private readonly string $domain, |
| 27 | 27 | private readonly ?string $prefix = null |
| 28 | - ) { |
|
| 28 | + ){ |
|
| 29 | 29 | $this->assertCloudFrontAvailable(); |
| 30 | 30 | $this->factory = new AmazonUriFactory(); |
| 31 | 31 | $this->signer = new UrlSigner($keyPairId, $privateKey); |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | protected function assertCloudFrontAvailable(): void |
| 48 | 48 | { |
| 49 | - if (\class_exists(UrlSigner::class)) { |
|
| 49 | + if (\class_exists(UrlSigner::class)){ |
|
| 50 | 50 | return; |
| 51 | 51 | } |
| 52 | 52 | |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | private readonly S3ClientInterface $client, |
| 20 | 20 | private readonly string $bucket, |
| 21 | 21 | private readonly ?string $prefix = null |
| 22 | - ) { |
|
| 22 | + ){ |
|
| 23 | 23 | parent::__construct(); |
| 24 | 24 | } |
| 25 | 25 | |
@@ -14,13 +14,13 @@ |
||
| 14 | 14 | public function configure(Command $command, \ReflectionClass $reflection): void |
| 15 | 15 | { |
| 16 | 16 | $command->setName($reflection->getConstant('NAME')); |
| 17 | - $command->setDescription((string) $reflection->getConstant('DESCRIPTION')); |
|
| 17 | + $command->setDescription((string)$reflection->getConstant('DESCRIPTION')); |
|
| 18 | 18 | |
| 19 | - foreach ($reflection->getMethod('defineOptions')->invoke($command) as $option) { |
|
| 19 | + foreach ($reflection->getMethod('defineOptions')->invoke($command) as $option){ |
|
| 20 | 20 | \call_user_func_array($command->addOption(...), $option); |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - foreach ($reflection->getMethod('defineArguments')->invoke($command) as $argument) { |
|
| 23 | + foreach ($reflection->getMethod('defineArguments')->invoke($command) as $argument){ |
|
| 24 | 24 | \call_user_func_array($command->addArgument(...), $argument); |
| 25 | 25 | } |
| 26 | 26 | } |
@@ -16,11 +16,13 @@ |
||
| 16 | 16 | $command->setName($reflection->getConstant('NAME')); |
| 17 | 17 | $command->setDescription((string) $reflection->getConstant('DESCRIPTION')); |
| 18 | 18 | |
| 19 | - foreach ($reflection->getMethod('defineOptions')->invoke($command) as $option) { |
|
| 19 | + foreach ($reflection->getMethod('defineOptions')->invoke($command) as $option) |
|
| 20 | + { |
|
| 20 | 21 | \call_user_func_array($command->addOption(...), $option); |
| 21 | 22 | } |
| 22 | 23 | |
| 23 | - foreach ($reflection->getMethod('defineArguments')->invoke($command) as $argument) { |
|
| 24 | + foreach ($reflection->getMethod('defineArguments')->invoke($command) as $argument) |
|
| 25 | + { |
|
| 24 | 26 | \call_user_func_array($command->addArgument(...), $argument); |
| 25 | 27 | } |
| 26 | 28 | } |
@@ -24,8 +24,8 @@ discard block |
||
| 24 | 24 | { |
| 25 | 25 | $name = $this->parseName($signature); |
| 26 | 26 | |
| 27 | - if (\preg_match_all('/\{\s*(.*?)\s*\}/', $signature, $matches)) { |
|
| 28 | - if (\count($matches[1])) { |
|
| 27 | + if (\preg_match_all('/\{\s*(.*?)\s*\}/', $signature, $matches)){ |
|
| 28 | + if (\count($matches[1])){ |
|
| 29 | 29 | return new CommandDefinition($name, ...$this->parseParameters($matches[1])); |
| 30 | 30 | } |
| 31 | 31 | } |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | private function parseName(string $signature): string |
| 42 | 42 | { |
| 43 | - if (!\preg_match('/\S+/', $signature, $matches)) { |
|
| 43 | + if (!\preg_match('/\S+/', $signature, $matches)){ |
|
| 44 | 44 | throw new InvalidArgumentException('Unable to determine command name from signature.'); |
| 45 | 45 | } |
| 46 | 46 | |
@@ -57,10 +57,10 @@ discard block |
||
| 57 | 57 | $arguments = []; |
| 58 | 58 | $options = []; |
| 59 | 59 | |
| 60 | - foreach ($tokens as $token) { |
|
| 61 | - if (\preg_match('/-{2,}(.*)/', (string) $token, $matches)) { |
|
| 60 | + foreach ($tokens as $token){ |
|
| 61 | + if (\preg_match('/-{2,}(.*)/', (string)$token, $matches)){ |
|
| 62 | 62 | $options[] = $this->parseOption($matches[1]); |
| 63 | - } else { |
|
| 63 | + }else{ |
|
| 64 | 64 | $arguments[] = $this->parseArgument($token); |
| 65 | 65 | } |
| 66 | 66 | } |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | $matches = \preg_split('/\s*\|\s*/', $token, 2); |
| 123 | 123 | $shortcut = null; |
| 124 | 124 | |
| 125 | - if (isset($matches[1])) { |
|
| 125 | + if (isset($matches[1])){ |
|
| 126 | 126 | [$shortcut, $token] = $matches; |
| 127 | 127 | } |
| 128 | 128 | |
@@ -24,8 +24,10 @@ discard block |
||
| 24 | 24 | { |
| 25 | 25 | $name = $this->parseName($signature); |
| 26 | 26 | |
| 27 | - if (\preg_match_all('/\{\s*(.*?)\s*\}/', $signature, $matches)) { |
|
| 28 | - if (\count($matches[1])) { |
|
| 27 | + if (\preg_match_all('/\{\s*(.*?)\s*\}/', $signature, $matches)) |
|
| 28 | + { |
|
| 29 | + if (\count($matches[1])) |
|
| 30 | + { |
|
| 29 | 31 | return new CommandDefinition($name, ...$this->parseParameters($matches[1])); |
| 30 | 32 | } |
| 31 | 33 | } |
@@ -40,7 +42,8 @@ discard block |
||
| 40 | 42 | */ |
| 41 | 43 | private function parseName(string $signature): string |
| 42 | 44 | { |
| 43 | - if (!\preg_match('/\S+/', $signature, $matches)) { |
|
| 45 | + if (!\preg_match('/\S+/', $signature, $matches)) |
|
| 46 | + { |
|
| 44 | 47 | throw new InvalidArgumentException('Unable to determine command name from signature.'); |
| 45 | 48 | } |
| 46 | 49 | |
@@ -57,10 +60,14 @@ discard block |
||
| 57 | 60 | $arguments = []; |
| 58 | 61 | $options = []; |
| 59 | 62 | |
| 60 | - foreach ($tokens as $token) { |
|
| 61 | - if (\preg_match('/-{2,}(.*)/', (string) $token, $matches)) { |
|
| 63 | + foreach ($tokens as $token) |
|
| 64 | + { |
|
| 65 | + if (\preg_match('/-{2,}(.*)/', (string) $token, $matches)) |
|
| 66 | + { |
|
| 62 | 67 | $options[] = $this->parseOption($matches[1]); |
| 63 | - } else { |
|
| 68 | + } |
|
| 69 | + else |
|
| 70 | + { |
|
| 64 | 71 | $arguments[] = $this->parseArgument($token); |
| 65 | 72 | } |
| 66 | 73 | } |
@@ -122,7 +129,8 @@ discard block |
||
| 122 | 129 | $matches = \preg_split('/\s*\|\s*/', $token, 2); |
| 123 | 130 | $shortcut = null; |
| 124 | 131 | |
| 125 | - if (isset($matches[1])) { |
|
| 132 | + if (isset($matches[1])) |
|
| 133 | + { |
|
| 126 | 134 | [$shortcut, $token] = $matches; |
| 127 | 135 | } |
| 128 | 136 | |