@@ -10,7 +10,7 @@ |
||
| 10 | 10 | declare(strict_types=1); |
| 11 | 11 | |
| 12 | 12 | namespace Doctrine\Common\Annotations { |
| 13 | - if (! \interface_exists(NamedArgumentConstructorAnnotation::class)) { |
|
| 13 | + if (!\interface_exists(NamedArgumentConstructorAnnotation::class)){ |
|
| 14 | 14 | interface NamedArgumentConstructorAnnotation |
| 15 | 15 | { |
| 16 | 16 | } |
@@ -10,7 +10,8 @@ |
||
| 10 | 10 | declare(strict_types=1); |
| 11 | 11 | |
| 12 | 12 | namespace Doctrine\Common\Annotations { |
| 13 | - if (! \interface_exists(NamedArgumentConstructorAnnotation::class)) { |
|
| 13 | + if (! \interface_exists(NamedArgumentConstructorAnnotation::class)) |
|
| 14 | + { |
|
| 14 | 15 | interface NamedArgumentConstructorAnnotation |
| 15 | 16 | { |
| 16 | 17 | } |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | { |
| 72 | 72 | // 1) Can not parse internal classes |
| 73 | 73 | // 2) Anonymous classes don't support attributes (PHP semantic) |
| 74 | - if ($class->isInternal() || $class->isAnonymous()) { |
|
| 74 | + if ($class->isInternal() || $class->isAnonymous()){ |
|
| 75 | 75 | return []; |
| 76 | 76 | } |
| 77 | 77 | |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | protected function getFunctionAttributes(\ReflectionFunctionAbstract $function, ?string $name): iterable |
| 87 | 87 | { |
| 88 | 88 | // Can not parse internal functions |
| 89 | - if ($function->isInternal()) { |
|
| 89 | + if ($function->isInternal()){ |
|
| 90 | 90 | return []; |
| 91 | 91 | } |
| 92 | 92 | |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | $class = $property->getDeclaringClass(); |
| 105 | 105 | |
| 106 | 106 | // Can not parse property of internal class |
| 107 | - if ($class->isInternal()) { |
|
| 107 | + if ($class->isInternal()){ |
|
| 108 | 108 | return []; |
| 109 | 109 | } |
| 110 | 110 | |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | $class = $const->getDeclaringClass(); |
| 122 | 122 | |
| 123 | 123 | // Can not parse internal classes |
| 124 | - if ($class->isInternal()) { |
|
| 124 | + if ($class->isInternal()){ |
|
| 125 | 125 | return []; |
| 126 | 126 | } |
| 127 | 127 | |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | $function = $param->getDeclaringFunction(); |
| 139 | 139 | |
| 140 | 140 | // Can not parse parameter of internal function |
| 141 | - if ($function->isInternal()) { |
|
| 141 | + if ($function->isInternal()){ |
|
| 142 | 142 | return []; |
| 143 | 143 | } |
| 144 | 144 | |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | $line = $function->getEndLine(); |
| 180 | 180 | |
| 181 | - if ($result = $attributes[$line] ?? null) { |
|
| 181 | + if ($result = $attributes[$line] ?? null){ |
|
| 182 | 182 | return $result; |
| 183 | 183 | } |
| 184 | 184 | |
@@ -203,8 +203,8 @@ discard block |
||
| 203 | 203 | * $ast->getEndLine(); // 2 (last significant character of a function) |
| 204 | 204 | * </code> |
| 205 | 205 | */ |
| 206 | - while ($line-- > 0) { |
|
| 207 | - if ($result = $attributes[$line] ?? null) { |
|
| 206 | + while ($line-- > 0){ |
|
| 207 | + if ($result = $attributes[$line] ?? null){ |
|
| 208 | 208 | return $result; |
| 209 | 209 | } |
| 210 | 210 | } |
@@ -219,8 +219,8 @@ discard block |
||
| 219 | 219 | */ |
| 220 | 220 | private function format(iterable $attributes, ?string $name): iterable |
| 221 | 221 | { |
| 222 | - foreach ($attributes as $prototype) { |
|
| 223 | - if ($name !== null && !\is_subclass_of($prototype->name, $name) && $prototype->name !== $name) { |
|
| 222 | + foreach ($attributes as $prototype){ |
|
| 223 | + if ($name !== null && !\is_subclass_of($prototype->name, $name) && $prototype->name !== $name){ |
|
| 224 | 224 | continue; |
| 225 | 225 | } |
| 226 | 226 | |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | */ |
| 238 | 238 | private function parseAttributes(string $file, int $context): array |
| 239 | 239 | { |
| 240 | - if (!isset($this->attributes[$file])) { |
|
| 240 | + if (!isset($this->attributes[$file])){ |
|
| 241 | 241 | $found = $this->parser->parse($file); |
| 242 | 242 | |
| 243 | 243 | $this->attributes[$file] = [ |
@@ -71,7 +71,8 @@ discard block |
||
| 71 | 71 | { |
| 72 | 72 | // 1) Can not parse internal classes |
| 73 | 73 | // 2) Anonymous classes don't support attributes (PHP semantic) |
| 74 | - if ($class->isInternal() || $class->isAnonymous()) { |
|
| 74 | + if ($class->isInternal() || $class->isAnonymous()) |
|
| 75 | + { |
|
| 75 | 76 | return []; |
| 76 | 77 | } |
| 77 | 78 | |
@@ -86,7 +87,8 @@ discard block |
||
| 86 | 87 | protected function getFunctionAttributes(\ReflectionFunctionAbstract $function, ?string $name): iterable |
| 87 | 88 | { |
| 88 | 89 | // Can not parse internal functions |
| 89 | - if ($function->isInternal()) { |
|
| 90 | + if ($function->isInternal()) |
|
| 91 | + { |
|
| 90 | 92 | return []; |
| 91 | 93 | } |
| 92 | 94 | |
@@ -104,7 +106,8 @@ discard block |
||
| 104 | 106 | $class = $property->getDeclaringClass(); |
| 105 | 107 | |
| 106 | 108 | // Can not parse property of internal class |
| 107 | - if ($class->isInternal()) { |
|
| 109 | + if ($class->isInternal()) |
|
| 110 | + { |
|
| 108 | 111 | return []; |
| 109 | 112 | } |
| 110 | 113 | |
@@ -121,7 +124,8 @@ discard block |
||
| 121 | 124 | $class = $const->getDeclaringClass(); |
| 122 | 125 | |
| 123 | 126 | // Can not parse internal classes |
| 124 | - if ($class->isInternal()) { |
|
| 127 | + if ($class->isInternal()) |
|
| 128 | + { |
|
| 125 | 129 | return []; |
| 126 | 130 | } |
| 127 | 131 | |
@@ -138,7 +142,8 @@ discard block |
||
| 138 | 142 | $function = $param->getDeclaringFunction(); |
| 139 | 143 | |
| 140 | 144 | // Can not parse parameter of internal function |
| 141 | - if ($function->isInternal()) { |
|
| 145 | + if ($function->isInternal()) |
|
| 146 | + { |
|
| 142 | 147 | return []; |
| 143 | 148 | } |
| 144 | 149 | |
@@ -178,7 +183,8 @@ discard block |
||
| 178 | 183 | */ |
| 179 | 184 | $line = $function->getEndLine(); |
| 180 | 185 | |
| 181 | - if ($result = $attributes[$line] ?? null) { |
|
| 186 | + if ($result = $attributes[$line] ?? null) |
|
| 187 | + { |
|
| 182 | 188 | return $result; |
| 183 | 189 | } |
| 184 | 190 | |
@@ -203,8 +209,10 @@ discard block |
||
| 203 | 209 | * $ast->getEndLine(); // 2 (last significant character of a function) |
| 204 | 210 | * </code> |
| 205 | 211 | */ |
| 206 | - while ($line-- > 0) { |
|
| 207 | - if ($result = $attributes[$line] ?? null) { |
|
| 212 | + while ($line-- > 0) |
|
| 213 | + { |
|
| 214 | + if ($result = $attributes[$line] ?? null) |
|
| 215 | + { |
|
| 208 | 216 | return $result; |
| 209 | 217 | } |
| 210 | 218 | } |
@@ -219,8 +227,10 @@ discard block |
||
| 219 | 227 | */ |
| 220 | 228 | private function format(iterable $attributes, ?string $name): iterable |
| 221 | 229 | { |
| 222 | - foreach ($attributes as $prototype) { |
|
| 223 | - if ($name !== null && !\is_subclass_of($prototype->name, $name) && $prototype->name !== $name) { |
|
| 230 | + foreach ($attributes as $prototype) |
|
| 231 | + { |
|
| 232 | + if ($name !== null && !\is_subclass_of($prototype->name, $name) && $prototype->name !== $name) |
|
| 233 | + { |
|
| 224 | 234 | continue; |
| 225 | 235 | } |
| 226 | 236 | |
@@ -237,7 +247,8 @@ discard block |
||
| 237 | 247 | */ |
| 238 | 248 | private function parseAttributes(string $file, int $context): array |
| 239 | 249 | { |
| 240 | - if (!isset($this->attributes[$file])) { |
|
| 250 | + if (!isset($this->attributes[$file])) |
|
| 251 | + { |
|
| 241 | 252 | $found = $this->parser->parse($file); |
| 242 | 253 | |
| 243 | 254 | $this->attributes[$file] = [ |
@@ -24,15 +24,15 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | protected function getConstructor(\ReflectionClass $class): ?\ReflectionMethod |
| 26 | 26 | { |
| 27 | - if ($class->hasMethod(self::CONSTRUCTOR_NAME)) { |
|
| 27 | + if ($class->hasMethod(self::CONSTRUCTOR_NAME)){ |
|
| 28 | 28 | return $class->getMethod(self::CONSTRUCTOR_NAME); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - if ($constructor = $this->getTraitConstructors($class)) { |
|
| 31 | + if ($constructor = $this->getTraitConstructors($class)){ |
|
| 32 | 32 | return $constructor; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - if ($parent = $class->getParentClass()) { |
|
| 35 | + if ($parent = $class->getParentClass()){ |
|
| 36 | 36 | return $this->getConstructor($parent); |
| 37 | 37 | } |
| 38 | 38 | |
@@ -45,12 +45,12 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | private function getTraitConstructors(\ReflectionClass $class): ?\ReflectionMethod |
| 47 | 47 | { |
| 48 | - foreach ($class->getTraits() as $trait) { |
|
| 49 | - if ($constructor = $this->getConstructor($trait)) { |
|
| 48 | + foreach ($class->getTraits() as $trait){ |
|
| 49 | + if ($constructor = $this->getConstructor($trait)){ |
|
| 50 | 50 | return $constructor; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - if ($constructor = $this->getTraitConstructors($trait)) { |
|
| 53 | + if ($constructor = $this->getTraitConstructors($trait)){ |
|
| 54 | 54 | return $constructor; |
| 55 | 55 | } |
| 56 | 56 | } |
@@ -24,15 +24,18 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | protected function getConstructor(\ReflectionClass $class): ?\ReflectionMethod |
| 26 | 26 | { |
| 27 | - if ($class->hasMethod(self::CONSTRUCTOR_NAME)) { |
|
| 27 | + if ($class->hasMethod(self::CONSTRUCTOR_NAME)) |
|
| 28 | + { |
|
| 28 | 29 | return $class->getMethod(self::CONSTRUCTOR_NAME); |
| 29 | 30 | } |
| 30 | 31 | |
| 31 | - if ($constructor = $this->getTraitConstructors($class)) { |
|
| 32 | + if ($constructor = $this->getTraitConstructors($class)) |
|
| 33 | + { |
|
| 32 | 34 | return $constructor; |
| 33 | 35 | } |
| 34 | 36 | |
| 35 | - if ($parent = $class->getParentClass()) { |
|
| 37 | + if ($parent = $class->getParentClass()) |
|
| 38 | + { |
|
| 36 | 39 | return $this->getConstructor($parent); |
| 37 | 40 | } |
| 38 | 41 | |
@@ -45,12 +48,15 @@ discard block |
||
| 45 | 48 | */ |
| 46 | 49 | private function getTraitConstructors(\ReflectionClass $class): ?\ReflectionMethod |
| 47 | 50 | { |
| 48 | - foreach ($class->getTraits() as $trait) { |
|
| 49 | - if ($constructor = $this->getConstructor($trait)) { |
|
| 51 | + foreach ($class->getTraits() as $trait) |
|
| 52 | + { |
|
| 53 | + if ($constructor = $this->getConstructor($trait)) |
|
| 54 | + { |
|
| 50 | 55 | return $constructor; |
| 51 | 56 | } |
| 52 | 57 | |
| 53 | - if ($constructor = $this->getTraitConstructors($trait)) { |
|
| 58 | + if ($constructor = $this->getTraitConstructors($trait)) |
|
| 59 | + { |
|
| 54 | 60 | return $constructor; |
| 55 | 61 | } |
| 56 | 62 | } |
@@ -42,7 +42,7 @@ |
||
| 42 | 42 | */ |
| 43 | 43 | public function instantiate(\ReflectionClass $attr, array $arguments, string $context): object |
| 44 | 44 | { |
| 45 | - if ($this->isNamedArguments($attr)) { |
|
| 45 | + if ($this->isNamedArguments($attr)){ |
|
| 46 | 46 | return $this->named->instantiate($attr, $arguments, $context); |
| 47 | 47 | } |
| 48 | 48 | |
@@ -42,7 +42,8 @@ |
||
| 42 | 42 | */ |
| 43 | 43 | public function instantiate(\ReflectionClass $attr, array $arguments, string $context): object |
| 44 | 44 | { |
| 45 | - if ($this->isNamedArguments($attr)) { |
|
| 45 | + if ($this->isNamedArguments($attr)) |
|
| 46 | + { |
|
| 46 | 47 | return $this->named->instantiate($attr, $arguments, $context); |
| 47 | 48 | } |
| 48 | 49 | |
@@ -38,17 +38,17 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | public function instantiate(\ReflectionClass $attr, array $arguments, string $context): object |
| 40 | 40 | { |
| 41 | - if ($this->isNamedArgumentsSupported()) { |
|
| 42 | - try { |
|
| 41 | + if ($this->isNamedArgumentsSupported()){ |
|
| 42 | + try{ |
|
| 43 | 43 | return $attr->newInstanceArgs($arguments); |
| 44 | - } catch (\Throwable $e) { |
|
| 44 | + }catch (\Throwable $e){ |
|
| 45 | 45 | throw Exception::withLocation($e, $attr->getFileName(), $attr->getStartLine()); |
| 46 | 46 | } |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | $constructor = $this->getConstructor($attr); |
| 50 | 50 | |
| 51 | - if ($constructor === null) { |
|
| 51 | + if ($constructor === null){ |
|
| 52 | 52 | return $attr->newInstanceWithoutConstructor(); |
| 53 | 53 | } |
| 54 | 54 | |
@@ -76,16 +76,16 @@ discard block |
||
| 76 | 76 | { |
| 77 | 77 | $passed = []; |
| 78 | 78 | |
| 79 | - try { |
|
| 80 | - foreach ($constructor->getParameters() as $parameter) { |
|
| 79 | + try{ |
|
| 80 | + foreach ($constructor->getParameters() as $parameter){ |
|
| 81 | 81 | $passed[] = $this->resolveParameter($ctx, $parameter, $arguments); |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - if (\count($arguments)) { |
|
| 84 | + if (\count($arguments)){ |
|
| 85 | 85 | $message = \sprintf(self::ERROR_UNKNOWN_ARGUMENT, \array_key_first($arguments)); |
| 86 | 86 | throw new \BadMethodCallException($message); |
| 87 | 87 | } |
| 88 | - } catch (\Throwable $e) { |
|
| 88 | + }catch (\Throwable $e){ |
|
| 89 | 89 | throw Exception::withLocation($e, $constructor->getFileName(), $constructor->getStartLine()); |
| 90 | 90 | } |
| 91 | 91 | |
@@ -101,18 +101,18 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | private function resolveParameter(\ReflectionClass $ctx, \ReflectionParameter $param, array &$arguments) |
| 103 | 103 | { |
| 104 | - switch (true) { |
|
| 104 | + switch (true){ |
|
| 105 | 105 | case \array_key_exists($param->getName(), $arguments): |
| 106 | - try { |
|
| 106 | + try{ |
|
| 107 | 107 | return $arguments[$param->getName()]; |
| 108 | - } finally { |
|
| 108 | + }finally{ |
|
| 109 | 109 | unset($arguments[$param->getName()]); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | case \array_key_exists($param->getPosition(), $arguments): |
| 113 | - try { |
|
| 113 | + try{ |
|
| 114 | 114 | return $arguments[$param->getPosition()]; |
| 115 | - } finally { |
|
| 115 | + }finally{ |
|
| 116 | 116 | unset($arguments[$param->getPosition()]); |
| 117 | 117 | } |
| 118 | 118 | |
@@ -38,17 +38,22 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | public function instantiate(\ReflectionClass $attr, array $arguments, string $context): object |
| 40 | 40 | { |
| 41 | - if ($this->isNamedArgumentsSupported()) { |
|
| 42 | - try { |
|
| 41 | + if ($this->isNamedArgumentsSupported()) |
|
| 42 | + { |
|
| 43 | + try |
|
| 44 | + { |
|
| 43 | 45 | return $attr->newInstanceArgs($arguments); |
| 44 | - } catch (\Throwable $e) { |
|
| 46 | + } |
|
| 47 | + catch (\Throwable $e) |
|
| 48 | + { |
|
| 45 | 49 | throw Exception::withLocation($e, $attr->getFileName(), $attr->getStartLine()); |
| 46 | 50 | } |
| 47 | 51 | } |
| 48 | 52 | |
| 49 | 53 | $constructor = $this->getConstructor($attr); |
| 50 | 54 | |
| 51 | - if ($constructor === null) { |
|
| 55 | + if ($constructor === null) |
|
| 56 | + { |
|
| 52 | 57 | return $attr->newInstanceWithoutConstructor(); |
| 53 | 58 | } |
| 54 | 59 | |
@@ -76,16 +81,21 @@ discard block |
||
| 76 | 81 | { |
| 77 | 82 | $passed = []; |
| 78 | 83 | |
| 79 | - try { |
|
| 80 | - foreach ($constructor->getParameters() as $parameter) { |
|
| 84 | + try |
|
| 85 | + { |
|
| 86 | + foreach ($constructor->getParameters() as $parameter) |
|
| 87 | + { |
|
| 81 | 88 | $passed[] = $this->resolveParameter($ctx, $parameter, $arguments); |
| 82 | 89 | } |
| 83 | 90 | |
| 84 | - if (\count($arguments)) { |
|
| 91 | + if (\count($arguments)) |
|
| 92 | + { |
|
| 85 | 93 | $message = \sprintf(self::ERROR_UNKNOWN_ARGUMENT, \array_key_first($arguments)); |
| 86 | 94 | throw new \BadMethodCallException($message); |
| 87 | 95 | } |
| 88 | - } catch (\Throwable $e) { |
|
| 96 | + } |
|
| 97 | + catch (\Throwable $e) |
|
| 98 | + { |
|
| 89 | 99 | throw Exception::withLocation($e, $constructor->getFileName(), $constructor->getStartLine()); |
| 90 | 100 | } |
| 91 | 101 | |
@@ -101,18 +111,25 @@ discard block |
||
| 101 | 111 | */ |
| 102 | 112 | private function resolveParameter(\ReflectionClass $ctx, \ReflectionParameter $param, array &$arguments) |
| 103 | 113 | { |
| 104 | - switch (true) { |
|
| 114 | + switch (true) |
|
| 115 | + { |
|
| 105 | 116 | case \array_key_exists($param->getName(), $arguments): |
| 106 | - try { |
|
| 117 | + try |
|
| 118 | + { |
|
| 107 | 119 | return $arguments[$param->getName()]; |
| 108 | - } finally { |
|
| 120 | + } |
|
| 121 | + finally |
|
| 122 | + { |
|
| 109 | 123 | unset($arguments[$param->getName()]); |
| 110 | 124 | } |
| 111 | 125 | |
| 112 | 126 | case \array_key_exists($param->getPosition(), $arguments): |
| 113 | - try { |
|
| 127 | + try |
|
| 128 | + { |
|
| 114 | 129 | return $arguments[$param->getPosition()]; |
| 115 | - } finally { |
|
| 130 | + } |
|
| 131 | + finally |
|
| 132 | + { |
|
| 116 | 133 | unset($arguments[$param->getPosition()]); |
| 117 | 134 | } |
| 118 | 135 | |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * @var string |
| 31 | 31 | */ |
| 32 | 32 | private const ERROR_INVALID_PROPERTY = |
| 33 | - 'The attribute #[%s] declared on %s does not have a property named "%s".' . "\n" . |
|
| 33 | + 'The attribute #[%s] declared on %s does not have a property named "%s".'."\n". |
|
| 34 | 34 | 'Available properties: %s' |
| 35 | 35 | ; |
| 36 | 36 | |
@@ -61,23 +61,23 @@ discard block |
||
| 61 | 61 | $arguments = $this->formatArguments($arguments); |
| 62 | 62 | |
| 63 | 63 | // Using constructor |
| 64 | - if ($this->getConstructor($attr)) { |
|
| 64 | + if ($this->getConstructor($attr)){ |
|
| 65 | 65 | return $attr->newInstance($arguments); |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | // Using direct insert |
| 69 | 69 | $instance = $attr->newInstanceWithoutConstructor(); |
| 70 | 70 | |
| 71 | - foreach ($arguments as $name => $value) { |
|
| 72 | - try { |
|
| 71 | + foreach ($arguments as $name => $value){ |
|
| 72 | + try{ |
|
| 73 | 73 | $property = $attr->getProperty($name); |
| 74 | 74 | |
| 75 | - if (!$property->isPublic()) { |
|
| 75 | + if (!$property->isPublic()){ |
|
| 76 | 76 | throw $this->propertyNotFound($attr, $name, $context); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | $instance->$name = $value; |
| 80 | - } catch (\Throwable $e) { |
|
| 80 | + }catch (\Throwable $e){ |
|
| 81 | 81 | throw $this->propertyNotFound($attr, $name, $context); |
| 82 | 82 | } |
| 83 | 83 | } |
@@ -93,8 +93,8 @@ discard block |
||
| 93 | 93 | { |
| 94 | 94 | $result = []; |
| 95 | 95 | |
| 96 | - foreach ($arguments as $name => $value) { |
|
| 97 | - if (\is_int($name)) { |
|
| 96 | + foreach ($arguments as $name => $value){ |
|
| 97 | + if (\is_int($name)){ |
|
| 98 | 98 | $this->validateArgumentPosition($name, $value); |
| 99 | 99 | |
| 100 | 100 | $name = self::DEFAULT_PROPERTY_NAME; |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | private function validateArgumentPosition(int $index, $value): void |
| 114 | 114 | { |
| 115 | - if ($index === 0) { |
|
| 115 | + if ($index === 0){ |
|
| 116 | 116 | return; |
| 117 | 117 | } |
| 118 | 118 | |
@@ -61,23 +61,29 @@ discard block |
||
| 61 | 61 | $arguments = $this->formatArguments($arguments); |
| 62 | 62 | |
| 63 | 63 | // Using constructor |
| 64 | - if ($this->getConstructor($attr)) { |
|
| 64 | + if ($this->getConstructor($attr)) |
|
| 65 | + { |
|
| 65 | 66 | return $attr->newInstance($arguments); |
| 66 | 67 | } |
| 67 | 68 | |
| 68 | 69 | // Using direct insert |
| 69 | 70 | $instance = $attr->newInstanceWithoutConstructor(); |
| 70 | 71 | |
| 71 | - foreach ($arguments as $name => $value) { |
|
| 72 | - try { |
|
| 72 | + foreach ($arguments as $name => $value) |
|
| 73 | + { |
|
| 74 | + try |
|
| 75 | + { |
|
| 73 | 76 | $property = $attr->getProperty($name); |
| 74 | 77 | |
| 75 | - if (!$property->isPublic()) { |
|
| 78 | + if (!$property->isPublic()) |
|
| 79 | + { |
|
| 76 | 80 | throw $this->propertyNotFound($attr, $name, $context); |
| 77 | 81 | } |
| 78 | 82 | |
| 79 | 83 | $instance->$name = $value; |
| 80 | - } catch (\Throwable $e) { |
|
| 84 | + } |
|
| 85 | + catch (\Throwable $e) |
|
| 86 | + { |
|
| 81 | 87 | throw $this->propertyNotFound($attr, $name, $context); |
| 82 | 88 | } |
| 83 | 89 | } |
@@ -93,8 +99,10 @@ discard block |
||
| 93 | 99 | { |
| 94 | 100 | $result = []; |
| 95 | 101 | |
| 96 | - foreach ($arguments as $name => $value) { |
|
| 97 | - if (\is_int($name)) { |
|
| 102 | + foreach ($arguments as $name => $value) |
|
| 103 | + { |
|
| 104 | + if (\is_int($name)) |
|
| 105 | + { |
|
| 98 | 106 | $this->validateArgumentPosition($name, $value); |
| 99 | 107 | |
| 100 | 108 | $name = self::DEFAULT_PROPERTY_NAME; |
@@ -112,7 +120,8 @@ discard block |
||
| 112 | 120 | */ |
| 113 | 121 | private function validateArgumentPosition(int $index, $value): void |
| 114 | 122 | { |
| 115 | - if ($index === 0) { |
|
| 123 | + if ($index === 0) |
|
| 124 | + { |
|
| 116 | 125 | return; |
| 117 | 126 | } |
| 118 | 127 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | private function bootAnnotations(): void |
| 42 | 42 | { |
| 43 | 43 | // doctrine/annotations ^1.0 compatibility. |
| 44 | - if (\method_exists(AnnotationRegistry::class, 'registerLoader')) { |
|
| 44 | + if (\method_exists(AnnotationRegistry::class, 'registerLoader')){ |
|
| 45 | 45 | AnnotationRegistry::registerLoader('\\class_exists'); |
| 46 | 46 | } |
| 47 | 47 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | public function getFunctionMetadata(\ReflectionFunctionAbstract $function, string $name = null): iterable |
| 63 | 63 | { |
| 64 | - if ($function instanceof \ReflectionMethod) { |
|
| 64 | + if ($function instanceof \ReflectionMethod){ |
|
| 65 | 65 | $result = $this->reader->getMethodAnnotations($function); |
| 66 | 66 | |
| 67 | 67 | return $this->filter($name, $result); |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | private function checkAvailability(): void |
| 111 | 111 | { |
| 112 | - if ($this->isAvailable()) { |
|
| 112 | + if ($this->isAvailable()){ |
|
| 113 | 113 | return; |
| 114 | 114 | } |
| 115 | 115 | |
@@ -123,14 +123,14 @@ discard block |
||
| 123 | 123 | */ |
| 124 | 124 | private function filter(?string $name, iterable $annotations): iterable |
| 125 | 125 | { |
| 126 | - if ($name === null) { |
|
| 126 | + if ($name === null){ |
|
| 127 | 127 | yield from $annotations; |
| 128 | 128 | |
| 129 | 129 | return; |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - foreach ($annotations as $annotation) { |
|
| 133 | - if ($annotation instanceof $name) { |
|
| 132 | + foreach ($annotations as $annotation){ |
|
| 133 | + if ($annotation instanceof $name){ |
|
| 134 | 134 | yield $annotation; |
| 135 | 135 | } |
| 136 | 136 | } |
@@ -41,7 +41,8 @@ discard block |
||
| 41 | 41 | private function bootAnnotations(): void |
| 42 | 42 | { |
| 43 | 43 | // doctrine/annotations ^1.0 compatibility. |
| 44 | - if (\method_exists(AnnotationRegistry::class, 'registerLoader')) { |
|
| 44 | + if (\method_exists(AnnotationRegistry::class, 'registerLoader')) |
|
| 45 | + { |
|
| 45 | 46 | AnnotationRegistry::registerLoader('\\class_exists'); |
| 46 | 47 | } |
| 47 | 48 | } |
@@ -61,7 +62,8 @@ discard block |
||
| 61 | 62 | */ |
| 62 | 63 | public function getFunctionMetadata(\ReflectionFunctionAbstract $function, string $name = null): iterable |
| 63 | 64 | { |
| 64 | - if ($function instanceof \ReflectionMethod) { |
|
| 65 | + if ($function instanceof \ReflectionMethod) |
|
| 66 | + { |
|
| 65 | 67 | $result = $this->reader->getMethodAnnotations($function); |
| 66 | 68 | |
| 67 | 69 | return $this->filter($name, $result); |
@@ -109,7 +111,8 @@ discard block |
||
| 109 | 111 | */ |
| 110 | 112 | private function checkAvailability(): void |
| 111 | 113 | { |
| 112 | - if ($this->isAvailable()) { |
|
| 114 | + if ($this->isAvailable()) |
|
| 115 | + { |
|
| 113 | 116 | return; |
| 114 | 117 | } |
| 115 | 118 | |
@@ -123,14 +126,17 @@ discard block |
||
| 123 | 126 | */ |
| 124 | 127 | private function filter(?string $name, iterable $annotations): iterable |
| 125 | 128 | { |
| 126 | - if ($name === null) { |
|
| 129 | + if ($name === null) |
|
| 130 | + { |
|
| 127 | 131 | yield from $annotations; |
| 128 | 132 | |
| 129 | 133 | return; |
| 130 | 134 | } |
| 131 | 135 | |
| 132 | - foreach ($annotations as $annotation) { |
|
| 133 | - if ($annotation instanceof $name) { |
|
| 136 | + foreach ($annotations as $annotation) |
|
| 137 | + { |
|
| 138 | + if ($annotation instanceof $name) |
|
| 139 | + { |
|
| 134 | 140 | yield $annotation; |
| 135 | 141 | } |
| 136 | 142 | } |