@@ -13,7 +13,7 @@ |
||
13 | 13 | use gossi\codegen\model\PhpProperty; |
14 | 14 | |
15 | 15 | trait CompareVisibilityPart { |
16 | - protected function compareVisibilityName(PhpProperty|PhpMethod $a, PhpProperty|PhpMethod $b): int { |
|
16 | + protected function compareVisibilityName(PhpProperty | PhpMethod $a, PhpProperty | PhpMethod $b): int { |
|
17 | 17 | if (($aV = $a->getVisibility()) !== $bV = $b->getVisibility()) { |
18 | 18 | $aV = 'public' === $aV ? 3 : ('protected' === $aV ? 2 : 1); |
19 | 19 | $bV = 'public' === $bV ? 3 : ('protected' === $bV ? 2 : 1); |
@@ -47,7 +47,7 @@ |
||
47 | 47 | * |
48 | 48 | * @param CodeGeneratorConfig|array $config |
49 | 49 | */ |
50 | - public function __construct(CodeGeneratorConfig|array $config = []) { |
|
50 | + public function __construct(CodeGeneratorConfig | array $config = []) { |
|
51 | 51 | $this->config = is_array($config) ? new CodeGeneratorConfig($config) : $config; |
52 | 52 | |
53 | 53 | $this->twig = new Environment(new FilesystemLoader($this->config->getTemplatesDirs()), ['autoescape' => false]); |
@@ -40,10 +40,10 @@ discard block |
||
40 | 40 | protected function configureOptions(OptionsResolver $resolver): void { |
41 | 41 | $resolver->setDefaults([ |
42 | 42 | 'generateDocblock' => true, |
43 | - 'generateEmptyDocblock' => fn (Options $options) => $options['generateDocblock'], |
|
44 | - 'generateTypeHints' => fn (Options $options) => $options['declareStrictTypes'], |
|
45 | - 'generateReturnTypeHints' => fn (Options $options) => $options['declareStrictTypes'], |
|
46 | - 'generatePropertyTypes' => fn (Options $options) => $options['declareStrictTypes'], |
|
43 | + 'generateEmptyDocblock' => fn(Options $options) => $options['generateDocblock'], |
|
44 | + 'generateTypeHints' => fn(Options $options) => $options['declareStrictTypes'], |
|
45 | + 'generateReturnTypeHints' => fn(Options $options) => $options['declareStrictTypes'], |
|
46 | + 'generatePropertyTypes' => fn(Options $options) => $options['declareStrictTypes'], |
|
47 | 47 | 'minPhpVersion' => '8.0', |
48 | 48 | 'enableSorting' => true, |
49 | 49 | 'useStatementSorting' => CodeGenerator::SORT_USESTATEMENTS_DEFAULT, |
@@ -76,18 +76,18 @@ discard block |
||
76 | 76 | |
77 | 77 | /** All templates directories must exists */ |
78 | 78 | $resolver->setAllowedValues('templatesDirs', |
79 | - fn (array $dirs): bool => count(array_filter($dirs, 'is_dir')) === count($dirs) |
|
79 | + fn(array $dirs): bool => count(array_filter($dirs, 'is_dir')) === count($dirs) |
|
80 | 80 | ); |
81 | 81 | $resolver->setAllowedValues('codeStyle', |
82 | - fn (string $value): bool => in_array(strtolower($value), ['default', 'phootwork', 'psr-12']) |
|
82 | + fn(string $value): bool => in_array(strtolower($value), ['default', 'phootwork', 'psr-12']) |
|
83 | 83 | ); |
84 | - $resolver->setAllowedValues('minPhpVersion', fn (string $value): bool => in_array($value, ['7.4', '8.0'])); |
|
84 | + $resolver->setAllowedValues('minPhpVersion', fn(string $value): bool => in_array($value, ['7.4', '8.0'])); |
|
85 | 85 | |
86 | 86 | $resolver->setNormalizer('headerComment', |
87 | - fn (Options $options, Docblock|string $value): Docblock => is_string($value) ? new Docblock(str_replace('/*', '/**', $value)) : $value |
|
87 | + fn(Options $options, Docblock | string $value): Docblock => is_string($value) ? new Docblock(str_replace('/*', '/**', $value)) : $value |
|
88 | 88 | ); |
89 | 89 | $resolver->setNormalizer('headerDocblock', |
90 | - fn (Options $options, Docblock|string $value): Docblock => is_string($value) ? new Docblock($value) : $value |
|
90 | + fn(Options $options, Docblock | string $value): Docblock => is_string($value) ? new Docblock($value) : $value |
|
91 | 91 | ); |
92 | 92 | |
93 | 93 | $resolver->setNormalizer('codeStyle', function (Options $options, string $value): string { |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | * |
214 | 214 | * @return string|bool|Comparator|\Closure |
215 | 215 | */ |
216 | - public function getUseStatementSorting(): string|bool|Comparator|\Closure { |
|
216 | + public function getUseStatementSorting(): string | bool | Comparator | \Closure { |
|
217 | 217 | return $this->options['useStatementSorting']; |
218 | 218 | } |
219 | 219 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | * |
223 | 223 | * @return string|bool|Comparator|\Closure |
224 | 224 | */ |
225 | - public function getConstantSorting(): string|bool|Comparator|\Closure { |
|
225 | + public function getConstantSorting(): string | bool | Comparator | \Closure { |
|
226 | 226 | return $this->options['constantSorting']; |
227 | 227 | } |
228 | 228 | |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * |
232 | 232 | * @return string|bool|Comparator|\Closure |
233 | 233 | */ |
234 | - public function getPropertySorting(): string|bool|Comparator|\Closure { |
|
234 | + public function getPropertySorting(): string | bool | Comparator | \Closure { |
|
235 | 235 | return $this->options['propertySorting']; |
236 | 236 | } |
237 | 237 | |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * |
241 | 241 | * @return string|bool|Comparator|\Closure |
242 | 242 | */ |
243 | - public function getMethodSorting(): string|bool|Comparator|\Closure { |
|
243 | + public function getMethodSorting(): string | bool | Comparator | \Closure { |
|
244 | 244 | return $this->options['methodSorting']; |
245 | 245 | } |
246 | 246 | |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | * |
287 | 287 | * @return $this |
288 | 288 | */ |
289 | - public function setUseStatementSorting(string|bool|Comparator|\Closure $sorting): self { |
|
289 | + public function setUseStatementSorting(string | bool | Comparator | \Closure $sorting): self { |
|
290 | 290 | $this->options['useStatementSorting'] = $sorting; |
291 | 291 | |
292 | 292 | return $this; |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | * |
300 | 300 | * @return $this |
301 | 301 | */ |
302 | - public function setConstantSorting(string|bool|Comparator|\Closure $sorting): self { |
|
302 | + public function setConstantSorting(string | bool | Comparator | \Closure $sorting): self { |
|
303 | 303 | $this->options['constantSorting'] = $sorting; |
304 | 304 | |
305 | 305 | return $this; |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | * |
313 | 313 | * @return $this |
314 | 314 | */ |
315 | - public function setPropertySorting(string|bool|Comparator|\Closure $sorting): self { |
|
315 | + public function setPropertySorting(string | bool | Comparator | \Closure $sorting): self { |
|
316 | 316 | $this->options['propertySorting'] = $sorting; |
317 | 317 | |
318 | 318 | return $this; |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | * |
326 | 326 | * @return $this |
327 | 327 | */ |
328 | - public function setMethodSorting(string|bool|Comparator|\Closure $sorting): self { |
|
328 | + public function setMethodSorting(string | bool | Comparator | \Closure $sorting): self { |
|
329 | 329 | $this->options['methodSorting'] = $sorting; |
330 | 330 | |
331 | 331 | return $this; |
@@ -347,9 +347,8 @@ discard block |
||
347 | 347 | * |
348 | 348 | * @return $this |
349 | 349 | */ |
350 | - public function setHeaderComment(string|Stringable|Docblock $comment): self { |
|
351 | - $this->options['headerComment'] = $comment instanceof Docblock ? $comment : |
|
352 | - new Docblock((string) $comment); |
|
350 | + public function setHeaderComment(string | Stringable | Docblock $comment): self { |
|
351 | + $this->options['headerComment'] = $comment instanceof Docblock ? $comment : new Docblock((string) $comment); |
|
353 | 352 | |
354 | 353 | return $this; |
355 | 354 | } |
@@ -370,9 +369,8 @@ discard block |
||
370 | 369 | * |
371 | 370 | * @return $this |
372 | 371 | */ |
373 | - public function setHeaderDocblock(string|Stringable|Docblock $docblock): self { |
|
374 | - $this->options['headerDocblock'] = $docblock instanceof Docblock ? $docblock : |
|
375 | - new Docblock((string) $docblock); |
|
372 | + public function setHeaderDocblock(string | Stringable | Docblock $docblock): self { |
|
373 | + $this->options['headerDocblock'] = $docblock instanceof Docblock ? $docblock : new Docblock((string) $docblock); |
|
376 | 374 | |
377 | 375 | return $this; |
378 | 376 | } |
@@ -36,7 +36,7 @@ |
||
36 | 36 | $filter |= ReflectionMethod::IS_PROTECTED; |
37 | 37 | } |
38 | 38 | |
39 | - return array_filter($class->getMethods($filter), fn ($method) => !$method->isFinal() && !$method->isStatic()); |
|
39 | + return array_filter($class->getMethods($filter), fn($method) => !$method->isFinal() && !$method->isStatic()); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | public function getFilters(): array { |
36 | 36 | return [ |
37 | 37 | |
38 | - new TwigFilter('commonName', fn (string $variable): string => str_contains($variable, '\\') ? substr($variable, strrpos($variable, '\\') + 1) : $variable), |
|
38 | + new TwigFilter('commonName', fn(string $variable): string => str_contains($variable, '\\') ? substr($variable, strrpos($variable, '\\') + 1) : $variable), |
|
39 | 39 | new TwigFilter('type', [$this, 'getType']), |
40 | 40 | new TwigFilter('value', [$this, 'getValue']), |
41 | 41 | new TwigFilter('repeat', 'str_repeat') |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @return string |
57 | 57 | */ |
58 | - public function getType(PhpConstant|PhpParameter|PhpProperty|RoutineInterface $model): string { |
|
58 | + public function getType(PhpConstant | PhpParameter | PhpProperty | RoutineInterface $model): string { |
|
59 | 59 | $type = $model->getType(); |
60 | 60 | $generateTypeHints = $model instanceof RoutineInterface ? |
61 | 61 | $this->config->getGenerateReturnTypeHints() : $this->config->getGenerateTypeHints(); |
@@ -101,7 +101,7 @@ |
||
101 | 101 | public function generateDocblock(): void { |
102 | 102 | parent::generateDocblock(); |
103 | 103 | |
104 | - $this->constants->each(fn (string $key, PhpConstant $constant) => $constant->generateDocblock()); |
|
105 | - $this->properties->each(fn (string $key, PhpProperty $property) => $property->generateDocblock()); |
|
104 | + $this->constants->each(fn(string $key, PhpConstant $constant) => $constant->generateDocblock()); |
|
105 | + $this->properties->each(fn(string $key, PhpProperty $property) => $property->generateDocblock()); |
|
106 | 106 | } |
107 | 107 | } |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @return $this |
20 | 20 | */ |
21 | - public function setValue(string|int|float|null|bool|PhpConstant $value); |
|
21 | + public function setValue(string | int | float | null | bool | PhpConstant $value); |
|
22 | 22 | |
23 | 23 | /** |
24 | 24 | * Unsets the value |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @return string|int|float|null|bool|PhpConstant |
34 | 34 | */ |
35 | - public function getValue(): string|int|float|null|bool|PhpConstant; |
|
35 | + public function getValue(): string | int | float | null | bool | PhpConstant; |
|
36 | 36 | |
37 | 37 | /** |
38 | 38 | * Checks whether a value or expression is set |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return $this |
30 | 30 | */ |
31 | - public function addTrait(PhpTrait|string $trait); |
|
31 | + public function addTrait(PhpTrait | string $trait); |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Returns a collection of traits |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return bool `true` if it exists and `false` if not |
46 | 46 | */ |
47 | - public function hasTrait(PhpTrait|string $trait): bool; |
|
47 | + public function hasTrait(PhpTrait | string $trait): bool; |
|
48 | 48 | |
49 | 49 | /** |
50 | 50 | * Removes a trait. |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @return $this |
58 | 58 | */ |
59 | - public function removeTrait(PhpTrait|string $trait); |
|
59 | + public function removeTrait(PhpTrait | string $trait); |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * Sets a collection of traits |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @return $this |
77 | 77 | */ |
78 | - public function setRequiredFiles(array|Set $files): self { |
|
78 | + public function setRequiredFiles(array | Set $files): self { |
|
79 | 79 | $this->requiredFiles = is_array($files) ? new Set($files) : $files; |
80 | 80 | |
81 | 81 | return $this; |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | } |
206 | 206 | |
207 | 207 | return $this->useStatements->search( |
208 | - fn (string $stmt) => str_contains($stmt, '\\') || $this->getNamespace() !== '' |
|
208 | + fn(string $stmt) => str_contains($stmt, '\\') || $this->getNamespace() !== '' |
|
209 | 209 | ); |
210 | 210 | } |
211 | 211 | |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | * |
284 | 284 | * @return $this |
285 | 285 | */ |
286 | - public function removeMethod(string|PhpMethod $nameOrMethod): self { |
|
286 | + public function removeMethod(string | PhpMethod $nameOrMethod): self { |
|
287 | 287 | $name = (string) $nameOrMethod; |
288 | 288 | |
289 | 289 | if (!$this->methods->has($name)) { |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | * |
304 | 304 | * @return bool `true` if it exists and `false` if not |
305 | 305 | */ |
306 | - public function hasMethod(string|PhpMethod $nameOrMethod): bool { |
|
306 | + public function hasMethod(string | PhpMethod $nameOrMethod): bool { |
|
307 | 307 | return $this->methods->has((string) $nameOrMethod); |
308 | 308 | } |
309 | 309 | |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | * @return $this |
349 | 349 | */ |
350 | 350 | public function clearMethods(): self { |
351 | - $this->methods->each(fn (string $key, PhpMethod $method) => $method->setParent(null)); |
|
351 | + $this->methods->each(fn(string $key, PhpMethod $method) => $method->setParent(null)); |
|
352 | 352 | $this->methods->clear(); |
353 | 353 | |
354 | 354 | return $this; |
@@ -361,6 +361,6 @@ discard block |
||
361 | 361 | $docblock = $this->getDocblock(); |
362 | 362 | $docblock->setShortDescription($this->getDescription()); |
363 | 363 | $docblock->setLongDescription($this->getLongDescription()); |
364 | - $this->methods->each(fn (string $key, PhpMethod $method) => $method->generateDocblock()); |
|
364 | + $this->methods->each(fn(string $key, PhpMethod $method) => $method->generateDocblock()); |
|
365 | 365 | } |
366 | 366 | } |