@@ -12,7 +12,7 @@ |
||
12 | 12 | public function __construct( |
13 | 13 | public readonly string $alias, |
14 | 14 | public readonly bool $singleton = false, |
15 | - ) { |
|
15 | + ){ |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | public function __toString(): string |
@@ -15,7 +15,7 @@ |
||
15 | 15 | public function __construct( |
16 | 16 | public readonly array $factory, |
17 | 17 | public readonly bool $singleton = false, |
18 | - ) { |
|
18 | + ){ |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | public function __toString(): string |
@@ -14,7 +14,7 @@ |
||
14 | 14 | public function __construct( |
15 | 15 | public readonly AutowireAlias $autowire, |
16 | 16 | public readonly bool $singleton = false, |
17 | - ) { |
|
17 | + ){ |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | public function __toString(): string |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | public function __construct( |
19 | 19 | callable $callable, |
20 | 20 | public readonly bool $singleton = false, |
21 | - ) { |
|
21 | + ){ |
|
22 | 22 | $this->factory = $callable(...); |
23 | 23 | $this->parametersCount = (new \ReflectionFunction($this->factory))->getNumberOfParameters(); |
24 | 24 | /** @psalm-suppress TypeDoesNotContainType */ |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | \is_object($callable[0]) ? $callable[0]::class : $callable[0], |
30 | 30 | $callable[1], |
31 | 31 | ), |
32 | - \is_object($callable) && $callable::class !== \Closure::class => 'object ' . $callable::class, |
|
32 | + \is_object($callable) && $callable::class !== \Closure::class => 'object '.$callable::class, |
|
33 | 33 | default => null, |
34 | 34 | }; |
35 | 35 | } |
@@ -43,9 +43,12 @@ discard block |
||
43 | 43 | $this->requested[$node->name->name] = $node->name->name; |
44 | 44 | } |
45 | 45 | |
46 | - if ($node instanceof Node\Stmt\Property) { |
|
47 | - foreach ($node->props as $prop) { |
|
48 | - if ($prop instanceof Node\Stmt\PropertyProperty) { |
|
46 | + if ($node instanceof Node\Stmt\Property) |
|
47 | + { |
|
48 | + foreach ($node->props as $prop) |
|
49 | + { |
|
50 | + if ($prop instanceof Node\Stmt\PropertyProperty) |
|
51 | + { |
|
49 | 52 | $this->properties[$prop->name->name] = $prop->name->name; |
50 | 53 | } |
51 | 54 | } |
@@ -56,7 +59,8 @@ discard block |
||
56 | 59 | |
57 | 60 | private function promotedProperties(Node $node): void |
58 | 61 | { |
59 | - if (!$node instanceof Node\Param || !$node->var instanceof Node\Expr\Variable) { |
|
62 | + if (!$node instanceof Node\Param || !$node->var instanceof Node\Expr\Variable) |
|
63 | + { |
|
60 | 64 | return; |
61 | 65 | } |
62 | 66 |
@@ -38,13 +38,13 @@ discard block |
||
38 | 38 | $node->var instanceof Node\Expr\Variable && |
39 | 39 | $node->var->name === 'this' && |
40 | 40 | $node->name instanceof Node\Identifier |
41 | - ) { |
|
41 | + ){ |
|
42 | 42 | $this->requested[$node->name->name] = $node->name->name; |
43 | 43 | } |
44 | 44 | |
45 | - if ($node instanceof Node\Stmt\Property) { |
|
46 | - foreach ($node->props as $prop) { |
|
47 | - if ($prop instanceof Node\Stmt\PropertyProperty) { |
|
45 | + if ($node instanceof Node\Stmt\Property){ |
|
46 | + foreach ($node->props as $prop){ |
|
47 | + if ($prop instanceof Node\Stmt\PropertyProperty){ |
|
48 | 48 | $this->properties[$prop->name->name] = $prop->name->name; |
49 | 49 | } |
50 | 50 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | private function promotedProperties(Node $node): void |
57 | 57 | { |
58 | - if (!$node instanceof Node\Param || !$node->var instanceof Node\Expr\Variable) { |
|
58 | + if (!$node instanceof Node\Param || !$node->var instanceof Node\Expr\Variable){ |
|
59 | 59 | return; |
60 | 60 | } |
61 | 61 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $node->flags & Node\Stmt\Class_::MODIFIER_PUBLIC || |
64 | 64 | $node->flags & Node\Stmt\Class_::MODIFIER_PROTECTED || |
65 | 65 | $node->flags & Node\Stmt\Class_::MODIFIER_PRIVATE |
66 | - ) { |
|
66 | + ){ |
|
67 | 67 | $this->properties[$node->var->name] = $node->var->name; |
68 | 68 | } |
69 | 69 | } |
@@ -17,18 +17,18 @@ discard block |
||
17 | 17 | { |
18 | 18 | public function __construct( |
19 | 19 | private readonly ClassNode $definition |
20 | - ) { |
|
20 | + ){ |
|
21 | 21 | } |
22 | 22 | |
23 | - public function leaveNode(Node $node): int|Node|null |
|
23 | + public function leaveNode(Node $node): int | Node | null |
|
24 | 24 | { |
25 | - if (!$node instanceof Node\Stmt\Class_) { |
|
25 | + if (!$node instanceof Node\Stmt\Class_){ |
|
26 | 26 | return null; |
27 | 27 | } |
28 | 28 | |
29 | 29 | $constructor = $this->getConstructorAttribute($node); |
30 | 30 | $this->addDependencies($constructor); |
31 | - if (!$this->definition->hasConstructor && $this->definition->constructorParams) { |
|
31 | + if (!$this->definition->hasConstructor && $this->definition->constructorParams){ |
|
32 | 32 | $this->addParentConstructorCall($constructor); |
33 | 33 | } |
34 | 34 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | private function addDependencies(Node\Stmt\ClassMethod $constructor): void |
42 | 42 | { |
43 | - foreach ($this->definition->dependencies as $dependency) { |
|
43 | + foreach ($this->definition->dependencies as $dependency){ |
|
44 | 44 | \array_unshift($constructor->params, $this->buildConstructorParam($dependency)); |
45 | 45 | } |
46 | 46 | } |
@@ -57,34 +57,34 @@ discard block |
||
57 | 57 | private function addParentConstructorCall(Node\Stmt\ClassMethod $constructor): void |
58 | 58 | { |
59 | 59 | $parentConstructorDependencies = []; |
60 | - foreach ($this->definition->constructorParams as $param) { |
|
60 | + foreach ($this->definition->constructorParams as $param){ |
|
61 | 61 | $parentConstructorDependencies[] = new Node\Arg(new Node\Expr\Variable($param->name)); |
62 | 62 | |
63 | 63 | $cp = new Param($param->name); |
64 | - if (!empty($param->type)) { |
|
64 | + if (!empty($param->type)){ |
|
65 | 65 | $type = $this->getParamType($param); |
66 | - if ($param->nullable) { |
|
66 | + if ($param->nullable){ |
|
67 | 67 | $type = \sprintf('?%s', $type); |
68 | 68 | } |
69 | 69 | |
70 | 70 | $cp->setType(new Node\Name($type)); |
71 | 71 | } |
72 | 72 | |
73 | - if ($param->byRef) { |
|
73 | + if ($param->byRef){ |
|
74 | 74 | $cp->makeByRef(); |
75 | 75 | } |
76 | 76 | |
77 | - if ($param->isVariadic) { |
|
77 | + if ($param->isVariadic){ |
|
78 | 78 | $cp->makeVariadic(); |
79 | 79 | } |
80 | 80 | |
81 | - if ($param->hasDefault) { |
|
81 | + if ($param->hasDefault){ |
|
82 | 82 | $cp->setDefault($param->default); |
83 | 83 | } |
84 | 84 | $constructor->params[] = $cp->getNode(); |
85 | 85 | } |
86 | 86 | |
87 | - if ($parentConstructorDependencies !== []) { |
|
87 | + if ($parentConstructorDependencies !== []){ |
|
88 | 88 | \array_unshift( |
89 | 89 | $constructor->stmts, |
90 | 90 | new Node\Stmt\Expression( |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | |
106 | 106 | private function getPropertyType(Dependency $dependency): string |
107 | 107 | { |
108 | - foreach ($this->definition->getStmts() as $stmt) { |
|
109 | - if ($stmt->name === $dependency->type->fullName && $stmt->alias) { |
|
108 | + foreach ($this->definition->getStmts() as $stmt){ |
|
109 | + if ($stmt->name === $dependency->type->fullName && $stmt->alias){ |
|
110 | 110 | return $stmt->alias; |
111 | 111 | } |
112 | 112 | } |
@@ -116,13 +116,13 @@ discard block |
||
116 | 116 | |
117 | 117 | private function getParamType(ClassNode\ConstructorParam $param): string |
118 | 118 | { |
119 | - foreach ($this->definition->getStmts() as $stmt) { |
|
120 | - if ($stmt->name === $param->type->fullName && $stmt->alias) { |
|
119 | + foreach ($this->definition->getStmts() as $stmt){ |
|
120 | + if ($stmt->name === $param->type->fullName && $stmt->alias){ |
|
121 | 121 | return $stmt->alias; |
122 | 122 | } |
123 | 123 | } |
124 | 124 | |
125 | - if ($param->type->alias) { |
|
125 | + if ($param->type->alias){ |
|
126 | 126 | return $param->type->alias; |
127 | 127 | } |
128 | 128 |
@@ -22,13 +22,15 @@ discard block |
||
22 | 22 | |
23 | 23 | public function leaveNode(Node $node): int|Node|null |
24 | 24 | { |
25 | - if (!$node instanceof Node\Stmt\Class_) { |
|
25 | + if (!$node instanceof Node\Stmt\Class_) |
|
26 | + { |
|
26 | 27 | return null; |
27 | 28 | } |
28 | 29 | |
29 | 30 | $constructor = $this->getConstructorAttribute($node); |
30 | 31 | $this->addDependencies($constructor); |
31 | - if (!$this->definition->hasConstructor && $this->definition->constructorParams) { |
|
32 | + if (!$this->definition->hasConstructor && $this->definition->constructorParams) |
|
33 | + { |
|
32 | 34 | $this->addParentConstructorCall($constructor); |
33 | 35 | } |
34 | 36 | |
@@ -40,7 +42,8 @@ discard block |
||
40 | 42 | */ |
41 | 43 | private function addDependencies(Node\Stmt\ClassMethod $constructor): void |
42 | 44 | { |
43 | - foreach ($this->definition->dependencies as $dependency) { |
|
45 | + foreach ($this->definition->dependencies as $dependency) |
|
46 | + { |
|
44 | 47 | \array_unshift($constructor->params, $this->buildConstructorParam($dependency)); |
45 | 48 | } |
46 | 49 | } |
@@ -57,34 +60,41 @@ discard block |
||
57 | 60 | private function addParentConstructorCall(Node\Stmt\ClassMethod $constructor): void |
58 | 61 | { |
59 | 62 | $parentConstructorDependencies = []; |
60 | - foreach ($this->definition->constructorParams as $param) { |
|
63 | + foreach ($this->definition->constructorParams as $param) |
|
64 | + { |
|
61 | 65 | $parentConstructorDependencies[] = new Node\Arg(new Node\Expr\Variable($param->name)); |
62 | 66 | |
63 | 67 | $cp = new Param($param->name); |
64 | - if (!empty($param->type)) { |
|
68 | + if (!empty($param->type)) |
|
69 | + { |
|
65 | 70 | $type = $this->getParamType($param); |
66 | - if ($param->nullable) { |
|
71 | + if ($param->nullable) |
|
72 | + { |
|
67 | 73 | $type = \sprintf('?%s', $type); |
68 | 74 | } |
69 | 75 | |
70 | 76 | $cp->setType(new Node\Name($type)); |
71 | 77 | } |
72 | 78 | |
73 | - if ($param->byRef) { |
|
79 | + if ($param->byRef) |
|
80 | + { |
|
74 | 81 | $cp->makeByRef(); |
75 | 82 | } |
76 | 83 | |
77 | - if ($param->isVariadic) { |
|
84 | + if ($param->isVariadic) |
|
85 | + { |
|
78 | 86 | $cp->makeVariadic(); |
79 | 87 | } |
80 | 88 | |
81 | - if ($param->hasDefault) { |
|
89 | + if ($param->hasDefault) |
|
90 | + { |
|
82 | 91 | $cp->setDefault($param->default); |
83 | 92 | } |
84 | 93 | $constructor->params[] = $cp->getNode(); |
85 | 94 | } |
86 | 95 | |
87 | - if ($parentConstructorDependencies !== []) { |
|
96 | + if ($parentConstructorDependencies !== []) |
|
97 | + { |
|
88 | 98 | \array_unshift( |
89 | 99 | $constructor->stmts, |
90 | 100 | new Node\Stmt\Expression( |
@@ -105,8 +115,10 @@ discard block |
||
105 | 115 | |
106 | 116 | private function getPropertyType(Dependency $dependency): string |
107 | 117 | { |
108 | - foreach ($this->definition->getStmts() as $stmt) { |
|
109 | - if ($stmt->name === $dependency->type->fullName && $stmt->alias) { |
|
118 | + foreach ($this->definition->getStmts() as $stmt) |
|
119 | + { |
|
120 | + if ($stmt->name === $dependency->type->fullName && $stmt->alias) |
|
121 | + { |
|
110 | 122 | return $stmt->alias; |
111 | 123 | } |
112 | 124 | } |
@@ -116,13 +128,16 @@ discard block |
||
116 | 128 | |
117 | 129 | private function getParamType(ClassNode\ConstructorParam $param): string |
118 | 130 | { |
119 | - foreach ($this->definition->getStmts() as $stmt) { |
|
120 | - if ($stmt->name === $param->type->fullName && $stmt->alias) { |
|
131 | + foreach ($this->definition->getStmts() as $stmt) |
|
132 | + { |
|
133 | + if ($stmt->name === $param->type->fullName && $stmt->alias) |
|
134 | + { |
|
121 | 135 | return $stmt->alias; |
122 | 136 | } |
123 | 137 | } |
124 | 138 | |
125 | - if ($param->type->alias) { |
|
139 | + if ($param->type->alias) |
|
140 | + { |
|
126 | 141 | return $param->type->alias; |
127 | 142 | } |
128 | 143 |
@@ -62,7 +62,8 @@ discard block |
||
62 | 62 | $className = $declaration->getClass()->getName(); |
63 | 63 | $relativeFilename = \str_replace($rootDirectory, '', $filename); |
64 | 64 | |
65 | - if ($this->files->exists($filename)) { |
|
65 | + if ($this->files->exists($filename)) |
|
66 | + { |
|
66 | 67 | $this->writeln( |
67 | 68 | \sprintf("<fg=red>Unable to create '<comment>%s</comment>' declaration, ", $className) |
68 | 69 | . \sprintf("file '<comment>%s</comment>' already exists.</fg=red>", $relativeFilename), |
@@ -79,11 +80,13 @@ discard block |
||
79 | 80 | . \sprintf("has been successfully written into '<comment>%s</comment>'.", $relativeFilename), |
80 | 81 | ); |
81 | 82 | |
82 | - if ($declaration instanceof HasInstructions && \count($declaration->getInstructions()) > 0) { |
|
83 | + if ($declaration instanceof HasInstructions && \count($declaration->getInstructions()) > 0) |
|
84 | + { |
|
83 | 85 | $this->newLine(); |
84 | 86 | $this->writeln('<fg=green>Next steps:</fg=green>'); |
85 | 87 | |
86 | - foreach ($declaration->getInstructions() as $i => $instruction) { |
|
88 | + foreach ($declaration->getInstructions() as $i => $instruction) |
|
89 | + { |
|
87 | 90 | $this->writeln(\sprintf('%d. %s', (string)(++$i), $instruction)); |
88 | 91 | } |
89 | 92 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | #[Proxy] ContainerInterface $container, |
24 | 24 | private readonly FactoryInterface $factory, |
25 | 25 | private readonly DirectoriesInterface $dirs, |
26 | - ) { |
|
26 | + ){ |
|
27 | 27 | $this->setContainer($container); |
28 | 28 | |
29 | 29 | parent::__construct(); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $className = $declaration->getClass()->getName(); |
64 | 64 | $relativeFilename = \str_replace($rootDirectory, '', $filename); |
65 | 65 | |
66 | - if ($this->files->exists($filename)) { |
|
66 | + if ($this->files->exists($filename)){ |
|
67 | 67 | $this->writeln( |
68 | 68 | \sprintf("<fg=red>Unable to create '<comment>%s</comment>' declaration, ", $className) |
69 | 69 | . \sprintf("file '<comment>%s</comment>' already exists.</fg=red>", $relativeFilename), |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | . \sprintf("has been successfully written into '<comment>%s</comment>'.", $relativeFilename), |
81 | 81 | ); |
82 | 82 | |
83 | - if ($declaration instanceof HasInstructions && \count($declaration->getInstructions()) > 0) { |
|
83 | + if ($declaration instanceof HasInstructions && \count($declaration->getInstructions()) > 0){ |
|
84 | 84 | $this->newLine(); |
85 | 85 | $this->writeln('<fg=green>Next steps:</fg=green>'); |
86 | 86 | |
87 | - foreach ($declaration->getInstructions() as $i => $instruction) { |
|
87 | + foreach ($declaration->getInstructions() as $i => $instruction){ |
|
88 | 88 | $this->writeln(\sprintf('%d. %s', (string)(++$i), $instruction)); |
89 | 89 | } |
90 | 90 | } |
@@ -20,5 +20,5 @@ |
||
20 | 20 | * |
21 | 21 | * @return array<class-string, ReflectionEnum> |
22 | 22 | */ |
23 | - public function getEnums(object|string|null $target = null): array; |
|
23 | + public function getEnums(object | string | null $target = null): array; |
|
24 | 24 | } |
@@ -16,7 +16,7 @@ |
||
16 | 16 | public function __construct( |
17 | 17 | private readonly EnumsInterface $enums, |
18 | 18 | private readonly ScopedEnumsInterface $scopedEnums, |
19 | - ) { |
|
19 | + ){ |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |