@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | { |
| 71 | 71 | // 1) Can not parse internal classes |
| 72 | 72 | // 2) Anonymous classes don't support attributes (PHP semantic) |
| 73 | - if ($class->isInternal() || $class->isAnonymous()) { |
|
| 73 | + if ($class->isInternal() || $class->isAnonymous()){ |
|
| 74 | 74 | return []; |
| 75 | 75 | } |
| 76 | 76 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | protected function getFunctionAttributes(\ReflectionFunctionAbstract $function, ?string $name): iterable |
| 86 | 86 | { |
| 87 | 87 | // Can not parse internal functions |
| 88 | - if ($function->isInternal()) { |
|
| 88 | + if ($function->isInternal()){ |
|
| 89 | 89 | return []; |
| 90 | 90 | } |
| 91 | 91 | |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | $line = $function->getEndLine(); |
| 127 | 127 | |
| 128 | - if ($result = $attributes[$line] ?? null) { |
|
| 128 | + if ($result = $attributes[$line] ?? null){ |
|
| 129 | 129 | return $result; |
| 130 | 130 | } |
| 131 | 131 | |
@@ -150,8 +150,8 @@ discard block |
||
| 150 | 150 | * $ast->getEndLine(); // 2 (last significant character of a function) |
| 151 | 151 | * </code> |
| 152 | 152 | */ |
| 153 | - while ($line-- > 0) { |
|
| 154 | - if ($result = $attributes[$line] ?? null) { |
|
| 153 | + while ($line-- > 0){ |
|
| 154 | + if ($result = $attributes[$line] ?? null){ |
|
| 155 | 155 | return $result; |
| 156 | 156 | } |
| 157 | 157 | } |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | $class = $property->getDeclaringClass(); |
| 168 | 168 | |
| 169 | 169 | // Can not parse property of internal class |
| 170 | - if ($class->isInternal()) { |
|
| 170 | + if ($class->isInternal()){ |
|
| 171 | 171 | return []; |
| 172 | 172 | } |
| 173 | 173 | |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | $class = $const->getDeclaringClass(); |
| 185 | 185 | |
| 186 | 186 | // Can not parse internal classes |
| 187 | - if ($class->isInternal()) { |
|
| 187 | + if ($class->isInternal()){ |
|
| 188 | 188 | return []; |
| 189 | 189 | } |
| 190 | 190 | |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | $function = $param->getDeclaringFunction(); |
| 202 | 202 | |
| 203 | 203 | // Can not parse parameter of internal function |
| 204 | - if ($function->isInternal()) { |
|
| 204 | + if ($function->isInternal()){ |
|
| 205 | 205 | return []; |
| 206 | 206 | } |
| 207 | 207 | |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | */ |
| 218 | 218 | private function format(iterable $attributes): iterable |
| 219 | 219 | { |
| 220 | - foreach ($attributes as $prototype) { |
|
| 220 | + foreach ($attributes as $prototype){ |
|
| 221 | 221 | yield new \ReflectionClass($prototype->name) => $prototype->params; |
| 222 | 222 | } |
| 223 | 223 | } |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | */ |
| 232 | 232 | private function parseAttributes(string $file, int $context): array |
| 233 | 233 | { |
| 234 | - if (! isset($this->attributes[$file])) { |
|
| 234 | + if (!isset($this->attributes[$file])){ |
|
| 235 | 235 | $found = $this->parser->parse($file); |
| 236 | 236 | |
| 237 | 237 | $this->attributes[$file] = [ |
@@ -70,7 +70,8 @@ discard block |
||
| 70 | 70 | { |
| 71 | 71 | // 1) Can not parse internal classes |
| 72 | 72 | // 2) Anonymous classes don't support attributes (PHP semantic) |
| 73 | - if ($class->isInternal() || $class->isAnonymous()) { |
|
| 73 | + if ($class->isInternal() || $class->isAnonymous()) |
|
| 74 | + { |
|
| 74 | 75 | return []; |
| 75 | 76 | } |
| 76 | 77 | |
@@ -85,7 +86,8 @@ discard block |
||
| 85 | 86 | protected function getFunctionAttributes(\ReflectionFunctionAbstract $function, ?string $name): iterable |
| 86 | 87 | { |
| 87 | 88 | // Can not parse internal functions |
| 88 | - if ($function->isInternal()) { |
|
| 89 | + if ($function->isInternal()) |
|
| 90 | + { |
|
| 89 | 91 | return []; |
| 90 | 92 | } |
| 91 | 93 | |
@@ -125,7 +127,8 @@ discard block |
||
| 125 | 127 | */ |
| 126 | 128 | $line = $function->getEndLine(); |
| 127 | 129 | |
| 128 | - if ($result = $attributes[$line] ?? null) { |
|
| 130 | + if ($result = $attributes[$line] ?? null) |
|
| 131 | + { |
|
| 129 | 132 | return $result; |
| 130 | 133 | } |
| 131 | 134 | |
@@ -150,8 +153,10 @@ discard block |
||
| 150 | 153 | * $ast->getEndLine(); // 2 (last significant character of a function) |
| 151 | 154 | * </code> |
| 152 | 155 | */ |
| 153 | - while ($line-- > 0) { |
|
| 154 | - if ($result = $attributes[$line] ?? null) { |
|
| 156 | + while ($line-- > 0) |
|
| 157 | + { |
|
| 158 | + if ($result = $attributes[$line] ?? null) |
|
| 159 | + { |
|
| 155 | 160 | return $result; |
| 156 | 161 | } |
| 157 | 162 | } |
@@ -167,7 +172,8 @@ discard block |
||
| 167 | 172 | $class = $property->getDeclaringClass(); |
| 168 | 173 | |
| 169 | 174 | // Can not parse property of internal class |
| 170 | - if ($class->isInternal()) { |
|
| 175 | + if ($class->isInternal()) |
|
| 176 | + { |
|
| 171 | 177 | return []; |
| 172 | 178 | } |
| 173 | 179 | |
@@ -184,7 +190,8 @@ discard block |
||
| 184 | 190 | $class = $const->getDeclaringClass(); |
| 185 | 191 | |
| 186 | 192 | // Can not parse internal classes |
| 187 | - if ($class->isInternal()) { |
|
| 193 | + if ($class->isInternal()) |
|
| 194 | + { |
|
| 188 | 195 | return []; |
| 189 | 196 | } |
| 190 | 197 | |
@@ -201,7 +208,8 @@ discard block |
||
| 201 | 208 | $function = $param->getDeclaringFunction(); |
| 202 | 209 | |
| 203 | 210 | // Can not parse parameter of internal function |
| 204 | - if ($function->isInternal()) { |
|
| 211 | + if ($function->isInternal()) |
|
| 212 | + { |
|
| 205 | 213 | return []; |
| 206 | 214 | } |
| 207 | 215 | |
@@ -217,7 +225,8 @@ discard block |
||
| 217 | 225 | */ |
| 218 | 226 | private function format(iterable $attributes): iterable |
| 219 | 227 | { |
| 220 | - foreach ($attributes as $prototype) { |
|
| 228 | + foreach ($attributes as $prototype) |
|
| 229 | + { |
|
| 221 | 230 | yield new \ReflectionClass($prototype->name) => $prototype->params; |
| 222 | 231 | } |
| 223 | 232 | } |
@@ -231,7 +240,8 @@ discard block |
||
| 231 | 240 | */ |
| 232 | 241 | private function parseAttributes(string $file, int $context): array |
| 233 | 242 | { |
| 234 | - if (! isset($this->attributes[$file])) { |
|
| 243 | + if (! isset($this->attributes[$file])) |
|
| 244 | + { |
|
| 235 | 245 | $found = $this->parser->parse($file); |
| 236 | 246 | |
| 237 | 247 | $this->attributes[$file] = [ |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | private function checkAvailability(): void |
| 41 | 41 | { |
| 42 | - if (! self::isAvailable()) { |
|
| 42 | + if (!self::isAvailable()){ |
|
| 43 | 43 | throw new InitializationException('Requires the PHP >= 8.0'); |
| 44 | 44 | } |
| 45 | 45 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | private function format(iterable $attributes): iterable |
| 52 | 52 | { |
| 53 | - foreach ($attributes as $attribute) { |
|
| 53 | + foreach ($attributes as $attribute){ |
|
| 54 | 54 | yield new \ReflectionClass($attribute->getName()) => $attribute->getArguments(); |
| 55 | 55 | } |
| 56 | 56 | } |
@@ -39,7 +39,8 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | private function checkAvailability(): void |
| 41 | 41 | { |
| 42 | - if (! self::isAvailable()) { |
|
| 42 | + if (! self::isAvailable()) |
|
| 43 | + { |
|
| 43 | 44 | throw new InitializationException('Requires the PHP >= 8.0'); |
| 44 | 45 | } |
| 45 | 46 | } |
@@ -50,7 +51,8 @@ discard block |
||
| 50 | 51 | */ |
| 51 | 52 | private function format(iterable $attributes): iterable |
| 52 | 53 | { |
| 53 | - foreach ($attributes as $attribute) { |
|
| 54 | + foreach ($attributes as $attribute) |
|
| 55 | + { |
|
| 54 | 56 | yield new \ReflectionClass($attribute->getName()) => $attribute->getArguments(); |
| 55 | 57 | } |
| 56 | 58 | } |
@@ -10,7 +10,7 @@ |
||
| 10 | 10 | declare(strict_types=1); |
| 11 | 11 | |
| 12 | 12 | namespace Doctrine\Common\Annotations { |
| 13 | - if (! \interface_exists('NamedArgumentConstructorAnnotation')) { |
|
| 14 | - interface NamedArgumentConstructorAnnotation {} |
|
| 13 | + if (!\interface_exists('NamedArgumentConstructorAnnotation')){ |
|
| 14 | + interface NamedArgumentConstructorAnnotation{} |
|
| 15 | 15 | } |
| 16 | 16 | } |
| 17 | 17 | \ No newline at end of file |
@@ -10,7 +10,10 @@ |
||
| 10 | 10 | declare(strict_types=1); |
| 11 | 11 | |
| 12 | 12 | namespace Doctrine\Common\Annotations { |
| 13 | - if (! \interface_exists('NamedArgumentConstructorAnnotation')) { |
|
| 14 | - interface NamedArgumentConstructorAnnotation {} |
|
| 13 | + if (! \interface_exists('NamedArgumentConstructorAnnotation')) |
|
| 14 | + { |
|
| 15 | + interface NamedArgumentConstructorAnnotation |
|
| 16 | + { |
|
| 17 | +} |
|
| 15 | 18 | } |
| 16 | 19 | } |
| 17 | 20 | \ No newline at end of file |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | $attributes = $this->getClassAttributes($class, $name); |
| 43 | 43 | $context = $this->ctx->getClassContext($class); |
| 44 | 44 | |
| 45 | - foreach ($attributes as $attribute => $arguments) { |
|
| 45 | + foreach ($attributes as $attribute => $arguments){ |
|
| 46 | 46 | yield $this->instantiate($attribute, $arguments, $context); |
| 47 | 47 | } |
| 48 | 48 | } |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | $attributes = $this->getFunctionAttributes($function, $name); |
| 74 | 74 | $context = $this->ctx->getCallableContext($function); |
| 75 | 75 | |
| 76 | - foreach ($attributes as $attribute => $arguments) { |
|
| 76 | + foreach ($attributes as $attribute => $arguments){ |
|
| 77 | 77 | yield $this->instantiate($attribute, $arguments, $context); |
| 78 | 78 | } |
| 79 | 79 | } |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | $attributes = $this->getPropertyAttributes($property, $name); |
| 94 | 94 | $context = $this->ctx->getPropertyContext($property); |
| 95 | 95 | |
| 96 | - foreach ($attributes as $attribute => $arguments) { |
|
| 96 | + foreach ($attributes as $attribute => $arguments){ |
|
| 97 | 97 | yield $this->instantiate($attribute, $arguments, $context); |
| 98 | 98 | } |
| 99 | 99 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | $attributes = $this->getConstantAttributes($constant, $name); |
| 114 | 114 | $context = $this->ctx->getConstantContext($constant); |
| 115 | 115 | |
| 116 | - foreach ($attributes as $attribute => $arguments) { |
|
| 116 | + foreach ($attributes as $attribute => $arguments){ |
|
| 117 | 117 | yield $this->instantiate($attribute, $arguments, $context); |
| 118 | 118 | } |
| 119 | 119 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | $attributes = $this->getParameterAttributes($parameter, $name); |
| 134 | 134 | $context = $this->ctx->getParameterContext($parameter); |
| 135 | 135 | |
| 136 | - foreach ($attributes as $attribute => $arguments) { |
|
| 136 | + foreach ($attributes as $attribute => $arguments){ |
|
| 137 | 137 | yield $this->instantiate($attribute, $arguments, $context); |
| 138 | 138 | } |
| 139 | 139 | } |
@@ -42,7 +42,8 @@ discard block |
||
| 42 | 42 | $attributes = $this->getClassAttributes($class, $name); |
| 43 | 43 | $context = $this->ctx->getClassContext($class); |
| 44 | 44 | |
| 45 | - foreach ($attributes as $attribute => $arguments) { |
|
| 45 | + foreach ($attributes as $attribute => $arguments) |
|
| 46 | + { |
|
| 46 | 47 | yield $this->instantiate($attribute, $arguments, $context); |
| 47 | 48 | } |
| 48 | 49 | } |
@@ -73,7 +74,8 @@ discard block |
||
| 73 | 74 | $attributes = $this->getFunctionAttributes($function, $name); |
| 74 | 75 | $context = $this->ctx->getCallableContext($function); |
| 75 | 76 | |
| 76 | - foreach ($attributes as $attribute => $arguments) { |
|
| 77 | + foreach ($attributes as $attribute => $arguments) |
|
| 78 | + { |
|
| 77 | 79 | yield $this->instantiate($attribute, $arguments, $context); |
| 78 | 80 | } |
| 79 | 81 | } |
@@ -93,7 +95,8 @@ discard block |
||
| 93 | 95 | $attributes = $this->getPropertyAttributes($property, $name); |
| 94 | 96 | $context = $this->ctx->getPropertyContext($property); |
| 95 | 97 | |
| 96 | - foreach ($attributes as $attribute => $arguments) { |
|
| 98 | + foreach ($attributes as $attribute => $arguments) |
|
| 99 | + { |
|
| 97 | 100 | yield $this->instantiate($attribute, $arguments, $context); |
| 98 | 101 | } |
| 99 | 102 | } |
@@ -113,7 +116,8 @@ discard block |
||
| 113 | 116 | $attributes = $this->getConstantAttributes($constant, $name); |
| 114 | 117 | $context = $this->ctx->getConstantContext($constant); |
| 115 | 118 | |
| 116 | - foreach ($attributes as $attribute => $arguments) { |
|
| 119 | + foreach ($attributes as $attribute => $arguments) |
|
| 120 | + { |
|
| 117 | 121 | yield $this->instantiate($attribute, $arguments, $context); |
| 118 | 122 | } |
| 119 | 123 | } |
@@ -133,7 +137,8 @@ discard block |
||
| 133 | 137 | $attributes = $this->getParameterAttributes($parameter, $name); |
| 134 | 138 | $context = $this->ctx->getParameterContext($parameter); |
| 135 | 139 | |
| 136 | - foreach ($attributes as $attribute => $arguments) { |
|
| 140 | + foreach ($attributes as $attribute => $arguments) |
|
| 141 | + { |
|
| 137 | 142 | yield $this->instantiate($attribute, $arguments, $context); |
| 138 | 143 | } |
| 139 | 144 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * @var string |
| 30 | 30 | */ |
| 31 | 31 | private const ERROR_INVALID_PROPERTY = |
| 32 | - 'The attribute #[%s] declared on %s does not have a property named "%s".' . "\n" . |
|
| 32 | + 'The attribute #[%s] declared on %s does not have a property named "%s".'."\n". |
|
| 33 | 33 | 'Available properties: %s' |
| 34 | 34 | ; |
| 35 | 35 | |
@@ -65,23 +65,23 @@ discard block |
||
| 65 | 65 | $arguments = $this->formatArguments($arguments); |
| 66 | 66 | |
| 67 | 67 | // Using constructor |
| 68 | - if ($this->getConstructor($attribute)) { |
|
| 68 | + if ($this->getConstructor($attribute)){ |
|
| 69 | 69 | return $attribute->newInstance($arguments); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | // Using direct insert |
| 73 | 73 | $instance = $attribute->newInstanceWithoutConstructor(); |
| 74 | 74 | |
| 75 | - foreach ($arguments as $name => $value) { |
|
| 76 | - try { |
|
| 75 | + foreach ($arguments as $name => $value){ |
|
| 76 | + try{ |
|
| 77 | 77 | $property = $attribute->getProperty($name); |
| 78 | 78 | |
| 79 | - if (! $property->isPublic()) { |
|
| 79 | + if (!$property->isPublic()){ |
|
| 80 | 80 | throw $this->propertyNotFound($attribute, $name, $context); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | $instance->$name = $value; |
| 84 | - } catch (\Throwable $e) { |
|
| 84 | + }catch (\Throwable $e){ |
|
| 85 | 85 | throw $this->propertyNotFound($attribute, $name, $context); |
| 86 | 86 | } |
| 87 | 87 | } |
@@ -97,8 +97,8 @@ discard block |
||
| 97 | 97 | { |
| 98 | 98 | $result = []; |
| 99 | 99 | |
| 100 | - foreach ($arguments as $name => $value) { |
|
| 101 | - if (\is_int($name)) { |
|
| 100 | + foreach ($arguments as $name => $value){ |
|
| 101 | + if (\is_int($name)){ |
|
| 102 | 102 | $this->validateArgumentPosition($name, $value); |
| 103 | 103 | |
| 104 | 104 | $name = self::DEFAULT_PROPERTY_NAME; |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | private function validateArgumentPosition(int $index, $value): void |
| 118 | 118 | { |
| 119 | - if ($index === 0) { |
|
| 119 | + if ($index === 0){ |
|
| 120 | 120 | return; |
| 121 | 121 | } |
| 122 | 122 | |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | { |
| 158 | 158 | $names = []; |
| 159 | 159 | |
| 160 | - foreach ($construct->getParameters() as $parameter) { |
|
| 160 | + foreach ($construct->getParameters() as $parameter){ |
|
| 161 | 161 | $names[] = $parameter->getName(); |
| 162 | 162 | } |
| 163 | 163 | |
@@ -179,15 +179,15 @@ discard block |
||
| 179 | 179 | */ |
| 180 | 180 | protected function getConstructor(\ReflectionClass $class): ?\ReflectionMethod |
| 181 | 181 | { |
| 182 | - if ($class->hasMethod(self::CONSTRUCTOR_NAME)) { |
|
| 182 | + if ($class->hasMethod(self::CONSTRUCTOR_NAME)){ |
|
| 183 | 183 | return $class->getMethod(self::CONSTRUCTOR_NAME); |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - if ($constructor = $this->getTraitConstructors($class)) { |
|
| 186 | + if ($constructor = $this->getTraitConstructors($class)){ |
|
| 187 | 187 | return $constructor; |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - if ($parent = $class->getParentClass()) { |
|
| 190 | + if ($parent = $class->getParentClass()){ |
|
| 191 | 191 | return $this->getConstructor($parent); |
| 192 | 192 | } |
| 193 | 193 | |
@@ -200,12 +200,12 @@ discard block |
||
| 200 | 200 | */ |
| 201 | 201 | private function getTraitConstructors(\ReflectionClass $class): ?\ReflectionMethod |
| 202 | 202 | { |
| 203 | - foreach ($class->getTraits() as $trait) { |
|
| 204 | - if ($constructor = $this->getConstructor($trait)) { |
|
| 203 | + foreach ($class->getTraits() as $trait){ |
|
| 204 | + if ($constructor = $this->getConstructor($trait)){ |
|
| 205 | 205 | return $constructor; |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - if ($constructor = $this->getTraitConstructors($trait)) { |
|
| 208 | + if ($constructor = $this->getTraitConstructors($trait)){ |
|
| 209 | 209 | return $constructor; |
| 210 | 210 | } |
| 211 | 211 | } |
@@ -65,23 +65,29 @@ discard block |
||
| 65 | 65 | $arguments = $this->formatArguments($arguments); |
| 66 | 66 | |
| 67 | 67 | // Using constructor |
| 68 | - if ($this->getConstructor($attribute)) { |
|
| 68 | + if ($this->getConstructor($attribute)) |
|
| 69 | + { |
|
| 69 | 70 | return $attribute->newInstance($arguments); |
| 70 | 71 | } |
| 71 | 72 | |
| 72 | 73 | // Using direct insert |
| 73 | 74 | $instance = $attribute->newInstanceWithoutConstructor(); |
| 74 | 75 | |
| 75 | - foreach ($arguments as $name => $value) { |
|
| 76 | - try { |
|
| 76 | + foreach ($arguments as $name => $value) |
|
| 77 | + { |
|
| 78 | + try |
|
| 79 | + { |
|
| 77 | 80 | $property = $attribute->getProperty($name); |
| 78 | 81 | |
| 79 | - if (! $property->isPublic()) { |
|
| 82 | + if (! $property->isPublic()) |
|
| 83 | + { |
|
| 80 | 84 | throw $this->propertyNotFound($attribute, $name, $context); |
| 81 | 85 | } |
| 82 | 86 | |
| 83 | 87 | $instance->$name = $value; |
| 84 | - } catch (\Throwable $e) { |
|
| 88 | + } |
|
| 89 | + catch (\Throwable $e) |
|
| 90 | + { |
|
| 85 | 91 | throw $this->propertyNotFound($attribute, $name, $context); |
| 86 | 92 | } |
| 87 | 93 | } |
@@ -97,8 +103,10 @@ discard block |
||
| 97 | 103 | { |
| 98 | 104 | $result = []; |
| 99 | 105 | |
| 100 | - foreach ($arguments as $name => $value) { |
|
| 101 | - if (\is_int($name)) { |
|
| 106 | + foreach ($arguments as $name => $value) |
|
| 107 | + { |
|
| 108 | + if (\is_int($name)) |
|
| 109 | + { |
|
| 102 | 110 | $this->validateArgumentPosition($name, $value); |
| 103 | 111 | |
| 104 | 112 | $name = self::DEFAULT_PROPERTY_NAME; |
@@ -116,7 +124,8 @@ discard block |
||
| 116 | 124 | */ |
| 117 | 125 | private function validateArgumentPosition(int $index, $value): void |
| 118 | 126 | { |
| 119 | - if ($index === 0) { |
|
| 127 | + if ($index === 0) |
|
| 128 | + { |
|
| 120 | 129 | return; |
| 121 | 130 | } |
| 122 | 131 | |
@@ -157,7 +166,8 @@ discard block |
||
| 157 | 166 | { |
| 158 | 167 | $names = []; |
| 159 | 168 | |
| 160 | - foreach ($construct->getParameters() as $parameter) { |
|
| 169 | + foreach ($construct->getParameters() as $parameter) |
|
| 170 | + { |
|
| 161 | 171 | $names[] = $parameter->getName(); |
| 162 | 172 | } |
| 163 | 173 | |
@@ -179,15 +189,18 @@ discard block |
||
| 179 | 189 | */ |
| 180 | 190 | protected function getConstructor(\ReflectionClass $class): ?\ReflectionMethod |
| 181 | 191 | { |
| 182 | - if ($class->hasMethod(self::CONSTRUCTOR_NAME)) { |
|
| 192 | + if ($class->hasMethod(self::CONSTRUCTOR_NAME)) |
|
| 193 | + { |
|
| 183 | 194 | return $class->getMethod(self::CONSTRUCTOR_NAME); |
| 184 | 195 | } |
| 185 | 196 | |
| 186 | - if ($constructor = $this->getTraitConstructors($class)) { |
|
| 197 | + if ($constructor = $this->getTraitConstructors($class)) |
|
| 198 | + { |
|
| 187 | 199 | return $constructor; |
| 188 | 200 | } |
| 189 | 201 | |
| 190 | - if ($parent = $class->getParentClass()) { |
|
| 202 | + if ($parent = $class->getParentClass()) |
|
| 203 | + { |
|
| 191 | 204 | return $this->getConstructor($parent); |
| 192 | 205 | } |
| 193 | 206 | |
@@ -200,12 +213,15 @@ discard block |
||
| 200 | 213 | */ |
| 201 | 214 | private function getTraitConstructors(\ReflectionClass $class): ?\ReflectionMethod |
| 202 | 215 | { |
| 203 | - foreach ($class->getTraits() as $trait) { |
|
| 204 | - if ($constructor = $this->getConstructor($trait)) { |
|
| 216 | + foreach ($class->getTraits() as $trait) |
|
| 217 | + { |
|
| 218 | + if ($constructor = $this->getConstructor($trait)) |
|
| 219 | + { |
|
| 205 | 220 | return $constructor; |
| 206 | 221 | } |
| 207 | 222 | |
| 208 | - if ($constructor = $this->getTraitConstructors($trait)) { |
|
| 223 | + if ($constructor = $this->getTraitConstructors($trait)) |
|
| 224 | + { |
|
| 209 | 225 | return $constructor; |
| 210 | 226 | } |
| 211 | 227 | } |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | public function getClassContext(\ReflectionClass $class): string |
| 65 | 65 | { |
| 66 | - if ($class->isAnonymous()) { |
|
| 66 | + if ($class->isAnonymous()){ |
|
| 67 | 67 | return \sprintf(static::FORMAT_ANONYMOUS_CLASS, $class->getFileName(), $class->getStartLine()); |
| 68 | 68 | } |
| 69 | 69 | |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | */ |
| 88 | 88 | public function getFunctionContext(\ReflectionFunction $fn): string |
| 89 | 89 | { |
| 90 | - if ($fn->isClosure()) { |
|
| 90 | + if ($fn->isClosure()){ |
|
| 91 | 91 | return \sprintf(self::FORMAT_ANONYMOUS_FUNCTION, $fn->getFileName(), $fn->getStartLine()); |
| 92 | 92 | } |
| 93 | 93 | |
@@ -100,11 +100,11 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | public function getCallableContext(\ReflectionFunctionAbstract $function): string |
| 102 | 102 | { |
| 103 | - if ($function instanceof \ReflectionMethod) { |
|
| 103 | + if ($function instanceof \ReflectionMethod){ |
|
| 104 | 104 | return $this->getMethodContext($function); |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - if ($function instanceof \ReflectionFunction) { |
|
| 107 | + if ($function instanceof \ReflectionFunction){ |
|
| 108 | 108 | return $this->getFunctionContext($function); |
| 109 | 109 | } |
| 110 | 110 | |
@@ -63,7 +63,8 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | public function getClassContext(\ReflectionClass $class): string |
| 65 | 65 | { |
| 66 | - if ($class->isAnonymous()) { |
|
| 66 | + if ($class->isAnonymous()) |
|
| 67 | + { |
|
| 67 | 68 | return \sprintf(static::FORMAT_ANONYMOUS_CLASS, $class->getFileName(), $class->getStartLine()); |
| 68 | 69 | } |
| 69 | 70 | |
@@ -87,7 +88,8 @@ discard block |
||
| 87 | 88 | */ |
| 88 | 89 | public function getFunctionContext(\ReflectionFunction $fn): string |
| 89 | 90 | { |
| 90 | - if ($fn->isClosure()) { |
|
| 91 | + if ($fn->isClosure()) |
|
| 92 | + { |
|
| 91 | 93 | return \sprintf(self::FORMAT_ANONYMOUS_FUNCTION, $fn->getFileName(), $fn->getStartLine()); |
| 92 | 94 | } |
| 93 | 95 | |
@@ -100,11 +102,13 @@ discard block |
||
| 100 | 102 | */ |
| 101 | 103 | public function getCallableContext(\ReflectionFunctionAbstract $function): string |
| 102 | 104 | { |
| 103 | - if ($function instanceof \ReflectionMethod) { |
|
| 105 | + if ($function instanceof \ReflectionMethod) |
|
| 106 | + { |
|
| 104 | 107 | return $this->getMethodContext($function); |
| 105 | 108 | } |
| 106 | 109 | |
| 107 | - if ($function instanceof \ReflectionFunction) { |
|
| 110 | + if ($function instanceof \ReflectionFunction) |
|
| 111 | + { |
|
| 108 | 112 | return $this->getFunctionContext($function); |
| 109 | 113 | } |
| 110 | 114 | |
@@ -101,8 +101,8 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | private function read(string $file): string |
| 103 | 103 | { |
| 104 | - if (! \is_readable($file)) { |
|
| 105 | - throw new \InvalidArgumentException('Unable to read file "' . $file . '"'); |
|
| 104 | + if (!\is_readable($file)){ |
|
| 105 | + throw new \InvalidArgumentException('Unable to read file "'.$file.'"'); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | return \file_get_contents($file); |
@@ -119,8 +119,8 @@ discard block |
||
| 119 | 119 | { |
| 120 | 120 | $eval = new ConstExprEvaluator($this->evaluator($file, $context)); |
| 121 | 121 | |
| 122 | - foreach ($groups as $group) { |
|
| 123 | - foreach ($group->attrs as $attr) { |
|
| 122 | + foreach ($groups as $group){ |
|
| 123 | + foreach ($group->attrs as $attr){ |
|
| 124 | 124 | $arguments = $this->parseAttributeArguments($attr, $file, $eval); |
| 125 | 125 | |
| 126 | 126 | yield new AttributePrototype($attr->name->toString(), $arguments); |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | private function evaluator(string $file, array $context): \Closure |
| 137 | 137 | { |
| 138 | 138 | return static function (Expr $expr) use ($file, $context) { |
| 139 | - switch (\get_class($expr)) { |
|
| 139 | + switch (\get_class($expr)){ |
|
| 140 | 140 | case Scalar\MagicConst\File::class: |
| 141 | 141 | return $file; |
| 142 | 142 | |
@@ -150,10 +150,10 @@ discard block |
||
| 150 | 150 | $namespace = $context[self::CTX_NAMESPACE] ?? ''; |
| 151 | 151 | $function = $context[self::CTX_FUNCTION] ?? ''; |
| 152 | 152 | |
| 153 | - return \ltrim($namespace . '\\' . $function, '\\'); |
|
| 153 | + return \ltrim($namespace.'\\'.$function, '\\'); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - if ($expr instanceof Scalar\MagicConst) { |
|
| 156 | + if ($expr instanceof Scalar\MagicConst){ |
|
| 157 | 157 | return $context[$expr->getName()] ?? ''; |
| 158 | 158 | } |
| 159 | 159 | |
@@ -175,13 +175,13 @@ discard block |
||
| 175 | 175 | $hasNamedArguments = false; |
| 176 | 176 | $arguments = []; |
| 177 | 177 | |
| 178 | - foreach ($attr->args as $argument) { |
|
| 178 | + foreach ($attr->args as $argument){ |
|
| 179 | 179 | $value = $eval->evaluateDirectly($argument->value); |
| 180 | 180 | |
| 181 | - if ($argument->name === null) { |
|
| 181 | + if ($argument->name === null){ |
|
| 182 | 182 | $arguments[] = $value; |
| 183 | 183 | |
| 184 | - if ($hasNamedArguments) { |
|
| 184 | + if ($hasNamedArguments){ |
|
| 185 | 185 | $exception = new \ParseError(self::ERROR_NAMED_ARGUMENTS_ORDER); |
| 186 | 186 | throw Exception::withLocation($exception, $file, $argument->getStartLine()); |
| 187 | 187 | } |
@@ -101,7 +101,8 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | private function read(string $file): string |
| 103 | 103 | { |
| 104 | - if (! \is_readable($file)) { |
|
| 104 | + if (! \is_readable($file)) |
|
| 105 | + { |
|
| 105 | 106 | throw new \InvalidArgumentException('Unable to read file "' . $file . '"'); |
| 106 | 107 | } |
| 107 | 108 | |
@@ -119,8 +120,10 @@ discard block |
||
| 119 | 120 | { |
| 120 | 121 | $eval = new ConstExprEvaluator($this->evaluator($file, $context)); |
| 121 | 122 | |
| 122 | - foreach ($groups as $group) { |
|
| 123 | - foreach ($group->attrs as $attr) { |
|
| 123 | + foreach ($groups as $group) |
|
| 124 | + { |
|
| 125 | + foreach ($group->attrs as $attr) |
|
| 126 | + { |
|
| 124 | 127 | $arguments = $this->parseAttributeArguments($attr, $file, $eval); |
| 125 | 128 | |
| 126 | 129 | yield new AttributePrototype($attr->name->toString(), $arguments); |
@@ -135,8 +138,10 @@ discard block |
||
| 135 | 138 | */ |
| 136 | 139 | private function evaluator(string $file, array $context): \Closure |
| 137 | 140 | { |
| 138 | - return static function (Expr $expr) use ($file, $context) { |
|
| 139 | - switch (\get_class($expr)) { |
|
| 141 | + return static function (Expr $expr) use ($file, $context) |
|
| 142 | + { |
|
| 143 | + switch (\get_class($expr)) |
|
| 144 | + { |
|
| 140 | 145 | case Scalar\MagicConst\File::class: |
| 141 | 146 | return $file; |
| 142 | 147 | |
@@ -153,7 +158,8 @@ discard block |
||
| 153 | 158 | return \ltrim($namespace . '\\' . $function, '\\'); |
| 154 | 159 | } |
| 155 | 160 | |
| 156 | - if ($expr instanceof Scalar\MagicConst) { |
|
| 161 | + if ($expr instanceof Scalar\MagicConst) |
|
| 162 | + { |
|
| 157 | 163 | return $context[$expr->getName()] ?? ''; |
| 158 | 164 | } |
| 159 | 165 | |
@@ -175,13 +181,16 @@ discard block |
||
| 175 | 181 | $hasNamedArguments = false; |
| 176 | 182 | $arguments = []; |
| 177 | 183 | |
| 178 | - foreach ($attr->args as $argument) { |
|
| 184 | + foreach ($attr->args as $argument) |
|
| 185 | + { |
|
| 179 | 186 | $value = $eval->evaluateDirectly($argument->value); |
| 180 | 187 | |
| 181 | - if ($argument->name === null) { |
|
| 188 | + if ($argument->name === null) |
|
| 189 | + { |
|
| 182 | 190 | $arguments[] = $value; |
| 183 | 191 | |
| 184 | - if ($hasNamedArguments) { |
|
| 192 | + if ($hasNamedArguments) |
|
| 193 | + { |
|
| 185 | 194 | $exception = new \ParseError(self::ERROR_NAMED_ARGUMENTS_ORDER); |
| 186 | 195 | throw Exception::withLocation($exception, $file, $argument->getStartLine()); |
| 187 | 196 | } |
@@ -145,23 +145,23 @@ discard block |
||
| 145 | 145 | { |
| 146 | 146 | $this->updateContext($node); |
| 147 | 147 | |
| 148 | - if ($node instanceof Node\Stmt\ClassLike) { |
|
| 149 | - foreach ($this->parse($node->attrGroups) as $prototype) { |
|
| 148 | + if ($node instanceof Node\Stmt\ClassLike){ |
|
| 149 | + foreach ($this->parse($node->attrGroups) as $prototype){ |
|
| 150 | 150 | $this->classes[$node->namespacedName->toString()][] = $prototype; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | return null; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - if ($node instanceof Node\FunctionLike) { |
|
| 156 | + if ($node instanceof Node\FunctionLike){ |
|
| 157 | 157 | $line = $node->getEndLine(); |
| 158 | 158 | |
| 159 | - foreach ($this->parse($node->getAttrGroups()) as $prototype) { |
|
| 159 | + foreach ($this->parse($node->getAttrGroups()) as $prototype){ |
|
| 160 | 160 | $this->functions[$line][] = $prototype; |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - foreach ($node->getParams() as $param) { |
|
| 164 | - foreach ($this->parse($param->attrGroups) as $prototype) { |
|
| 163 | + foreach ($node->getParams() as $param){ |
|
| 164 | + foreach ($this->parse($param->attrGroups) as $prototype){ |
|
| 165 | 165 | assert(\is_string($param->var->name), 'Function parameter name should be an identifier'); |
| 166 | 166 | |
| 167 | 167 | $this->parameters[$line][$param->var->name][] = $prototype; |
@@ -171,11 +171,11 @@ discard block |
||
| 171 | 171 | return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN; |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - if ($node instanceof Node\Stmt\ClassConst) { |
|
| 174 | + if ($node instanceof Node\Stmt\ClassConst){ |
|
| 175 | 175 | $class = $this->fqn(); |
| 176 | 176 | |
| 177 | - foreach ($this->parse($node->attrGroups) as $prototype) { |
|
| 178 | - foreach ($node->consts as $const) { |
|
| 177 | + foreach ($this->parse($node->attrGroups) as $prototype){ |
|
| 178 | + foreach ($node->consts as $const){ |
|
| 179 | 179 | $this->constants[$class][$this->name($const->name)][] = $prototype; |
| 180 | 180 | } |
| 181 | 181 | } |
@@ -183,11 +183,11 @@ discard block |
||
| 183 | 183 | return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN; |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - if ($node instanceof Property) { |
|
| 186 | + if ($node instanceof Property){ |
|
| 187 | 187 | $class = $this->fqn(); |
| 188 | 188 | |
| 189 | - foreach ($this->parse($node->attrGroups) as $prototype) { |
|
| 190 | - foreach ($node->props as $property) { |
|
| 189 | + foreach ($this->parse($node->attrGroups) as $prototype){ |
|
| 190 | + foreach ($node->props as $property){ |
|
| 191 | 191 | $this->properties[$class][$this->name($property->name)][] = $prototype; |
| 192 | 192 | } |
| 193 | 193 | } |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | $namespace = $this->context[AttributeParser::CTX_NAMESPACE] ?? ''; |
| 207 | 207 | $class = $this->context[AttributeParser::CTX_CLASS] ?? ''; |
| 208 | 208 | |
| 209 | - return \trim($namespace . '\\' . $class, '\\'); |
|
| 209 | + return \trim($namespace.'\\'.$class, '\\'); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | */ |
| 216 | 216 | private function name($name): string |
| 217 | 217 | { |
| 218 | - if ($name === null) { |
|
| 218 | + if ($name === null){ |
|
| 219 | 219 | return ''; |
| 220 | 220 | } |
| 221 | 221 | |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | */ |
| 228 | 228 | private function updateContext(Node $node): void |
| 229 | 229 | { |
| 230 | - switch (true) { |
|
| 230 | + switch (true){ |
|
| 231 | 231 | case $node instanceof Node\Stmt\Namespace_: |
| 232 | 232 | $this->context[AttributeParser::CTX_NAMESPACE] = $this->name($node->name); |
| 233 | 233 | break; |
@@ -251,18 +251,18 @@ discard block |
||
| 251 | 251 | */ |
| 252 | 252 | public function leaveNode(Node $node): void |
| 253 | 253 | { |
| 254 | - if ($node instanceof Node\Stmt\Namespace_) { |
|
| 254 | + if ($node instanceof Node\Stmt\Namespace_){ |
|
| 255 | 255 | $this->context[AttributeParser::CTX_NAMESPACE] = ''; |
| 256 | 256 | return; |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - if ($node instanceof Node\Stmt\ClassLike) { |
|
| 259 | + if ($node instanceof Node\Stmt\ClassLike){ |
|
| 260 | 260 | $this->context[AttributeParser::CTX_CLASS] = ''; |
| 261 | 261 | $this->context[AttributeParser::CTX_TRAIT] = ''; |
| 262 | 262 | return; |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | - if ($node instanceof Node\FunctionLike) { |
|
| 265 | + if ($node instanceof Node\FunctionLike){ |
|
| 266 | 266 | $this->context[AttributeParser::CTX_FUNCTION] = ''; |
| 267 | 267 | return; |
| 268 | 268 | } |
@@ -145,23 +145,29 @@ discard block |
||
| 145 | 145 | { |
| 146 | 146 | $this->updateContext($node); |
| 147 | 147 | |
| 148 | - if ($node instanceof Node\Stmt\ClassLike) { |
|
| 149 | - foreach ($this->parse($node->attrGroups) as $prototype) { |
|
| 148 | + if ($node instanceof Node\Stmt\ClassLike) |
|
| 149 | + { |
|
| 150 | + foreach ($this->parse($node->attrGroups) as $prototype) |
|
| 151 | + { |
|
| 150 | 152 | $this->classes[$node->namespacedName->toString()][] = $prototype; |
| 151 | 153 | } |
| 152 | 154 | |
| 153 | 155 | return null; |
| 154 | 156 | } |
| 155 | 157 | |
| 156 | - if ($node instanceof Node\FunctionLike) { |
|
| 158 | + if ($node instanceof Node\FunctionLike) |
|
| 159 | + { |
|
| 157 | 160 | $line = $node->getEndLine(); |
| 158 | 161 | |
| 159 | - foreach ($this->parse($node->getAttrGroups()) as $prototype) { |
|
| 162 | + foreach ($this->parse($node->getAttrGroups()) as $prototype) |
|
| 163 | + { |
|
| 160 | 164 | $this->functions[$line][] = $prototype; |
| 161 | 165 | } |
| 162 | 166 | |
| 163 | - foreach ($node->getParams() as $param) { |
|
| 164 | - foreach ($this->parse($param->attrGroups) as $prototype) { |
|
| 167 | + foreach ($node->getParams() as $param) |
|
| 168 | + { |
|
| 169 | + foreach ($this->parse($param->attrGroups) as $prototype) |
|
| 170 | + { |
|
| 165 | 171 | assert(\is_string($param->var->name), 'Function parameter name should be an identifier'); |
| 166 | 172 | |
| 167 | 173 | $this->parameters[$line][$param->var->name][] = $prototype; |
@@ -171,11 +177,14 @@ discard block |
||
| 171 | 177 | return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN; |
| 172 | 178 | } |
| 173 | 179 | |
| 174 | - if ($node instanceof Node\Stmt\ClassConst) { |
|
| 180 | + if ($node instanceof Node\Stmt\ClassConst) |
|
| 181 | + { |
|
| 175 | 182 | $class = $this->fqn(); |
| 176 | 183 | |
| 177 | - foreach ($this->parse($node->attrGroups) as $prototype) { |
|
| 178 | - foreach ($node->consts as $const) { |
|
| 184 | + foreach ($this->parse($node->attrGroups) as $prototype) |
|
| 185 | + { |
|
| 186 | + foreach ($node->consts as $const) |
|
| 187 | + { |
|
| 179 | 188 | $this->constants[$class][$this->name($const->name)][] = $prototype; |
| 180 | 189 | } |
| 181 | 190 | } |
@@ -183,11 +192,14 @@ discard block |
||
| 183 | 192 | return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN; |
| 184 | 193 | } |
| 185 | 194 | |
| 186 | - if ($node instanceof Property) { |
|
| 195 | + if ($node instanceof Property) |
|
| 196 | + { |
|
| 187 | 197 | $class = $this->fqn(); |
| 188 | 198 | |
| 189 | - foreach ($this->parse($node->attrGroups) as $prototype) { |
|
| 190 | - foreach ($node->props as $property) { |
|
| 199 | + foreach ($this->parse($node->attrGroups) as $prototype) |
|
| 200 | + { |
|
| 201 | + foreach ($node->props as $property) |
|
| 202 | + { |
|
| 191 | 203 | $this->properties[$class][$this->name($property->name)][] = $prototype; |
| 192 | 204 | } |
| 193 | 205 | } |
@@ -215,7 +227,8 @@ discard block |
||
| 215 | 227 | */ |
| 216 | 228 | private function name($name): string |
| 217 | 229 | { |
| 218 | - if ($name === null) { |
|
| 230 | + if ($name === null) |
|
| 231 | + { |
|
| 219 | 232 | return ''; |
| 220 | 233 | } |
| 221 | 234 | |
@@ -227,7 +240,8 @@ discard block |
||
| 227 | 240 | */ |
| 228 | 241 | private function updateContext(Node $node): void |
| 229 | 242 | { |
| 230 | - switch (true) { |
|
| 243 | + switch (true) |
|
| 244 | + { |
|
| 231 | 245 | case $node instanceof Node\Stmt\Namespace_: |
| 232 | 246 | $this->context[AttributeParser::CTX_NAMESPACE] = $this->name($node->name); |
| 233 | 247 | break; |
@@ -251,18 +265,21 @@ discard block |
||
| 251 | 265 | */ |
| 252 | 266 | public function leaveNode(Node $node): void |
| 253 | 267 | { |
| 254 | - if ($node instanceof Node\Stmt\Namespace_) { |
|
| 268 | + if ($node instanceof Node\Stmt\Namespace_) |
|
| 269 | + { |
|
| 255 | 270 | $this->context[AttributeParser::CTX_NAMESPACE] = ''; |
| 256 | 271 | return; |
| 257 | 272 | } |
| 258 | 273 | |
| 259 | - if ($node instanceof Node\Stmt\ClassLike) { |
|
| 274 | + if ($node instanceof Node\Stmt\ClassLike) |
|
| 275 | + { |
|
| 260 | 276 | $this->context[AttributeParser::CTX_CLASS] = ''; |
| 261 | 277 | $this->context[AttributeParser::CTX_TRAIT] = ''; |
| 262 | 278 | return; |
| 263 | 279 | } |
| 264 | 280 | |
| 265 | - if ($node instanceof Node\FunctionLike) { |
|
| 281 | + if ($node instanceof Node\FunctionLike) |
|
| 282 | + { |
|
| 266 | 283 | $this->context[AttributeParser::CTX_FUNCTION] = ''; |
| 267 | 284 | return; |
| 268 | 285 | } |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | $this->reader = $reader ?? new DoctrineReader(); |
| 35 | 35 | |
| 36 | 36 | // doctrine/annotations ^1.0 compatibility. |
| 37 | - if (\method_exists(AnnotationRegistry::class, 'registerLoader')) { |
|
| 37 | + if (\method_exists(AnnotationRegistry::class, 'registerLoader')){ |
|
| 38 | 38 | AnnotationRegistry::registerLoader('\\class_exists'); |
| 39 | 39 | } |
| 40 | 40 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | private function checkAvailability(): void |
| 46 | 46 | { |
| 47 | - if ($this->isAvailable()) { |
|
| 47 | + if ($this->isAvailable()){ |
|
| 48 | 48 | return; |
| 49 | 49 | } |
| 50 | 50 | |
@@ -76,14 +76,14 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | private function filter(?string $name, iterable $annotations): iterable |
| 78 | 78 | { |
| 79 | - if ($name === null) { |
|
| 79 | + if ($name === null){ |
|
| 80 | 80 | yield from $annotations; |
| 81 | 81 | |
| 82 | 82 | return; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - foreach ($annotations as $annotation) { |
|
| 86 | - if ($annotation instanceof $name) { |
|
| 85 | + foreach ($annotations as $annotation){ |
|
| 86 | + if ($annotation instanceof $name){ |
|
| 87 | 87 | yield $annotation; |
| 88 | 88 | } |
| 89 | 89 | } |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | public function getFunctionMetadata(\ReflectionFunctionAbstract $function, string $name = null): iterable |
| 96 | 96 | { |
| 97 | - if ($function instanceof \ReflectionMethod) { |
|
| 97 | + if ($function instanceof \ReflectionMethod){ |
|
| 98 | 98 | $result = $this->reader->getMethodAnnotations($function); |
| 99 | 99 | |
| 100 | 100 | return $this->filter($name, $result); |
@@ -34,7 +34,8 @@ discard block |
||
| 34 | 34 | $this->reader = $reader ?? new DoctrineReader(); |
| 35 | 35 | |
| 36 | 36 | // doctrine/annotations ^1.0 compatibility. |
| 37 | - if (\method_exists(AnnotationRegistry::class, 'registerLoader')) { |
|
| 37 | + if (\method_exists(AnnotationRegistry::class, 'registerLoader')) |
|
| 38 | + { |
|
| 38 | 39 | AnnotationRegistry::registerLoader('\\class_exists'); |
| 39 | 40 | } |
| 40 | 41 | } |
@@ -44,7 +45,8 @@ discard block |
||
| 44 | 45 | */ |
| 45 | 46 | private function checkAvailability(): void |
| 46 | 47 | { |
| 47 | - if ($this->isAvailable()) { |
|
| 48 | + if ($this->isAvailable()) |
|
| 49 | + { |
|
| 48 | 50 | return; |
| 49 | 51 | } |
| 50 | 52 | |
@@ -76,14 +78,17 @@ discard block |
||
| 76 | 78 | */ |
| 77 | 79 | private function filter(?string $name, iterable $annotations): iterable |
| 78 | 80 | { |
| 79 | - if ($name === null) { |
|
| 81 | + if ($name === null) |
|
| 82 | + { |
|
| 80 | 83 | yield from $annotations; |
| 81 | 84 | |
| 82 | 85 | return; |
| 83 | 86 | } |
| 84 | 87 | |
| 85 | - foreach ($annotations as $annotation) { |
|
| 86 | - if ($annotation instanceof $name) { |
|
| 88 | + foreach ($annotations as $annotation) |
|
| 89 | + { |
|
| 90 | + if ($annotation instanceof $name) |
|
| 91 | + { |
|
| 87 | 92 | yield $annotation; |
| 88 | 93 | } |
| 89 | 94 | } |
@@ -94,7 +99,8 @@ discard block |
||
| 94 | 99 | */ |
| 95 | 100 | public function getFunctionMetadata(\ReflectionFunctionAbstract $function, string $name = null): iterable |
| 96 | 101 | { |
| 97 | - if ($function instanceof \ReflectionMethod) { |
|
| 102 | + if ($function instanceof \ReflectionMethod) |
|
| 103 | + { |
|
| 98 | 104 | $result = $this->reader->getMethodAnnotations($function); |
| 99 | 105 | |
| 100 | 106 | return $this->filter($name, $result); |