@@ -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,19 +101,19 @@ 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 | // no actual falling through |
| 112 | 112 | |
| 113 | 113 | case \array_key_exists($param->getPosition(), $arguments): |
| 114 | - try { |
|
| 114 | + try{ |
|
| 115 | 115 | return $arguments[$param->getPosition()]; |
| 116 | - } finally { |
|
| 116 | + }finally{ |
|
| 117 | 117 | unset($arguments[$param->getPosition()]); |
| 118 | 118 | } |
| 119 | 119 | // no actual falling through |
@@ -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,19 +111,26 @@ 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 | // no actual falling through |
| 112 | 126 | |
| 113 | 127 | case \array_key_exists($param->getPosition(), $arguments): |
| 114 | - try { |
|
| 128 | + try |
|
| 129 | + { |
|
| 115 | 130 | return $arguments[$param->getPosition()]; |
| 116 | - } finally { |
|
| 131 | + } |
|
| 132 | + finally |
|
| 133 | + { |
|
| 117 | 134 | unset($arguments[$param->getPosition()]); |
| 118 | 135 | } |
| 119 | 136 | // no actual falling through |