@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | { |
56 | 56 | $route = $this->request->getAttribute(RouteInterface::class); |
57 | 57 | |
58 | - if (! $route instanceof RouteInterface) { |
|
58 | + if (!$route instanceof RouteInterface) { |
|
59 | 59 | // phpcs:ignore Generic.Files.LineLength.TooLong |
60 | 60 | throw new LogicException('At this level of the application, the request does not contain information about the requested route.'); |
61 | 61 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | // @codeCoverageIgnoreStart |
153 | 153 | if (!extension_loaded('intl')) { |
154 | 154 | throw new LogicException( |
155 | - 'To get the locales consumed by the client, ' . |
|
155 | + 'To get the locales consumed by the client, '. |
|
156 | 156 | 'the Intl (https://www.php.net/intl) extension must be installed.' |
157 | 157 | ); |
158 | 158 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | } |
167 | 167 | |
168 | 168 | throw new InvalidArgumentException(sprintf( |
169 | - 'The loader "%s" only accepts directory, file or class names; ' . |
|
169 | + 'The loader "%s" only accepts directory, file or class names; '. |
|
170 | 170 | 'however, the resource "%s" is not one of them.', |
171 | 171 | self::class, |
172 | 172 | $resource, |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | * |
211 | 211 | * @throws InvalidArgumentException |
212 | 212 | */ |
213 | - private static function getClassOrMethodDescriptor(ReflectionClass|ReflectionMethod $classOrMethod): ?Descriptor |
|
213 | + private static function getClassOrMethodDescriptor(ReflectionClass | ReflectionMethod $classOrMethod): ?Descriptor |
|
214 | 214 | { |
215 | 215 | /** @var list<ReflectionAttribute<Descriptor>> $annotations */ |
216 | 216 | $annotations = $classOrMethod->getAttributes(Descriptor::class, ReflectionAttribute::IS_INSTANCEOF); |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | */ |
237 | 237 | private static function enrichDescriptorFromClassOrMethod( |
238 | 238 | Descriptor $descriptor, |
239 | - ReflectionClass|ReflectionMethod $classOrMethod, |
|
239 | + ReflectionClass | ReflectionMethod $classOrMethod, |
|
240 | 240 | ): void { |
241 | 241 | /** @var list<ReflectionAttribute<NamePrefix>> $annotations */ |
242 | 242 | $annotations = $classOrMethod->getAttributes(NamePrefix::class); |
@@ -351,11 +351,11 @@ discard block |
||
351 | 351 | * |
352 | 352 | * @throws InvalidArgumentException |
353 | 353 | */ |
354 | - private static function completeDescriptor(Descriptor $descriptor, ReflectionClass|ReflectionMethod $holder): void |
|
354 | + private static function completeDescriptor(Descriptor $descriptor, ReflectionClass | ReflectionMethod $holder): void |
|
355 | 355 | { |
356 | 356 | $descriptor->holder = $holder instanceof ReflectionClass ? $holder->name : [$holder->class, $holder->name]; |
357 | - $descriptor->name = implode($descriptor->namePrefixes) . $descriptor->name; |
|
358 | - $descriptor->path = implode($descriptor->pathPrefixes) . $descriptor->path; |
|
357 | + $descriptor->name = implode($descriptor->namePrefixes).$descriptor->name; |
|
358 | + $descriptor->path = implode($descriptor->pathPrefixes).$descriptor->path; |
|
359 | 359 | $descriptor->methods = array_map(strtoupper(...), $descriptor->methods); |
360 | 360 | $descriptor->pattern = RouteCompiler::compileRoute($descriptor->path, $descriptor->patterns); |
361 | 361 | } |
@@ -99,7 +99,7 @@ |
||
99 | 99 | } |
100 | 100 | |
101 | 101 | throw new InvalidArgumentException(sprintf( |
102 | - 'The "%s" value could not be converted to a string; ' . |
|
102 | + 'The "%s" value could not be converted to a string; '. |
|
103 | 103 | 'supported types are: string, integer, backed enum and stringable object.', |
104 | 104 | get_debug_type($value), |
105 | 105 | )); |
@@ -57,7 +57,7 @@ |
||
57 | 57 | } |
58 | 58 | |
59 | 59 | throw new InvalidArgumentException(sprintf( |
60 | - 'The route "%s" could not be matched due to: %s. ' . |
|
60 | + 'The route "%s" could not be matched due to: %s. '. |
|
61 | 61 | 'This problem is most likely related to one of the route patterns.', |
62 | 62 | $pattern, |
63 | 63 | preg_last_error_msg(), |
@@ -33,7 +33,7 @@ |
||
33 | 33 | $replace = []; |
34 | 34 | foreach ($variables as $variable) { |
35 | 35 | $search[] = $variable['statement']; |
36 | - $replace[] = '{' . $variable['name'] . '}'; |
|
36 | + $replace[] = '{'.$variable['name'].'}'; |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | // will be replaced by an empty string: |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | if ($route[$offset] === '(' && !($cursor & self::IN_VARIABLE)) { |
67 | 67 | if (($cursor & self::IN_OPTIONAL_PART)) { |
68 | 68 | throw new InvalidArgumentException(sprintf( |
69 | - 'The route "%s" could not be parsed due to a syntax error. ' . |
|
70 | - 'The attempt to open an optional part at position %d failed ' . |
|
69 | + 'The route "%s" could not be parsed due to a syntax error. '. |
|
70 | + 'The attempt to open an optional part at position %d failed '. |
|
71 | 71 | 'because nested optional parts are not supported.', |
72 | 72 | $route, |
73 | 73 | $offset, |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | if ($route[$offset] === ')' && !($cursor & self::IN_VARIABLE)) { |
81 | 81 | if (!($cursor & self::IN_OPTIONAL_PART)) { |
82 | 82 | throw new InvalidArgumentException(sprintf( |
83 | - 'The route "%s" could not be parsed due to a syntax error. ' . |
|
84 | - 'The attempt to close an optional part at position %d failed ' . |
|
83 | + 'The route "%s" could not be parsed due to a syntax error. '. |
|
84 | + 'The attempt to close an optional part at position %d failed '. |
|
85 | 85 | 'because an open optional part was not found.', |
86 | 86 | $route, |
87 | 87 | $offset, |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | if (($cursor & self::IN_OCCUPIED_PART)) { |
92 | 92 | $cursor &= ~self::IN_OCCUPIED_PART; |
93 | 93 | // phpcs:ignore Generic.Files.LineLength.TooLong |
94 | - $variables[$variable]['optional_part'] = '(' . $left . ($variables[$variable]['statement'] ?? '') . $right . ')'; |
|
94 | + $variables[$variable]['optional_part'] = '('.$left.($variables[$variable]['statement'] ?? '').$right.')'; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | $cursor &= ~self::IN_OPTIONAL_PART; |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | if ($route[$offset] === '{' && !($cursor & self::IN_VARIABLE_PATTERN)) { |
103 | 103 | if (($cursor & self::IN_VARIABLE)) { |
104 | 104 | throw new InvalidArgumentException(sprintf( |
105 | - 'The route "%s" could not be parsed due to a syntax error. ' . |
|
106 | - 'The attempt to open a variable at position %d failed ' . |
|
105 | + 'The route "%s" could not be parsed due to a syntax error. '. |
|
106 | + 'The attempt to open a variable at position %d failed '. |
|
107 | 107 | 'because nested variables are not supported.', |
108 | 108 | $route, |
109 | 109 | $offset, |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | } |
112 | 112 | if (($cursor & self::IN_OCCUPIED_PART)) { |
113 | 113 | throw new InvalidArgumentException(sprintf( |
114 | - 'The route "%s" could not be parsed due to a syntax error. ' . |
|
115 | - 'The attempt to open a variable at position %d failed ' . |
|
114 | + 'The route "%s" could not be parsed due to a syntax error. '. |
|
115 | + 'The attempt to open a variable at position %d failed '. |
|
116 | 116 | 'because more than one variable inside an optional part is not supported.', |
117 | 117 | $route, |
118 | 118 | $offset, |
@@ -130,8 +130,8 @@ discard block |
||
130 | 130 | if ($route[$offset] === '}' && !($cursor & self::IN_VARIABLE_PATTERN)) { |
131 | 131 | if (!($cursor & self::IN_VARIABLE)) { |
132 | 132 | throw new InvalidArgumentException(sprintf( |
133 | - 'The route "%s" could not be parsed due to a syntax error. ' . |
|
134 | - 'The attempt to close a variable at position %d failed ' . |
|
133 | + 'The route "%s" could not be parsed due to a syntax error. '. |
|
134 | + 'The attempt to close a variable at position %d failed '. |
|
135 | 135 | 'because an open variable was not found.', |
136 | 136 | $route, |
137 | 137 | $offset, |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | } |
140 | 140 | if (!isset($variables[$variable]['name'])) { |
141 | 141 | throw new InvalidArgumentException(sprintf( |
142 | - 'The route "%s" could not be parsed due to a syntax error. ' . |
|
143 | - 'The attempt to close a variable at position %d failed ' . |
|
142 | + 'The route "%s" could not be parsed due to a syntax error. '. |
|
143 | + 'The attempt to close a variable at position %d failed '. |
|
144 | 144 | 'because its name is required for its declaration.', |
145 | 145 | $route, |
146 | 146 | $offset, |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | } |
149 | 149 | if (isset($names[$variables[$variable]['name']])) { |
150 | 150 | throw new InvalidArgumentException(sprintf( |
151 | - 'The route "%s" at position %d could not be parsed ' . |
|
151 | + 'The route "%s" at position %d could not be parsed '. |
|
152 | 152 | 'because the variable name "%s" is already in use.', |
153 | 153 | $route, |
154 | 154 | $offset, |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | } |
158 | 158 | |
159 | 159 | $cursor &= ~(self::IN_VARIABLE | self::IN_VARIABLE_NAME); |
160 | - $variables[$variable]['statement'] = '{' . ($variables[$variable]['statement'] ?? '') . '}'; |
|
160 | + $variables[$variable]['statement'] = '{'.($variables[$variable]['statement'] ?? '').'}'; |
|
161 | 161 | $names[$variables[$variable]['name']] = true; // @phpstan-ignore-line |
162 | 162 | continue; |
163 | 163 | } |
@@ -170,8 +170,8 @@ discard block |
||
170 | 170 | if ($route[$offset] === '<' && ($cursor & self::IN_VARIABLE)) { |
171 | 171 | if (($cursor & self::IN_VARIABLE_PATTERN)) { |
172 | 172 | throw new InvalidArgumentException(sprintf( |
173 | - 'The route "%s" could not be parsed due to a syntax error. ' . |
|
174 | - 'The attempt to open a variable pattern at position %d failed ' . |
|
173 | + 'The route "%s" could not be parsed due to a syntax error. '. |
|
174 | + 'The attempt to open a variable pattern at position %d failed '. |
|
175 | 175 | 'because nested patterns are not supported.', |
176 | 176 | $route, |
177 | 177 | $offset, |
@@ -179,8 +179,8 @@ discard block |
||
179 | 179 | } |
180 | 180 | if (!($cursor & self::IN_VARIABLE_NAME)) { |
181 | 181 | throw new InvalidArgumentException(sprintf( |
182 | - 'The route "%s" could not be parsed due to a syntax error. ' . |
|
183 | - 'The attempt to open a variable pattern at position %d failed ' . |
|
182 | + 'The route "%s" could not be parsed due to a syntax error. '. |
|
183 | + 'The attempt to open a variable pattern at position %d failed '. |
|
184 | 184 | 'because the pattern must be preceded by the variable name.', |
185 | 185 | $route, |
186 | 186 | $offset, |
@@ -193,8 +193,8 @@ discard block |
||
193 | 193 | if ($route[$offset] === '>' && ($cursor & self::IN_VARIABLE)) { |
194 | 194 | if (!($cursor & self::IN_VARIABLE_PATTERN)) { |
195 | 195 | throw new InvalidArgumentException(sprintf( |
196 | - 'The route "%s" could not be parsed due to a syntax error. ' . |
|
197 | - 'The attempt to close a variable pattern at position %d failed ' . |
|
196 | + 'The route "%s" could not be parsed due to a syntax error. '. |
|
197 | + 'The attempt to close a variable pattern at position %d failed '. |
|
198 | 198 | 'because an open pattern was not found.', |
199 | 199 | $route, |
200 | 200 | $offset, |
@@ -202,8 +202,8 @@ discard block |
||
202 | 202 | } |
203 | 203 | if (!isset($variables[$variable]['pattern'])) { |
204 | 204 | throw new InvalidArgumentException(sprintf( |
205 | - 'The route "%s" could not be parsed due to a syntax error. ' . |
|
206 | - 'The attempt to close a variable pattern at position %d failed ' . |
|
205 | + 'The route "%s" could not be parsed due to a syntax error. '. |
|
206 | + 'The attempt to close a variable pattern at position %d failed '. |
|
207 | 207 | 'because its content is required for its declaration.', |
208 | 208 | $route, |
209 | 209 | $offset, |
@@ -230,8 +230,8 @@ discard block |
||
230 | 230 | if (($cursor & self::IN_VARIABLE_NAME)) { |
231 | 231 | if (!isset($variables[$variable]['name']) && $route[$offset] >= '0' && $route[$offset] <= '9') { |
232 | 232 | throw new InvalidArgumentException(sprintf( |
233 | - 'The route "%s" could not be parsed due to a syntax error. ' . |
|
234 | - 'An invalid character was found at position %d. ' . |
|
233 | + 'The route "%s" could not be parsed due to a syntax error. '. |
|
234 | + 'An invalid character was found at position %d. '. |
|
235 | 235 | 'Please note that variable names cannot start with digits.', |
236 | 236 | $route, |
237 | 237 | $offset, |
@@ -239,8 +239,8 @@ discard block |
||
239 | 239 | } |
240 | 240 | if (!isset(self::PCRE_SUBPATTERN_NAME_CHARSET[$route[$offset]])) { |
241 | 241 | throw new InvalidArgumentException(sprintf( |
242 | - 'The route "%s" could not be parsed due to a syntax error. ' . |
|
243 | - 'An invalid character was found at position %d. ' . |
|
242 | + 'The route "%s" could not be parsed due to a syntax error. '. |
|
243 | + 'An invalid character was found at position %d. '. |
|
244 | 244 | 'Please note that variable names must consist only of digits, letters and underscores.', |
245 | 245 | $route, |
246 | 246 | $offset, |
@@ -248,8 +248,8 @@ discard block |
||
248 | 248 | } |
249 | 249 | if (isset($variables[$variable]['name'][31])) { |
250 | 250 | throw new InvalidArgumentException(sprintf( |
251 | - 'The route "%s" could not be parsed due to a syntax error. ' . |
|
252 | - 'An extra character was found at position %d. ' . |
|
251 | + 'The route "%s" could not be parsed due to a syntax error. '. |
|
252 | + 'An extra character was found at position %d. '. |
|
253 | 253 | 'Please note that variable names must not exceed 32 characters.', |
254 | 254 | $route, |
255 | 255 | $offset, |
@@ -264,9 +264,9 @@ discard block |
||
264 | 264 | if (($cursor & self::IN_VARIABLE_PATTERN)) { |
265 | 265 | if ($route[$offset] === RouteCompiler::EXPRESSION_DELIMITER) { |
266 | 266 | throw new InvalidArgumentException(sprintf( |
267 | - 'The route "%s" could not be parsed due to a syntax error. ' . |
|
268 | - 'An invalid character was found at position %d. ' . |
|
269 | - 'Please note that variable patterns cannot contain the character "%s"; ' . |
|
267 | + 'The route "%s" could not be parsed due to a syntax error. '. |
|
268 | + 'An invalid character was found at position %d. '. |
|
269 | + 'Please note that variable patterns cannot contain the character "%s"; '. |
|
270 | 270 | 'use an octal or hexadecimal sequence instead.', |
271 | 271 | $route, |
272 | 272 | $offset, |
@@ -283,8 +283,8 @@ discard block |
||
283 | 283 | // ~~~~~~~~~^^^~ |
284 | 284 | if (($cursor & self::IN_VARIABLE)) { |
285 | 285 | throw new InvalidArgumentException(sprintf( |
286 | - 'The route "%s" could not be parsed due to a syntax error. ' . |
|
287 | - 'An unexpected character was found at position %d; ' . |
|
286 | + 'The route "%s" could not be parsed due to a syntax error. '. |
|
287 | + 'An unexpected character was found at position %d; '. |
|
288 | 288 | 'a variable at this position must be closed.', |
289 | 289 | $route, |
290 | 290 | $offset, |
@@ -294,8 +294,8 @@ discard block |
||
294 | 294 | |
295 | 295 | if (($cursor & self::IN_VARIABLE) || ($cursor & self::IN_OPTIONAL_PART)) { |
296 | 296 | throw new InvalidArgumentException(sprintf( |
297 | - 'The route "%s" could not be parsed due to a syntax error. ' . |
|
298 | - 'The attempt to parse the route failed ' . |
|
297 | + 'The route "%s" could not be parsed due to a syntax error. '. |
|
298 | + 'The attempt to parse the route failed '. |
|
299 | 299 | 'because it contains an unclosed variable or optional part.', |
300 | 300 | $route, |
301 | 301 | )); |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | $replace = []; |
42 | 42 | foreach ($variables as $variable) { |
43 | 43 | $search[] = $variable['statement']; |
44 | - $replace[] = '{' . $variable['name'] . '}'; |
|
44 | + $replace[] = '{'.$variable['name'].'}'; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | $route = str_replace($search, $replace, $route); |
@@ -53,12 +53,12 @@ discard block |
||
53 | 53 | foreach ($variables as $variable) { |
54 | 54 | $pattern = $patterns[$variable['name']] ?? $variable['pattern'] ?? self::DEFAULT_VARIABLE_PATTERN; |
55 | 55 | |
56 | - $search[] = '{' . $variable['name'] . '}'; |
|
57 | - $replace[] = '(?<' . $variable['name'] . '>' . $pattern . ')'; |
|
56 | + $search[] = '{'.$variable['name'].'}'; |
|
57 | + $replace[] = '(?<'.$variable['name'].'>'.$pattern.')'; |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | $route = str_replace($search, $replace, $route); |
61 | 61 | |
62 | - return '#^' . $route . '$#uD'; |
|
62 | + return '#^'.$route.'$#uD'; |
|
63 | 63 | } |
64 | 64 | } |