@@ -53,23 +53,23 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function write($source, SpecificationInterface $specification, Compiler $compiler) |
55 | 55 | { |
56 | - if (!$this->targetAcceptable($source)) { |
|
56 | + if (!$this->targetAcceptable($source)){ |
|
57 | 57 | return null; |
58 | 58 | } |
59 | 59 | |
60 | - if ($specification instanceof Specification\FilterInterface) { |
|
60 | + if ($specification instanceof Specification\FilterInterface){ |
|
61 | 61 | return $this->writeFilter($source, $specification, $compiler); |
62 | 62 | } |
63 | 63 | |
64 | - if ($specification instanceof Specification\SorterInterface) { |
|
64 | + if ($specification instanceof Specification\SorterInterface){ |
|
65 | 65 | return $this->writeSorter($source, $specification, $compiler); |
66 | 66 | } |
67 | 67 | |
68 | - if ($specification instanceof Specification\Pagination\Limit) { |
|
68 | + if ($specification instanceof Specification\Pagination\Limit){ |
|
69 | 69 | return $source->limit($specification->getValue()); |
70 | 70 | } |
71 | 71 | |
72 | - if ($specification instanceof Specification\Pagination\Offset) { |
|
72 | + if ($specification instanceof Specification\Pagination\Offset){ |
|
73 | 73 | return $source->offset($specification->getValue()); |
74 | 74 | } |
75 | 75 | |
@@ -84,15 +84,15 @@ discard block |
||
84 | 84 | */ |
85 | 85 | protected function writeFilter($source, Specification\FilterInterface $filter, Compiler $compiler) |
86 | 86 | { |
87 | - if ($filter instanceof Specification\Filter\All || $filter instanceof Specification\Filter\Map) { |
|
87 | + if ($filter instanceof Specification\Filter\All || $filter instanceof Specification\Filter\Map){ |
|
88 | 88 | return $source->where(static function () use ($compiler, $filter, $source): void { |
89 | 89 | $compiler->compile($source, ...$filter->getFilters()); |
90 | 90 | }); |
91 | 91 | } |
92 | 92 | |
93 | - if ($filter instanceof Specification\Filter\Any) { |
|
93 | + if ($filter instanceof Specification\Filter\Any){ |
|
94 | 94 | return $source->where(static function () use ($compiler, $filter, $source): void { |
95 | - foreach ($filter->getFilters() as $subFilter) { |
|
95 | + foreach ($filter->getFilters() as $subFilter){ |
|
96 | 96 | $source->orWhere(static function () use ($compiler, $subFilter, $source): void { |
97 | 97 | $compiler->compile($source, $subFilter); |
98 | 98 | }); |
@@ -100,9 +100,9 @@ discard block |
||
100 | 100 | }); |
101 | 101 | } |
102 | 102 | |
103 | - if ($filter instanceof Specification\Filter\InjectionFilter) { |
|
103 | + if ($filter instanceof Specification\Filter\InjectionFilter){ |
|
104 | 104 | $expression = $filter->getFilter(); |
105 | - if ($expression instanceof Specification\Filter\Expression) { |
|
105 | + if ($expression instanceof Specification\Filter\Expression){ |
|
106 | 106 | return $source->where( |
107 | 107 | $filter->getInjection(), |
108 | 108 | $this->getExpressionOperator($expression), |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | } |
112 | 112 | } |
113 | 113 | |
114 | - if ($filter instanceof Specification\Filter\Expression) { |
|
114 | + if ($filter instanceof Specification\Filter\Expression){ |
|
115 | 115 | return $source->where( |
116 | 116 | $filter->getExpression(), |
117 | 117 | $this->getExpressionOperator($filter), |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | */ |
129 | 129 | protected function getExpressionOperator(Specification\Filter\Expression $filter): string |
130 | 130 | { |
131 | - if ($filter instanceof Specification\Filter\Like) { |
|
131 | + if ($filter instanceof Specification\Filter\Like){ |
|
132 | 132 | return 'LIKE'; |
133 | 133 | } |
134 | 134 | |
135 | - if ($filter instanceof Specification\Filter\InArray || $filter instanceof Specification\Filter\NotInArray) { |
|
135 | + if ($filter instanceof Specification\Filter\InArray || $filter instanceof Specification\Filter\NotInArray){ |
|
136 | 136 | return static::ARRAY_OPERATORS[get_class($filter)]; |
137 | 137 | } |
138 | 138 | |
@@ -145,11 +145,11 @@ discard block |
||
145 | 145 | */ |
146 | 146 | protected function getExpressionArgs(Specification\Filter\Expression $filter): array |
147 | 147 | { |
148 | - if ($filter instanceof Specification\Filter\Like) { |
|
148 | + if ($filter instanceof Specification\Filter\Like){ |
|
149 | 149 | return [sprintf($filter->getPattern(), $this->fetchValue($filter->getValue()))]; |
150 | 150 | } |
151 | 151 | |
152 | - if ($filter instanceof Specification\Filter\InArray || $filter instanceof Specification\Filter\NotInArray) { |
|
152 | + if ($filter instanceof Specification\Filter\InArray || $filter instanceof Specification\Filter\NotInArray){ |
|
153 | 153 | return [new Parameter($this->fetchValue($filter->getValue()))]; |
154 | 154 | } |
155 | 155 | |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | */ |
165 | 165 | protected function writeSorter($source, Specification\SorterInterface $sorter, Compiler $compiler) |
166 | 166 | { |
167 | - if ($sorter instanceof Specification\Sorter\SorterSet) { |
|
168 | - foreach ($sorter->getSorters() as $subSorter) { |
|
167 | + if ($sorter instanceof Specification\Sorter\SorterSet){ |
|
168 | + foreach ($sorter->getSorters() as $subSorter){ |
|
169 | 169 | $source = $compiler->compile($source, $subSorter); |
170 | 170 | } |
171 | 171 | |
@@ -175,18 +175,18 @@ discard block |
||
175 | 175 | if ( |
176 | 176 | $sorter instanceof Specification\Sorter\AscSorter |
177 | 177 | || $sorter instanceof Specification\Sorter\DescSorter |
178 | - ) { |
|
178 | + ){ |
|
179 | 179 | $direction = static::SORTER_DIRECTIONS[get_class($sorter)]; |
180 | - foreach ($sorter->getExpressions() as $expression) { |
|
180 | + foreach ($sorter->getExpressions() as $expression){ |
|
181 | 181 | $source = $source->orderBy($expression, $direction); |
182 | 182 | } |
183 | 183 | |
184 | 184 | return $source; |
185 | 185 | } |
186 | 186 | |
187 | - if ($sorter instanceof InjectionSorter) { |
|
187 | + if ($sorter instanceof InjectionSorter){ |
|
188 | 188 | $direction = static::SORTER_DIRECTIONS[get_class($sorter)] ?? 'ASC'; |
189 | - foreach ($sorter->getInjections() as $injection) { |
|
189 | + foreach ($sorter->getInjections() as $injection){ |
|
190 | 190 | $source = $source->orderBy($injection, $direction); |
191 | 191 | } |
192 | 192 | |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | */ |
205 | 205 | protected function fetchValue($value) |
206 | 206 | { |
207 | - if ($value instanceof Specification\ValueInterface) { |
|
207 | + if ($value instanceof Specification\ValueInterface){ |
|
208 | 208 | throw new CompilerException('Value expects user input, none given'); |
209 | 209 | } |
210 | 210 | |
@@ -217,11 +217,11 @@ discard block |
||
217 | 217 | */ |
218 | 218 | protected function targetAcceptable($target): bool |
219 | 219 | { |
220 | - if (class_exists(SelectQuery::class) && $target instanceof SelectQuery) { |
|
220 | + if (class_exists(SelectQuery::class) && $target instanceof SelectQuery){ |
|
221 | 221 | return true; |
222 | 222 | } |
223 | 223 | |
224 | - if (class_exists(Select::class) && $target instanceof Select) { |
|
224 | + if (class_exists(Select::class) && $target instanceof Select){ |
|
225 | 225 | return true; |
226 | 226 | } |
227 | 227 |
@@ -53,23 +53,28 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function write($source, SpecificationInterface $specification, Compiler $compiler) |
55 | 55 | { |
56 | - if (!$this->targetAcceptable($source)) { |
|
56 | + if (!$this->targetAcceptable($source)) |
|
57 | + { |
|
57 | 58 | return null; |
58 | 59 | } |
59 | 60 | |
60 | - if ($specification instanceof Specification\FilterInterface) { |
|
61 | + if ($specification instanceof Specification\FilterInterface) |
|
62 | + { |
|
61 | 63 | return $this->writeFilter($source, $specification, $compiler); |
62 | 64 | } |
63 | 65 | |
64 | - if ($specification instanceof Specification\SorterInterface) { |
|
66 | + if ($specification instanceof Specification\SorterInterface) |
|
67 | + { |
|
65 | 68 | return $this->writeSorter($source, $specification, $compiler); |
66 | 69 | } |
67 | 70 | |
68 | - if ($specification instanceof Specification\Pagination\Limit) { |
|
71 | + if ($specification instanceof Specification\Pagination\Limit) |
|
72 | + { |
|
69 | 73 | return $source->limit($specification->getValue()); |
70 | 74 | } |
71 | 75 | |
72 | - if ($specification instanceof Specification\Pagination\Offset) { |
|
76 | + if ($specification instanceof Specification\Pagination\Offset) |
|
77 | + { |
|
73 | 78 | return $source->offset($specification->getValue()); |
74 | 79 | } |
75 | 80 | |
@@ -84,15 +89,18 @@ discard block |
||
84 | 89 | */ |
85 | 90 | protected function writeFilter($source, Specification\FilterInterface $filter, Compiler $compiler) |
86 | 91 | { |
87 | - if ($filter instanceof Specification\Filter\All || $filter instanceof Specification\Filter\Map) { |
|
92 | + if ($filter instanceof Specification\Filter\All || $filter instanceof Specification\Filter\Map) |
|
93 | + { |
|
88 | 94 | return $source->where(static function () use ($compiler, $filter, $source): void { |
89 | 95 | $compiler->compile($source, ...$filter->getFilters()); |
90 | 96 | }); |
91 | 97 | } |
92 | 98 | |
93 | - if ($filter instanceof Specification\Filter\Any) { |
|
99 | + if ($filter instanceof Specification\Filter\Any) |
|
100 | + { |
|
94 | 101 | return $source->where(static function () use ($compiler, $filter, $source): void { |
95 | - foreach ($filter->getFilters() as $subFilter) { |
|
102 | + foreach ($filter->getFilters() as $subFilter) |
|
103 | + { |
|
96 | 104 | $source->orWhere(static function () use ($compiler, $subFilter, $source): void { |
97 | 105 | $compiler->compile($source, $subFilter); |
98 | 106 | }); |
@@ -100,9 +108,11 @@ discard block |
||
100 | 108 | }); |
101 | 109 | } |
102 | 110 | |
103 | - if ($filter instanceof Specification\Filter\InjectionFilter) { |
|
111 | + if ($filter instanceof Specification\Filter\InjectionFilter) |
|
112 | + { |
|
104 | 113 | $expression = $filter->getFilter(); |
105 | - if ($expression instanceof Specification\Filter\Expression) { |
|
114 | + if ($expression instanceof Specification\Filter\Expression) |
|
115 | + { |
|
106 | 116 | return $source->where( |
107 | 117 | $filter->getInjection(), |
108 | 118 | $this->getExpressionOperator($expression), |
@@ -111,7 +121,8 @@ discard block |
||
111 | 121 | } |
112 | 122 | } |
113 | 123 | |
114 | - if ($filter instanceof Specification\Filter\Expression) { |
|
124 | + if ($filter instanceof Specification\Filter\Expression) |
|
125 | + { |
|
115 | 126 | return $source->where( |
116 | 127 | $filter->getExpression(), |
117 | 128 | $this->getExpressionOperator($filter), |
@@ -128,11 +139,13 @@ discard block |
||
128 | 139 | */ |
129 | 140 | protected function getExpressionOperator(Specification\Filter\Expression $filter): string |
130 | 141 | { |
131 | - if ($filter instanceof Specification\Filter\Like) { |
|
142 | + if ($filter instanceof Specification\Filter\Like) |
|
143 | + { |
|
132 | 144 | return 'LIKE'; |
133 | 145 | } |
134 | 146 | |
135 | - if ($filter instanceof Specification\Filter\InArray || $filter instanceof Specification\Filter\NotInArray) { |
|
147 | + if ($filter instanceof Specification\Filter\InArray || $filter instanceof Specification\Filter\NotInArray) |
|
148 | + { |
|
136 | 149 | return static::ARRAY_OPERATORS[get_class($filter)]; |
137 | 150 | } |
138 | 151 | |
@@ -145,11 +158,13 @@ discard block |
||
145 | 158 | */ |
146 | 159 | protected function getExpressionArgs(Specification\Filter\Expression $filter): array |
147 | 160 | { |
148 | - if ($filter instanceof Specification\Filter\Like) { |
|
161 | + if ($filter instanceof Specification\Filter\Like) |
|
162 | + { |
|
149 | 163 | return [sprintf($filter->getPattern(), $this->fetchValue($filter->getValue()))]; |
150 | 164 | } |
151 | 165 | |
152 | - if ($filter instanceof Specification\Filter\InArray || $filter instanceof Specification\Filter\NotInArray) { |
|
166 | + if ($filter instanceof Specification\Filter\InArray || $filter instanceof Specification\Filter\NotInArray) |
|
167 | + { |
|
153 | 168 | return [new Parameter($this->fetchValue($filter->getValue()))]; |
154 | 169 | } |
155 | 170 | |
@@ -164,8 +179,10 @@ discard block |
||
164 | 179 | */ |
165 | 180 | protected function writeSorter($source, Specification\SorterInterface $sorter, Compiler $compiler) |
166 | 181 | { |
167 | - if ($sorter instanceof Specification\Sorter\SorterSet) { |
|
168 | - foreach ($sorter->getSorters() as $subSorter) { |
|
182 | + if ($sorter instanceof Specification\Sorter\SorterSet) |
|
183 | + { |
|
184 | + foreach ($sorter->getSorters() as $subSorter) |
|
185 | + { |
|
169 | 186 | $source = $compiler->compile($source, $subSorter); |
170 | 187 | } |
171 | 188 | |
@@ -177,16 +194,19 @@ discard block |
||
177 | 194 | || $sorter instanceof Specification\Sorter\DescSorter |
178 | 195 | ) { |
179 | 196 | $direction = static::SORTER_DIRECTIONS[get_class($sorter)]; |
180 | - foreach ($sorter->getExpressions() as $expression) { |
|
197 | + foreach ($sorter->getExpressions() as $expression) |
|
198 | + { |
|
181 | 199 | $source = $source->orderBy($expression, $direction); |
182 | 200 | } |
183 | 201 | |
184 | 202 | return $source; |
185 | 203 | } |
186 | 204 | |
187 | - if ($sorter instanceof InjectionSorter) { |
|
205 | + if ($sorter instanceof InjectionSorter) |
|
206 | + { |
|
188 | 207 | $direction = static::SORTER_DIRECTIONS[get_class($sorter)] ?? 'ASC'; |
189 | - foreach ($sorter->getInjections() as $injection) { |
|
208 | + foreach ($sorter->getInjections() as $injection) |
|
209 | + { |
|
190 | 210 | $source = $source->orderBy($injection, $direction); |
191 | 211 | } |
192 | 212 | |
@@ -204,7 +224,8 @@ discard block |
||
204 | 224 | */ |
205 | 225 | protected function fetchValue($value) |
206 | 226 | { |
207 | - if ($value instanceof Specification\ValueInterface) { |
|
227 | + if ($value instanceof Specification\ValueInterface) |
|
228 | + { |
|
208 | 229 | throw new CompilerException('Value expects user input, none given'); |
209 | 230 | } |
210 | 231 | |
@@ -217,11 +238,13 @@ discard block |
||
217 | 238 | */ |
218 | 239 | protected function targetAcceptable($target): bool |
219 | 240 | { |
220 | - if (class_exists(SelectQuery::class) && $target instanceof SelectQuery) { |
|
241 | + if (class_exists(SelectQuery::class) && $target instanceof SelectQuery) |
|
242 | + { |
|
221 | 243 | return true; |
222 | 244 | } |
223 | 245 | |
224 | - if (class_exists(Select::class) && $target instanceof Select) { |
|
246 | + if (class_exists(Select::class) && $target instanceof Select) |
|
247 | + { |
|
225 | 248 | return true; |
226 | 249 | } |
227 | 250 |
@@ -26,14 +26,14 @@ |
||
26 | 26 | public function setUp(): void |
27 | 27 | { |
28 | 28 | $this->app = App::init([ |
29 | - 'root' => __DIR__ . '/App', |
|
30 | - 'app' => __DIR__ . '/App' |
|
29 | + 'root' => __DIR__.'/App', |
|
30 | + 'app' => __DIR__.'/App' |
|
31 | 31 | ]); |
32 | 32 | } |
33 | 33 | |
34 | 34 | public function tearDown(): void |
35 | 35 | { |
36 | - foreach (glob(__DIR__ . '/App/runtime/cache/views/*.php') as $file) { |
|
36 | + foreach (glob(__DIR__.'/App/runtime/cache/views/*.php') as $file){ |
|
37 | 37 | @unlink($file); |
38 | 38 | } |
39 | 39 | } |
@@ -33,7 +33,8 @@ |
||
33 | 33 | |
34 | 34 | public function tearDown(): void |
35 | 35 | { |
36 | - foreach (glob(__DIR__ . '/App/runtime/cache/views/*.php') as $file) { |
|
36 | + foreach (glob(__DIR__ . '/App/runtime/cache/views/*.php') as $file) |
|
37 | + { |
|
37 | 38 | @unlink($file); |
38 | 39 | } |
39 | 40 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | ReaderInterface $reader, |
33 | 33 | CacheItemPoolInterface $cache, |
34 | 34 | KeyGeneratorInterface $generator = null |
35 | - ) { |
|
35 | + ){ |
|
36 | 36 | $this->cache = $cache; |
37 | 37 | |
38 | 38 | parent::__construct($reader, $generator); |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | { |
47 | 47 | $item = $this->cache->getItem($key); |
48 | 48 | |
49 | - if (!$item->isHit()) { |
|
49 | + if (!$item->isHit()){ |
|
50 | 50 | $this->cache->save( |
51 | 51 | $item->set($then()) |
52 | 52 | ); |
@@ -46,7 +46,8 @@ |
||
46 | 46 | { |
47 | 47 | $item = $this->cache->getItem($key); |
48 | 48 | |
49 | - if (!$item->isHit()) { |
|
49 | + if (!$item->isHit()) |
|
50 | + { |
|
50 | 51 | $this->cache->save( |
51 | 52 | $item->set($then()) |
52 | 53 | ); |
@@ -41,7 +41,7 @@ |
||
41 | 41 | */ |
42 | 42 | protected function cached(string $key, callable $then): iterable |
43 | 43 | { |
44 | - if (!$this->cache->has($key)) { |
|
44 | + if (!$this->cache->has($key)){ |
|
45 | 45 | $this->cache->set($key, $then()); |
46 | 46 | } |
47 | 47 |
@@ -41,7 +41,8 @@ |
||
41 | 41 | */ |
42 | 42 | protected function cached(string $key, callable $then): iterable |
43 | 43 | { |
44 | - if (!$this->cache->has($key)) { |
|
44 | + if (!$this->cache->has($key)) |
|
45 | + { |
|
45 | 46 | $this->cache->set($key, $then()); |
46 | 47 | } |
47 | 48 |
@@ -34,17 +34,17 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function instantiate(\ReflectionClass $attr, array $arguments, \Reflector $context = null): object |
36 | 36 | { |
37 | - if ($this->isNamedArgumentsSupported()) { |
|
38 | - try { |
|
37 | + if ($this->isNamedArgumentsSupported()){ |
|
38 | + try{ |
|
39 | 39 | return $attr->newInstanceArgs($arguments); |
40 | - } catch (\Throwable $e) { |
|
40 | + }catch (\Throwable $e){ |
|
41 | 41 | throw Exception::withLocation($e, $attr->getFileName(), $attr->getStartLine()); |
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
45 | 45 | $constructor = $this->getConstructor($attr); |
46 | 46 | |
47 | - if ($constructor === null) { |
|
47 | + if ($constructor === null){ |
|
48 | 48 | return $attr->newInstanceWithoutConstructor(); |
49 | 49 | } |
50 | 50 | |
@@ -72,16 +72,16 @@ discard block |
||
72 | 72 | { |
73 | 73 | $passed = []; |
74 | 74 | |
75 | - try { |
|
76 | - foreach ($constructor->getParameters() as $parameter) { |
|
75 | + try{ |
|
76 | + foreach ($constructor->getParameters() as $parameter){ |
|
77 | 77 | $passed[] = $this->resolveParameter($ctx, $parameter, $arguments); |
78 | 78 | } |
79 | 79 | |
80 | - if (\count($arguments)) { |
|
80 | + if (\count($arguments)){ |
|
81 | 81 | $message = \sprintf(self::ERROR_UNKNOWN_ARGUMENT, \array_key_first($arguments)); |
82 | 82 | throw new \BadMethodCallException($message); |
83 | 83 | } |
84 | - } catch (\Throwable $e) { |
|
84 | + }catch (\Throwable $e){ |
|
85 | 85 | throw Exception::withLocation($e, $constructor->getFileName(), $constructor->getStartLine()); |
86 | 86 | } |
87 | 87 | |
@@ -97,19 +97,19 @@ discard block |
||
97 | 97 | */ |
98 | 98 | private function resolveParameter(\ReflectionClass $ctx, \ReflectionParameter $param, array &$arguments) |
99 | 99 | { |
100 | - switch (true) { |
|
100 | + switch (true){ |
|
101 | 101 | case \array_key_exists($param->getName(), $arguments): |
102 | - try { |
|
102 | + try{ |
|
103 | 103 | return $arguments[$param->getName()]; |
104 | - } finally { |
|
104 | + }finally{ |
|
105 | 105 | unset($arguments[$param->getName()]); |
106 | 106 | } |
107 | 107 | // no actual falling through |
108 | 108 | |
109 | 109 | case \array_key_exists($param->getPosition(), $arguments): |
110 | - try { |
|
110 | + try{ |
|
111 | 111 | return $arguments[$param->getPosition()]; |
112 | - } finally { |
|
112 | + }finally{ |
|
113 | 113 | unset($arguments[$param->getPosition()]); |
114 | 114 | } |
115 | 115 | // no actual falling through |
@@ -34,17 +34,22 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function instantiate(\ReflectionClass $attr, array $arguments, \Reflector $context = null): object |
36 | 36 | { |
37 | - if ($this->isNamedArgumentsSupported()) { |
|
38 | - try { |
|
37 | + if ($this->isNamedArgumentsSupported()) |
|
38 | + { |
|
39 | + try |
|
40 | + { |
|
39 | 41 | return $attr->newInstanceArgs($arguments); |
40 | - } catch (\Throwable $e) { |
|
42 | + } |
|
43 | + catch (\Throwable $e) |
|
44 | + { |
|
41 | 45 | throw Exception::withLocation($e, $attr->getFileName(), $attr->getStartLine()); |
42 | 46 | } |
43 | 47 | } |
44 | 48 | |
45 | 49 | $constructor = $this->getConstructor($attr); |
46 | 50 | |
47 | - if ($constructor === null) { |
|
51 | + if ($constructor === null) |
|
52 | + { |
|
48 | 53 | return $attr->newInstanceWithoutConstructor(); |
49 | 54 | } |
50 | 55 | |
@@ -72,16 +77,21 @@ discard block |
||
72 | 77 | { |
73 | 78 | $passed = []; |
74 | 79 | |
75 | - try { |
|
76 | - foreach ($constructor->getParameters() as $parameter) { |
|
80 | + try |
|
81 | + { |
|
82 | + foreach ($constructor->getParameters() as $parameter) |
|
83 | + { |
|
77 | 84 | $passed[] = $this->resolveParameter($ctx, $parameter, $arguments); |
78 | 85 | } |
79 | 86 | |
80 | - if (\count($arguments)) { |
|
87 | + if (\count($arguments)) |
|
88 | + { |
|
81 | 89 | $message = \sprintf(self::ERROR_UNKNOWN_ARGUMENT, \array_key_first($arguments)); |
82 | 90 | throw new \BadMethodCallException($message); |
83 | 91 | } |
84 | - } catch (\Throwable $e) { |
|
92 | + } |
|
93 | + catch (\Throwable $e) |
|
94 | + { |
|
85 | 95 | throw Exception::withLocation($e, $constructor->getFileName(), $constructor->getStartLine()); |
86 | 96 | } |
87 | 97 | |
@@ -97,19 +107,26 @@ discard block |
||
97 | 107 | */ |
98 | 108 | private function resolveParameter(\ReflectionClass $ctx, \ReflectionParameter $param, array &$arguments) |
99 | 109 | { |
100 | - switch (true) { |
|
110 | + switch (true) |
|
111 | + { |
|
101 | 112 | case \array_key_exists($param->getName(), $arguments): |
102 | - try { |
|
113 | + try |
|
114 | + { |
|
103 | 115 | return $arguments[$param->getName()]; |
104 | - } finally { |
|
116 | + } |
|
117 | + finally |
|
118 | + { |
|
105 | 119 | unset($arguments[$param->getName()]); |
106 | 120 | } |
107 | 121 | // no actual falling through |
108 | 122 | |
109 | 123 | case \array_key_exists($param->getPosition(), $arguments): |
110 | - try { |
|
124 | + try |
|
125 | + { |
|
111 | 126 | return $arguments[$param->getPosition()]; |
112 | - } finally { |
|
127 | + } |
|
128 | + finally |
|
129 | + { |
|
113 | 130 | unset($arguments[$param->getPosition()]); |
114 | 131 | } |
115 | 132 | // no actual falling through |
@@ -124,7 +124,7 @@ |
||
124 | 124 | */ |
125 | 125 | protected function iterableToArray(iterable $attributes): array |
126 | 126 | { |
127 | - if ($attributes instanceof \Traversable) { |
|
127 | + if ($attributes instanceof \Traversable){ |
|
128 | 128 | return \iterator_to_array($attributes, false); |
129 | 129 | } |
130 | 130 |
@@ -41,7 +41,8 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function getClassMetadata(\ReflectionClass $class, string $name = null): iterable |
43 | 43 | { |
44 | - $result = $this->cached($this->key->forClass($class), function () use ($class) { |
|
44 | + $result = $this->cached($this->key->forClass($class), function () use ($class) |
|
45 | + { |
|
45 | 46 | return $this->iterableToArray(parent::getClassMetadata($class)); |
46 | 47 | }); |
47 | 48 | |
@@ -53,7 +54,8 @@ discard block |
||
53 | 54 | */ |
54 | 55 | public function getFunctionMetadata(\ReflectionFunctionAbstract $function, string $name = null): iterable |
55 | 56 | { |
56 | - $result = $this->cached($this->key->forFunction($function), function () use ($function) { |
|
57 | + $result = $this->cached($this->key->forFunction($function), function () use ($function) |
|
58 | + { |
|
57 | 59 | return $this->iterableToArray(parent::getFunctionMetadata($function)); |
58 | 60 | }); |
59 | 61 | |
@@ -65,7 +67,8 @@ discard block |
||
65 | 67 | */ |
66 | 68 | public function getPropertyMetadata(\ReflectionProperty $property, string $name = null): iterable |
67 | 69 | { |
68 | - $result = $this->cached($this->key->forProperty($property), function () use ($property) { |
|
70 | + $result = $this->cached($this->key->forProperty($property), function () use ($property) |
|
71 | + { |
|
69 | 72 | return $this->iterableToArray(parent::getPropertyMetadata($property)); |
70 | 73 | }); |
71 | 74 | |
@@ -77,7 +80,8 @@ discard block |
||
77 | 80 | */ |
78 | 81 | public function getConstantMetadata(\ReflectionClassConstant $constant, string $name = null): iterable |
79 | 82 | { |
80 | - $result = $this->cached($this->key->forConstant($constant), function () use ($constant) { |
|
83 | + $result = $this->cached($this->key->forConstant($constant), function () use ($constant) |
|
84 | + { |
|
81 | 85 | return $this->iterableToArray(parent::getConstantMetadata($constant)); |
82 | 86 | }); |
83 | 87 | |
@@ -89,7 +93,8 @@ discard block |
||
89 | 93 | */ |
90 | 94 | public function getParameterMetadata(\ReflectionParameter $parameter, string $name = null): iterable |
91 | 95 | { |
92 | - $result = $this->cached($this->key->forParameter($parameter), function () use ($parameter) { |
|
96 | + $result = $this->cached($this->key->forParameter($parameter), function () use ($parameter) |
|
97 | + { |
|
93 | 98 | return $this->iterableToArray(parent::getParameterMetadata($parameter)); |
94 | 99 | }); |
95 | 100 | |
@@ -124,7 +129,8 @@ discard block |
||
124 | 129 | */ |
125 | 130 | protected function iterableToArray(iterable $attributes): array |
126 | 131 | { |
127 | - if ($attributes instanceof \Traversable) { |
|
132 | + if ($attributes instanceof \Traversable) |
|
133 | + { |
|
128 | 134 | return \iterator_to_array($attributes, false); |
129 | 135 | } |
130 | 136 |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function forClass(\ReflectionClass $class): string |
57 | 57 | { |
58 | - if ($class->isAnonymous()) { |
|
58 | + if ($class->isAnonymous()){ |
|
59 | 59 | return \vsprintf(self::TPL_ANONYMOUS_CLASS, [ |
60 | 60 | $class->getFileName(), |
61 | 61 | $class->getStartLine(), |
@@ -104,14 +104,14 @@ discard block |
||
104 | 104 | */ |
105 | 105 | public function forFunction(\ReflectionFunctionAbstract $fn): string |
106 | 106 | { |
107 | - if ($fn instanceof \ReflectionMethod) { |
|
107 | + if ($fn instanceof \ReflectionMethod){ |
|
108 | 108 | return \vsprintf(self::TPL_METHOD, [ |
109 | 109 | $this->forClass($fn->getDeclaringClass()), |
110 | 110 | $fn->getName(), |
111 | 111 | ]); |
112 | 112 | } |
113 | 113 | |
114 | - if ($fn->isClosure()) { |
|
114 | + if ($fn->isClosure()){ |
|
115 | 115 | return \vsprintf(self::TPL_ANONYMOUS_FN, [ |
116 | 116 | $fn->getFileName(), |
117 | 117 | $fn->getStartLine(), |
@@ -55,7 +55,8 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function forClass(\ReflectionClass $class): string |
57 | 57 | { |
58 | - if ($class->isAnonymous()) { |
|
58 | + if ($class->isAnonymous()) |
|
59 | + { |
|
59 | 60 | return \vsprintf(self::TPL_ANONYMOUS_CLASS, [ |
60 | 61 | $class->getFileName(), |
61 | 62 | $class->getStartLine(), |
@@ -104,14 +105,16 @@ discard block |
||
104 | 105 | */ |
105 | 106 | public function forFunction(\ReflectionFunctionAbstract $fn): string |
106 | 107 | { |
107 | - if ($fn instanceof \ReflectionMethod) { |
|
108 | + if ($fn instanceof \ReflectionMethod) |
|
109 | + { |
|
108 | 110 | return \vsprintf(self::TPL_METHOD, [ |
109 | 111 | $this->forClass($fn->getDeclaringClass()), |
110 | 112 | $fn->getName(), |
111 | 113 | ]); |
112 | 114 | } |
113 | 115 | |
114 | - if ($fn->isClosure()) { |
|
116 | + if ($fn->isClosure()) |
|
117 | + { |
|
115 | 118 | return \vsprintf(self::TPL_ANONYMOUS_FN, [ |
116 | 119 | $fn->getFileName(), |
117 | 120 | $fn->getStartLine(), |
@@ -106,7 +106,7 @@ |
||
106 | 106 | { |
107 | 107 | $result = []; |
108 | 108 | |
109 | - foreach ($this->generators as $generator) { |
|
109 | + foreach ($this->generators as $generator){ |
|
110 | 110 | $result[] = $each($generator); |
111 | 111 | } |
112 | 112 |
@@ -106,7 +106,8 @@ |
||
106 | 106 | { |
107 | 107 | $result = []; |
108 | 108 | |
109 | - foreach ($this->generators as $generator) { |
|
109 | + foreach ($this->generators as $generator) |
|
110 | + { |
|
110 | 111 | $result[] = $each($generator); |
111 | 112 | } |
112 | 113 |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | */ |
26 | 26 | public function forClass(\ReflectionClass $class): string |
27 | 27 | { |
28 | - if ($class->isUserDefined()) { |
|
28 | + if ($class->isUserDefined()){ |
|
29 | 29 | return (string)\filemtime( |
30 | 30 | $class->getFileName() |
31 | 31 | ); |
@@ -61,23 +61,23 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function forFunction(\ReflectionFunctionAbstract $fn): string |
63 | 63 | { |
64 | - if ($fn instanceof \ReflectionMethod) { |
|
64 | + if ($fn instanceof \ReflectionMethod){ |
|
65 | 65 | return $this->forClass( |
66 | 66 | $fn->getDeclaringClass() |
67 | 67 | ); |
68 | 68 | } |
69 | 69 | |
70 | - if ($fn->isUserDefined()) { |
|
70 | + if ($fn->isUserDefined()){ |
|
71 | 71 | return (string)\filemtime( |
72 | 72 | $fn->getFileName() |
73 | 73 | ); |
74 | 74 | } |
75 | 75 | |
76 | - if ($extension = $fn->getExtension()) { |
|
76 | + if ($extension = $fn->getExtension()){ |
|
77 | 77 | return $extension->getVersion(); |
78 | 78 | } |
79 | 79 | |
80 | - throw new \LogicException('Can not determine modification time of [' . $fn->getName() . ']'); |
|
80 | + throw new \LogicException('Can not determine modification time of ['.$fn->getName().']'); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -25,7 +25,8 @@ discard block |
||
25 | 25 | */ |
26 | 26 | public function forClass(\ReflectionClass $class): string |
27 | 27 | { |
28 | - if ($class->isUserDefined()) { |
|
28 | + if ($class->isUserDefined()) |
|
29 | + { |
|
29 | 30 | return (string)\filemtime( |
30 | 31 | $class->getFileName() |
31 | 32 | ); |
@@ -61,19 +62,22 @@ discard block |
||
61 | 62 | */ |
62 | 63 | public function forFunction(\ReflectionFunctionAbstract $fn): string |
63 | 64 | { |
64 | - if ($fn instanceof \ReflectionMethod) { |
|
65 | + if ($fn instanceof \ReflectionMethod) |
|
66 | + { |
|
65 | 67 | return $this->forClass( |
66 | 68 | $fn->getDeclaringClass() |
67 | 69 | ); |
68 | 70 | } |
69 | 71 | |
70 | - if ($fn->isUserDefined()) { |
|
72 | + if ($fn->isUserDefined()) |
|
73 | + { |
|
71 | 74 | return (string)\filemtime( |
72 | 75 | $fn->getFileName() |
73 | 76 | ); |
74 | 77 | } |
75 | 78 | |
76 | - if ($extension = $fn->getExtension()) { |
|
79 | + if ($extension = $fn->getExtension()) |
|
80 | + { |
|
77 | 81 | return $extension->getVersion(); |
78 | 82 | } |
79 | 83 |