@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | private function getConstructorReservedNames(ClassNode $definition): array |
46 | 46 | { |
47 | 47 | $names = []; |
48 | - foreach ($definition->constructorVars as $name) { |
|
48 | + foreach ($definition->constructorVars as $name){ |
|
49 | 49 | $names[] = $name; |
50 | 50 | } |
51 | 51 | |
52 | - foreach ($definition->constructorParams as $param) { |
|
52 | + foreach ($definition->constructorParams as $param){ |
|
53 | 53 | $names[] = $param->name; |
54 | 54 | } |
55 | 55 | |
@@ -63,12 +63,12 @@ discard block |
||
63 | 63 | private function initiateCounters(array $names): array |
64 | 64 | { |
65 | 65 | $counters = []; |
66 | - foreach ($names as $name) { |
|
66 | + foreach ($names as $name){ |
|
67 | 67 | $name = $this->parseName($name); |
68 | 68 | |
69 | - if (isset($counters[$name->name])) { |
|
69 | + if (isset($counters[$name->name])){ |
|
70 | 70 | $counters[$name->name][$name->sequence] = $name->fullName(); |
71 | - } else { |
|
71 | + }else{ |
|
72 | 72 | $counters[$name->name] = [$name->sequence => $name->fullName()]; |
73 | 73 | } |
74 | 74 | } |
@@ -82,18 +82,18 @@ discard block |
||
82 | 82 | */ |
83 | 83 | private function addPostfixes(ClassNode $definition, array $counters): void |
84 | 84 | { |
85 | - foreach ($definition->dependencies as $dependency) { |
|
85 | + foreach ($definition->dependencies as $dependency){ |
|
86 | 86 | $name = $this->parseName($dependency->var); |
87 | - if (isset($counters[$name->name])) { |
|
87 | + if (isset($counters[$name->name])){ |
|
88 | 88 | $sequence = $this->sequences->find(array_keys($counters[$name->name]), $name->sequence); |
89 | - if ($sequence !== $name->sequence) { |
|
89 | + if ($sequence !== $name->sequence){ |
|
90 | 90 | $name->sequence = $sequence; |
91 | 91 | |
92 | 92 | $dependency->var = $name->fullName(); |
93 | 93 | } |
94 | 94 | |
95 | 95 | $counters[$name->name][$sequence] = $name->fullName(); |
96 | - } else { |
|
96 | + }else{ |
|
97 | 97 | $counters[$name->name] = [$name->sequence => $name->fullName()]; |
98 | 98 | } |
99 | 99 | } |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | */ |
106 | 106 | private function parseName(string $name): NameEntity |
107 | 107 | { |
108 | - if (preg_match("/\d+$/", $name, $match)) { |
|
108 | + if (preg_match("/\d+$/", $name, $match)){ |
|
109 | 109 | $sequence = (int)$match[0]; |
110 | - if ($sequence > 0) { |
|
110 | + if ($sequence > 0){ |
|
111 | 111 | return NameEntity::createWithSequence(Utils::trimTrailingDigits($name, $sequence), $sequence); |
112 | 112 | } |
113 | 113 | } |
@@ -45,11 +45,13 @@ discard block |
||
45 | 45 | private function getConstructorReservedNames(ClassNode $definition): array |
46 | 46 | { |
47 | 47 | $names = []; |
48 | - foreach ($definition->constructorVars as $name) { |
|
48 | + foreach ($definition->constructorVars as $name) |
|
49 | + { |
|
49 | 50 | $names[] = $name; |
50 | 51 | } |
51 | 52 | |
52 | - foreach ($definition->constructorParams as $param) { |
|
53 | + foreach ($definition->constructorParams as $param) |
|
54 | + { |
|
53 | 55 | $names[] = $param->name; |
54 | 56 | } |
55 | 57 | |
@@ -63,12 +65,16 @@ discard block |
||
63 | 65 | private function initiateCounters(array $names): array |
64 | 66 | { |
65 | 67 | $counters = []; |
66 | - foreach ($names as $name) { |
|
68 | + foreach ($names as $name) |
|
69 | + { |
|
67 | 70 | $name = $this->parseName($name); |
68 | 71 | |
69 | - if (isset($counters[$name->name])) { |
|
72 | + if (isset($counters[$name->name])) |
|
73 | + { |
|
70 | 74 | $counters[$name->name][$name->sequence] = $name->fullName(); |
71 | - } else { |
|
75 | + } |
|
76 | + else |
|
77 | + { |
|
72 | 78 | $counters[$name->name] = [$name->sequence => $name->fullName()]; |
73 | 79 | } |
74 | 80 | } |
@@ -82,18 +88,23 @@ discard block |
||
82 | 88 | */ |
83 | 89 | private function addPostfixes(ClassNode $definition, array $counters): void |
84 | 90 | { |
85 | - foreach ($definition->dependencies as $dependency) { |
|
91 | + foreach ($definition->dependencies as $dependency) |
|
92 | + { |
|
86 | 93 | $name = $this->parseName($dependency->var); |
87 | - if (isset($counters[$name->name])) { |
|
94 | + if (isset($counters[$name->name])) |
|
95 | + { |
|
88 | 96 | $sequence = $this->sequences->find(array_keys($counters[$name->name]), $name->sequence); |
89 | - if ($sequence !== $name->sequence) { |
|
97 | + if ($sequence !== $name->sequence) |
|
98 | + { |
|
90 | 99 | $name->sequence = $sequence; |
91 | 100 | |
92 | 101 | $dependency->var = $name->fullName(); |
93 | 102 | } |
94 | 103 | |
95 | 104 | $counters[$name->name][$sequence] = $name->fullName(); |
96 | - } else { |
|
105 | + } |
|
106 | + else |
|
107 | + { |
|
97 | 108 | $counters[$name->name] = [$name->sequence => $name->fullName()]; |
98 | 109 | } |
99 | 110 | } |
@@ -105,9 +116,11 @@ discard block |
||
105 | 116 | */ |
106 | 117 | private function parseName(string $name): NameEntity |
107 | 118 | { |
108 | - if (preg_match("/\d+$/", $name, $match)) { |
|
119 | + if (preg_match("/\d+$/", $name, $match)) |
|
120 | + { |
|
109 | 121 | $sequence = (int)$match[0]; |
110 | - if ($sequence > 0) { |
|
122 | + if ($sequence > 0) |
|
123 | + { |
|
111 | 124 | return NameEntity::createWithSequence(Utils::trimTrailingDigits($name, $sequence), $sequence); |
112 | 125 | } |
113 | 126 | } |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | */ |
59 | 59 | private function getReservedNamespacesWithAlias(ClassNode $definition, array $namespaces): array |
60 | 60 | { |
61 | - foreach ($definition->getStmts() as $stmt) { |
|
62 | - if (!$stmt->alias) { |
|
61 | + foreach ($definition->getStmts() as $stmt){ |
|
62 | + if (!$stmt->alias){ |
|
63 | 63 | continue; |
64 | 64 | } |
65 | 65 | |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | */ |
77 | 77 | private function getReservedNamespacesWithoutAlias(ClassNode $definition, array $namespaces): array |
78 | 78 | { |
79 | - foreach ($definition->getStmts() as $stmt) { |
|
80 | - if ($stmt->alias || isset($namespaces[$stmt->shortName])) { |
|
79 | + foreach ($definition->getStmts() as $stmt){ |
|
80 | + if ($stmt->alias || isset($namespaces[$stmt->shortName])){ |
|
81 | 81 | continue; |
82 | 82 | } |
83 | 83 | |
@@ -94,12 +94,12 @@ discard block |
||
94 | 94 | private function initiateCounters(array $namespaces): array |
95 | 95 | { |
96 | 96 | $counters = []; |
97 | - foreach ($namespaces as $shortName => $fullName) { |
|
97 | + foreach ($namespaces as $shortName => $fullName){ |
|
98 | 98 | $namespace = $this->parseNamespace($shortName, $fullName); |
99 | 99 | |
100 | - if (isset($counters[$namespace->name])) { |
|
100 | + if (isset($counters[$namespace->name])){ |
|
101 | 101 | $counters[$namespace->name][$namespace->sequence] = $namespace; |
102 | - } else { |
|
102 | + }else{ |
|
103 | 103 | $counters[$namespace->name] = [$namespace->sequence => $namespace]; |
104 | 104 | } |
105 | 105 | } |
@@ -113,52 +113,52 @@ discard block |
||
113 | 113 | */ |
114 | 114 | private function resolveImportsNamespaces(ClassNode $definition, array $counters): void |
115 | 115 | { |
116 | - if (!$definition->hasConstructor && $definition->constructorParams) { |
|
117 | - foreach ($definition->constructorParams as $param) { |
|
116 | + if (!$definition->hasConstructor && $definition->constructorParams){ |
|
117 | + foreach ($definition->constructorParams as $param){ |
|
118 | 118 | //no type (or type is internal), do nothing |
119 | - if (empty($param->type) || $param->isBuiltIn()) { |
|
119 | + if (empty($param->type) || $param->isBuiltIn()){ |
|
120 | 120 | continue; |
121 | 121 | } |
122 | 122 | |
123 | 123 | $namespace = $this->parseNamespaceFromType($param->type); |
124 | - if (isset($counters[$namespace->name])) { |
|
125 | - if ($this->getAlreadyImportedNamespace($counters[$namespace->name], $namespace)) { |
|
124 | + if (isset($counters[$namespace->name])){ |
|
125 | + if ($this->getAlreadyImportedNamespace($counters[$namespace->name], $namespace)){ |
|
126 | 126 | continue; |
127 | 127 | } |
128 | 128 | |
129 | 129 | $sequence = $this->sequences->find(array_keys($counters[$namespace->name]), $namespace->sequence); |
130 | - if ($sequence !== $namespace->sequence) { |
|
130 | + if ($sequence !== $namespace->sequence){ |
|
131 | 131 | $namespace->sequence = $sequence; |
132 | 132 | |
133 | 133 | $param->type->alias = $namespace->fullName(); |
134 | 134 | } |
135 | 135 | |
136 | 136 | $counters[$namespace->name][$sequence] = $namespace; |
137 | - } else { |
|
137 | + }else{ |
|
138 | 138 | $counters[$namespace->name] = [$namespace->sequence => $namespace]; |
139 | 139 | } |
140 | 140 | } |
141 | 141 | } |
142 | 142 | |
143 | - foreach ($definition->dependencies as $dependency) { |
|
143 | + foreach ($definition->dependencies as $dependency){ |
|
144 | 144 | $namespace = $this->parseNamespaceFromType($dependency->type); |
145 | - if (isset($counters[$namespace->name])) { |
|
145 | + if (isset($counters[$namespace->name])){ |
|
146 | 146 | $alreadyImported = $this->getAlreadyImportedNamespace($counters[$namespace->name], $namespace); |
147 | - if ($alreadyImported !== null) { |
|
147 | + if ($alreadyImported !== null){ |
|
148 | 148 | $dependency->type->alias = $alreadyImported->fullName(); |
149 | 149 | |
150 | 150 | continue; |
151 | 151 | } |
152 | 152 | |
153 | 153 | $sequence = $this->sequences->find(array_keys($counters[$namespace->name]), $namespace->sequence); |
154 | - if ($sequence !== $namespace->sequence) { |
|
154 | + if ($sequence !== $namespace->sequence){ |
|
155 | 155 | $namespace->sequence = $sequence; |
156 | 156 | |
157 | 157 | $dependency->type->alias = $namespace->fullName(); |
158 | 158 | } |
159 | 159 | |
160 | 160 | $counters[$namespace->name][$sequence] = $namespace; |
161 | - } else { |
|
161 | + }else{ |
|
162 | 162 | $counters[$namespace->name] = [$namespace->sequence => $namespace]; |
163 | 163 | } |
164 | 164 | } |
@@ -171,8 +171,8 @@ discard block |
||
171 | 171 | */ |
172 | 172 | private function getAlreadyImportedNamespace(array $counters, NamespaceEntity $namespace): ?NamespaceEntity |
173 | 173 | { |
174 | - foreach ($counters as $counter) { |
|
175 | - if ($counter->equals($namespace)) { |
|
174 | + foreach ($counters as $counter){ |
|
175 | + if ($counter->equals($namespace)){ |
|
176 | 176 | return $counter; |
177 | 177 | } |
178 | 178 | } |
@@ -196,9 +196,9 @@ discard block |
||
196 | 196 | */ |
197 | 197 | private function parseNamespace(string $shortName, string $fullName): NamespaceEntity |
198 | 198 | { |
199 | - if (preg_match("/\d+$/", $shortName, $match)) { |
|
199 | + if (preg_match("/\d+$/", $shortName, $match)){ |
|
200 | 200 | $sequence = (int)$match[0]; |
201 | - if ($sequence > 0) { |
|
201 | + if ($sequence > 0){ |
|
202 | 202 | return NamespaceEntity::createWithSequence( |
203 | 203 | Utils::trimTrailingDigits($shortName, $sequence), |
204 | 204 | $fullName, |
@@ -58,8 +58,10 @@ discard block |
||
58 | 58 | */ |
59 | 59 | private function getReservedNamespacesWithAlias(ClassNode $definition, array $namespaces): array |
60 | 60 | { |
61 | - foreach ($definition->getStmts() as $stmt) { |
|
62 | - if (!$stmt->alias) { |
|
61 | + foreach ($definition->getStmts() as $stmt) |
|
62 | + { |
|
63 | + if (!$stmt->alias) |
|
64 | + { |
|
63 | 65 | continue; |
64 | 66 | } |
65 | 67 | |
@@ -76,8 +78,10 @@ discard block |
||
76 | 78 | */ |
77 | 79 | private function getReservedNamespacesWithoutAlias(ClassNode $definition, array $namespaces): array |
78 | 80 | { |
79 | - foreach ($definition->getStmts() as $stmt) { |
|
80 | - if ($stmt->alias || isset($namespaces[$stmt->shortName])) { |
|
81 | + foreach ($definition->getStmts() as $stmt) |
|
82 | + { |
|
83 | + if ($stmt->alias || isset($namespaces[$stmt->shortName])) |
|
84 | + { |
|
81 | 85 | continue; |
82 | 86 | } |
83 | 87 | |
@@ -94,12 +98,16 @@ discard block |
||
94 | 98 | private function initiateCounters(array $namespaces): array |
95 | 99 | { |
96 | 100 | $counters = []; |
97 | - foreach ($namespaces as $shortName => $fullName) { |
|
101 | + foreach ($namespaces as $shortName => $fullName) |
|
102 | + { |
|
98 | 103 | $namespace = $this->parseNamespace($shortName, $fullName); |
99 | 104 | |
100 | - if (isset($counters[$namespace->name])) { |
|
105 | + if (isset($counters[$namespace->name])) |
|
106 | + { |
|
101 | 107 | $counters[$namespace->name][$namespace->sequence] = $namespace; |
102 | - } else { |
|
108 | + } |
|
109 | + else |
|
110 | + { |
|
103 | 111 | $counters[$namespace->name] = [$namespace->sequence => $namespace]; |
104 | 112 | } |
105 | 113 | } |
@@ -113,52 +121,66 @@ discard block |
||
113 | 121 | */ |
114 | 122 | private function resolveImportsNamespaces(ClassNode $definition, array $counters): void |
115 | 123 | { |
116 | - if (!$definition->hasConstructor && $definition->constructorParams) { |
|
117 | - foreach ($definition->constructorParams as $param) { |
|
124 | + if (!$definition->hasConstructor && $definition->constructorParams) |
|
125 | + { |
|
126 | + foreach ($definition->constructorParams as $param) |
|
127 | + { |
|
118 | 128 | //no type (or type is internal), do nothing |
119 | - if (empty($param->type) || $param->isBuiltIn()) { |
|
129 | + if (empty($param->type) || $param->isBuiltIn()) |
|
130 | + { |
|
120 | 131 | continue; |
121 | 132 | } |
122 | 133 | |
123 | 134 | $namespace = $this->parseNamespaceFromType($param->type); |
124 | - if (isset($counters[$namespace->name])) { |
|
125 | - if ($this->getAlreadyImportedNamespace($counters[$namespace->name], $namespace)) { |
|
135 | + if (isset($counters[$namespace->name])) |
|
136 | + { |
|
137 | + if ($this->getAlreadyImportedNamespace($counters[$namespace->name], $namespace)) |
|
138 | + { |
|
126 | 139 | continue; |
127 | 140 | } |
128 | 141 | |
129 | 142 | $sequence = $this->sequences->find(array_keys($counters[$namespace->name]), $namespace->sequence); |
130 | - if ($sequence !== $namespace->sequence) { |
|
143 | + if ($sequence !== $namespace->sequence) |
|
144 | + { |
|
131 | 145 | $namespace->sequence = $sequence; |
132 | 146 | |
133 | 147 | $param->type->alias = $namespace->fullName(); |
134 | 148 | } |
135 | 149 | |
136 | 150 | $counters[$namespace->name][$sequence] = $namespace; |
137 | - } else { |
|
151 | + } |
|
152 | + else |
|
153 | + { |
|
138 | 154 | $counters[$namespace->name] = [$namespace->sequence => $namespace]; |
139 | 155 | } |
140 | 156 | } |
141 | 157 | } |
142 | 158 | |
143 | - foreach ($definition->dependencies as $dependency) { |
|
159 | + foreach ($definition->dependencies as $dependency) |
|
160 | + { |
|
144 | 161 | $namespace = $this->parseNamespaceFromType($dependency->type); |
145 | - if (isset($counters[$namespace->name])) { |
|
162 | + if (isset($counters[$namespace->name])) |
|
163 | + { |
|
146 | 164 | $alreadyImported = $this->getAlreadyImportedNamespace($counters[$namespace->name], $namespace); |
147 | - if ($alreadyImported !== null) { |
|
165 | + if ($alreadyImported !== null) |
|
166 | + { |
|
148 | 167 | $dependency->type->alias = $alreadyImported->fullName(); |
149 | 168 | |
150 | 169 | continue; |
151 | 170 | } |
152 | 171 | |
153 | 172 | $sequence = $this->sequences->find(array_keys($counters[$namespace->name]), $namespace->sequence); |
154 | - if ($sequence !== $namespace->sequence) { |
|
173 | + if ($sequence !== $namespace->sequence) |
|
174 | + { |
|
155 | 175 | $namespace->sequence = $sequence; |
156 | 176 | |
157 | 177 | $dependency->type->alias = $namespace->fullName(); |
158 | 178 | } |
159 | 179 | |
160 | 180 | $counters[$namespace->name][$sequence] = $namespace; |
161 | - } else { |
|
181 | + } |
|
182 | + else |
|
183 | + { |
|
162 | 184 | $counters[$namespace->name] = [$namespace->sequence => $namespace]; |
163 | 185 | } |
164 | 186 | } |
@@ -171,8 +193,10 @@ discard block |
||
171 | 193 | */ |
172 | 194 | private function getAlreadyImportedNamespace(array $counters, NamespaceEntity $namespace): ?NamespaceEntity |
173 | 195 | { |
174 | - foreach ($counters as $counter) { |
|
175 | - if ($counter->equals($namespace)) { |
|
196 | + foreach ($counters as $counter) |
|
197 | + { |
|
198 | + if ($counter->equals($namespace)) |
|
199 | + { |
|
176 | 200 | return $counter; |
177 | 201 | } |
178 | 202 | } |
@@ -196,9 +220,11 @@ discard block |
||
196 | 220 | */ |
197 | 221 | private function parseNamespace(string $shortName, string $fullName): NamespaceEntity |
198 | 222 | { |
199 | - if (preg_match("/\d+$/", $shortName, $match)) { |
|
223 | + if (preg_match("/\d+$/", $shortName, $match)) |
|
224 | + { |
|
200 | 225 | $sequence = (int)$match[0]; |
201 | - if ($sequence > 0) { |
|
226 | + if ($sequence > 0) |
|
227 | + { |
|
202 | 228 | return NamespaceEntity::createWithSequence( |
203 | 229 | Utils::trimTrailingDigits($shortName, $sequence), |
204 | 230 | $fullName, |
@@ -24,21 +24,21 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public function find(array $sequences, int $originSequence): int |
26 | 26 | { |
27 | - if (empty($sequences) || $originSequence > max($sequences)) { |
|
27 | + if (empty($sequences) || $originSequence > max($sequences)){ |
|
28 | 28 | return $originSequence; |
29 | 29 | } |
30 | 30 | |
31 | 31 | $gaps = $this->skippedSequences($sequences); |
32 | 32 | |
33 | - if (isset($gaps[$originSequence])) { |
|
33 | + if (isset($gaps[$originSequence])){ |
|
34 | 34 | return $originSequence; |
35 | 35 | } |
36 | 36 | |
37 | 37 | //we do not add "1" as postfix: $var, $var2, $var3, etc |
38 | 38 | unset($gaps[1]); |
39 | - if (empty($gaps)) { |
|
39 | + if (empty($gaps)){ |
|
40 | 40 | $max = max($sequences); |
41 | - if ($max === 0) { |
|
41 | + if ($max === 0){ |
|
42 | 42 | return 2; |
43 | 43 | } |
44 | 44 | |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | { |
57 | 57 | $skipped = []; |
58 | 58 | $max = max($sequences); |
59 | - for ($i = 0; $i < $max; $i++) { |
|
60 | - if (!in_array($i, $sequences, true)) { |
|
59 | + for ($i = 0; $i < $max; $i++){ |
|
60 | + if (!in_array($i, $sequences, true)){ |
|
61 | 61 | $skipped[$i] = $i; |
62 | 62 | } |
63 | 63 | } |
@@ -24,21 +24,25 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public function find(array $sequences, int $originSequence): int |
26 | 26 | { |
27 | - if (empty($sequences) || $originSequence > max($sequences)) { |
|
27 | + if (empty($sequences) || $originSequence > max($sequences)) |
|
28 | + { |
|
28 | 29 | return $originSequence; |
29 | 30 | } |
30 | 31 | |
31 | 32 | $gaps = $this->skippedSequences($sequences); |
32 | 33 | |
33 | - if (isset($gaps[$originSequence])) { |
|
34 | + if (isset($gaps[$originSequence])) |
|
35 | + { |
|
34 | 36 | return $originSequence; |
35 | 37 | } |
36 | 38 | |
37 | 39 | //we do not add "1" as postfix: $var, $var2, $var3, etc |
38 | 40 | unset($gaps[1]); |
39 | - if (empty($gaps)) { |
|
41 | + if (empty($gaps)) |
|
42 | + { |
|
40 | 43 | $max = max($sequences); |
41 | - if ($max === 0) { |
|
44 | + if ($max === 0) |
|
45 | + { |
|
42 | 46 | return 2; |
43 | 47 | } |
44 | 48 | |
@@ -56,8 +60,10 @@ discard block |
||
56 | 60 | { |
57 | 61 | $skipped = []; |
58 | 62 | $max = max($sequences); |
59 | - for ($i = 0; $i < $max; $i++) { |
|
60 | - if (!in_array($i, $sequences, true)) { |
|
63 | + for ($i = 0; $i < $max; $i++) |
|
64 | + { |
|
65 | + if (!in_array($i, $sequences, true)) |
|
66 | + { |
|
61 | 67 | $skipped[$i] = $i; |
62 | 68 | } |
63 | 69 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | $stmt = new self(); |
56 | 56 | $stmt->name = $parameter->getName(); |
57 | 57 | |
58 | - if ($parameter->hasType()) { |
|
58 | + if ($parameter->hasType()){ |
|
59 | 59 | /** @var \ReflectionType $type */ |
60 | 60 | $type = $parameter->getType(); |
61 | 61 | $stmt->type = Type::create($type->getName()); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $stmt->nullable = $type->allowsNull(); |
64 | 64 | } |
65 | 65 | |
66 | - if ($parameter->isDefaultValueAvailable()) { |
|
66 | + if ($parameter->isDefaultValueAvailable()){ |
|
67 | 67 | $stmt->hasDefault = true; |
68 | 68 | $stmt->default = $parameter->getDefaultValue(); |
69 | 69 | } |
@@ -55,7 +55,8 @@ discard block |
||
55 | 55 | $stmt = new self(); |
56 | 56 | $stmt->name = $parameter->getName(); |
57 | 57 | |
58 | - if ($parameter->hasType()) { |
|
58 | + if ($parameter->hasType()) |
|
59 | + { |
|
59 | 60 | /** @var \ReflectionType $type */ |
60 | 61 | $type = $parameter->getType(); |
61 | 62 | $stmt->type = Type::create($type->getName()); |
@@ -63,7 +64,8 @@ discard block |
||
63 | 64 | $stmt->nullable = $type->allowsNull(); |
64 | 65 | } |
65 | 66 | |
66 | - if ($parameter->isDefaultValueAvailable()) { |
|
67 | + if ($parameter->isDefaultValueAvailable()) |
|
68 | + { |
|
67 | 69 | $stmt->hasDefault = true; |
68 | 70 | $stmt->default = $parameter->getDefaultValue(); |
69 | 71 | } |
@@ -36,7 +36,7 @@ |
||
36 | 36 | */ |
37 | 37 | public function __toString(): string |
38 | 38 | { |
39 | - if ($this->alias) { |
|
39 | + if ($this->alias){ |
|
40 | 40 | return "{$this->name} as $this->alias"; |
41 | 41 | } |
42 | 42 |
@@ -36,7 +36,8 @@ |
||
36 | 36 | */ |
37 | 37 | public function __toString(): string |
38 | 38 | { |
39 | - if ($this->alias) { |
|
39 | + if ($this->alias) |
|
40 | + { |
|
40 | 41 | return "{$this->name} as $this->alias"; |
41 | 42 | } |
42 | 43 |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $type = new self(); |
34 | 34 | |
35 | 35 | $fullName = null; |
36 | - if ($type->hasShortName($name)) { |
|
36 | + if ($type->hasShortName($name)){ |
|
37 | 37 | $fullName = $name; |
38 | 38 | $name = Utils::shortName($name); |
39 | 39 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | public function getSlashedShortName(bool $builtIn): string |
60 | 60 | { |
61 | 61 | $type = $this->shortName; |
62 | - if (!$builtIn && !$this->fullName) { |
|
62 | + if (!$builtIn && !$this->fullName){ |
|
63 | 63 | $type = "\\$type"; |
64 | 64 | } |
65 | 65 |
@@ -33,7 +33,8 @@ discard block |
||
33 | 33 | $type = new self(); |
34 | 34 | |
35 | 35 | $fullName = null; |
36 | - if ($type->hasShortName($name)) { |
|
36 | + if ($type->hasShortName($name)) |
|
37 | + { |
|
37 | 38 | $fullName = $name; |
38 | 39 | $name = Utils::shortName($name); |
39 | 40 | } |
@@ -59,7 +60,8 @@ discard block |
||
59 | 60 | public function getSlashedShortName(bool $builtIn): string |
60 | 61 | { |
61 | 62 | $type = $this->shortName; |
62 | - if (!$builtIn && !$this->fullName) { |
|
63 | + if (!$builtIn && !$this->fullName) |
|
64 | + { |
|
63 | 65 | $type = "\\$type"; |
64 | 66 | } |
65 | 67 |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $prototypeBootloader->initAnnotations($this->container, true); |
34 | 34 | |
35 | 35 | $dependencies = $this->registry->getPropertyBindings(); |
36 | - if ($dependencies === []) { |
|
36 | + if ($dependencies === []){ |
|
37 | 37 | $this->writeln('<comment>No prototyped shortcuts found.</comment>'); |
38 | 38 | return; |
39 | 39 | } |
@@ -42,14 +42,14 @@ discard block |
||
42 | 42 | |
43 | 43 | $trait = new \ReflectionClass(PrototypeTrait::class); |
44 | 44 | $docComment = $trait->getDocComment(); |
45 | - if ($docComment === false) { |
|
45 | + if ($docComment === false){ |
|
46 | 46 | $this->write('<fg=reg>DOCComment is missing</fg=red>'); |
47 | 47 | return; |
48 | 48 | } |
49 | 49 | |
50 | 50 | $filename = $trait->getFileName(); |
51 | 51 | |
52 | - try { |
|
52 | + try{ |
|
53 | 53 | file_put_contents( |
54 | 54 | $filename, |
55 | 55 | str_replace( |
@@ -58,17 +58,17 @@ discard block |
||
58 | 58 | file_get_contents($filename) |
59 | 59 | ) |
60 | 60 | ); |
61 | - } catch (\Throwable $e) { |
|
62 | - $this->write('<fg=red>' . $e->getMessage() . "</fg=red>\n"); |
|
61 | + }catch (\Throwable $e){ |
|
62 | + $this->write('<fg=red>'.$e->getMessage()."</fg=red>\n"); |
|
63 | 63 | return; |
64 | 64 | } |
65 | 65 | |
66 | 66 | $this->write("<fg=green>complete</fg=green>\n"); |
67 | 67 | |
68 | - if ($this->isVerbose()) { |
|
68 | + if ($this->isVerbose()){ |
|
69 | 69 | $grid = $this->table(['Property:', 'Target:']); |
70 | 70 | |
71 | - foreach ($dependencies as $dependency) { |
|
71 | + foreach ($dependencies as $dependency){ |
|
72 | 72 | $grid->addRow([$dependency->var, $dependency->type->fullName]); |
73 | 73 | } |
74 | 74 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | ); |
89 | 89 | $an->lines[] = new Annotation\Line(''); |
90 | 90 | |
91 | - foreach ($dependencies as $dependency) { |
|
91 | + foreach ($dependencies as $dependency){ |
|
92 | 92 | $an->lines[] = new Annotation\Line( |
93 | 93 | sprintf('\\%s $%s', $dependency->type->fullName, $dependency->var), |
94 | 94 | 'property' |
@@ -33,7 +33,8 @@ discard block |
||
33 | 33 | $prototypeBootloader->initAnnotations($this->container, true); |
34 | 34 | |
35 | 35 | $dependencies = $this->registry->getPropertyBindings(); |
36 | - if ($dependencies === []) { |
|
36 | + if ($dependencies === []) |
|
37 | + { |
|
37 | 38 | $this->writeln('<comment>No prototyped shortcuts found.</comment>'); |
38 | 39 | return; |
39 | 40 | } |
@@ -42,14 +43,16 @@ discard block |
||
42 | 43 | |
43 | 44 | $trait = new \ReflectionClass(PrototypeTrait::class); |
44 | 45 | $docComment = $trait->getDocComment(); |
45 | - if ($docComment === false) { |
|
46 | + if ($docComment === false) |
|
47 | + { |
|
46 | 48 | $this->write('<fg=reg>DOCComment is missing</fg=red>'); |
47 | 49 | return; |
48 | 50 | } |
49 | 51 | |
50 | 52 | $filename = $trait->getFileName(); |
51 | 53 | |
52 | - try { |
|
54 | + try |
|
55 | + { |
|
53 | 56 | file_put_contents( |
54 | 57 | $filename, |
55 | 58 | str_replace( |
@@ -58,17 +61,21 @@ discard block |
||
58 | 61 | file_get_contents($filename) |
59 | 62 | ) |
60 | 63 | ); |
61 | - } catch (\Throwable $e) { |
|
64 | + } |
|
65 | + catch (\Throwable $e) |
|
66 | + { |
|
62 | 67 | $this->write('<fg=red>' . $e->getMessage() . "</fg=red>\n"); |
63 | 68 | return; |
64 | 69 | } |
65 | 70 | |
66 | 71 | $this->write("<fg=green>complete</fg=green>\n"); |
67 | 72 | |
68 | - if ($this->isVerbose()) { |
|
73 | + if ($this->isVerbose()) |
|
74 | + { |
|
69 | 75 | $grid = $this->table(['Property:', 'Target:']); |
70 | 76 | |
71 | - foreach ($dependencies as $dependency) { |
|
77 | + foreach ($dependencies as $dependency) |
|
78 | + { |
|
72 | 79 | $grid->addRow([$dependency->var, $dependency->type->fullName]); |
73 | 80 | } |
74 | 81 | |
@@ -88,7 +95,8 @@ discard block |
||
88 | 95 | ); |
89 | 96 | $an->lines[] = new Annotation\Line(''); |
90 | 97 | |
91 | - foreach ($dependencies as $dependency) { |
|
98 | + foreach ($dependencies as $dependency) |
|
99 | + { |
|
92 | 100 | $an->lines[] = new Annotation\Line( |
93 | 101 | sprintf('\\%s $%s', $dependency->type->fullName, $dependency->var), |
94 | 102 | 'property' |
@@ -50,13 +50,13 @@ |
||
50 | 50 | $node instanceof Node\Expr\PropertyFetch && |
51 | 51 | $node->var instanceof Node\Expr\Variable && |
52 | 52 | $node->var->name === 'this' |
53 | - ) { |
|
53 | + ){ |
|
54 | 54 | $this->requested[$node->name->name] = $node->name->name; |
55 | 55 | } |
56 | 56 | |
57 | - if ($node instanceof Node\Stmt\Property) { |
|
58 | - foreach ($node->props as $prop) { |
|
59 | - if ($prop instanceof Node\Stmt\PropertyProperty) { |
|
57 | + if ($node instanceof Node\Stmt\Property){ |
|
58 | + foreach ($node->props as $prop){ |
|
59 | + if ($prop instanceof Node\Stmt\PropertyProperty){ |
|
60 | 60 | $this->properties[$prop->name->name] = $prop->name->name; |
61 | 61 | } |
62 | 62 | } |
@@ -54,9 +54,12 @@ |
||
54 | 54 | $this->requested[$node->name->name] = $node->name->name; |
55 | 55 | } |
56 | 56 | |
57 | - if ($node instanceof Node\Stmt\Property) { |
|
58 | - foreach ($node->props as $prop) { |
|
59 | - if ($prop instanceof Node\Stmt\PropertyProperty) { |
|
57 | + if ($node instanceof Node\Stmt\Property) |
|
58 | + { |
|
59 | + foreach ($node->props as $prop) |
|
60 | + { |
|
61 | + if ($prop instanceof Node\Stmt\PropertyProperty) |
|
62 | + { |
|
60 | 63 | $this->properties[$prop->name->name] = $prop->name->name; |
61 | 64 | } |
62 | 65 | } |
@@ -27,17 +27,17 @@ |
||
27 | 27 | */ |
28 | 28 | public function leaveNode(Node $node) |
29 | 29 | { |
30 | - if (!$node instanceof Node\Stmt\Use_) { |
|
30 | + if (!$node instanceof Node\Stmt\Use_){ |
|
31 | 31 | return null; |
32 | 32 | } |
33 | 33 | |
34 | - foreach ($node->uses as $index => $use) { |
|
35 | - if ($use->name->toString() === PrototypeTrait::class) { |
|
34 | + foreach ($node->uses as $index => $use){ |
|
35 | + if ($use->name->toString() === PrototypeTrait::class){ |
|
36 | 36 | unset($node->uses[$index]); |
37 | 37 | } |
38 | 38 | } |
39 | 39 | |
40 | - if (empty($node->uses)) { |
|
40 | + if (empty($node->uses)){ |
|
41 | 41 | return NodeTraverser::REMOVE_NODE; |
42 | 42 | } |
43 | 43 |
@@ -27,17 +27,21 @@ |
||
27 | 27 | */ |
28 | 28 | public function leaveNode(Node $node) |
29 | 29 | { |
30 | - if (!$node instanceof Node\Stmt\Use_) { |
|
30 | + if (!$node instanceof Node\Stmt\Use_) |
|
31 | + { |
|
31 | 32 | return null; |
32 | 33 | } |
33 | 34 | |
34 | - foreach ($node->uses as $index => $use) { |
|
35 | - if ($use->name->toString() === PrototypeTrait::class) { |
|
35 | + foreach ($node->uses as $index => $use) |
|
36 | + { |
|
37 | + if ($use->name->toString() === PrototypeTrait::class) |
|
38 | + { |
|
36 | 39 | unset($node->uses[$index]); |
37 | 40 | } |
38 | 41 | } |
39 | 42 | |
40 | - if (empty($node->uses)) { |
|
43 | + if (empty($node->uses)) |
|
44 | + { |
|
41 | 45 | return NodeTraverser::REMOVE_NODE; |
42 | 46 | } |
43 | 47 |