@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | public function perform(): void |
23 | 23 | { |
24 | 24 | $prototyped = $this->locator->getTargetClasses(); |
25 | - if ($prototyped === []) { |
|
25 | + if ($prototyped === []){ |
|
26 | 26 | $this->writeln('<comment>No prototyped classes found.</comment>'); |
27 | 27 | |
28 | 28 | return; |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | $grid = $this->table(['Class:', 'Property:', 'Target:']); |
32 | 32 | |
33 | - foreach ($prototyped as $class) { |
|
33 | + foreach ($prototyped as $class){ |
|
34 | 34 | $proto = $this->getPrototypeProperties($class, $prototyped); |
35 | 35 | |
36 | 36 | $grid->addRow([$class->getName(), $this->mergeNames($proto), $this->mergeTargets($proto)]); |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | $results = [$this->readProperties($class)]; |
59 | 59 | |
60 | 60 | $parent = $class->getParentClass(); |
61 | - while ($parent instanceof \ReflectionClass && isset($all[$parent->getName()])) { |
|
61 | + while ($parent instanceof \ReflectionClass && isset($all[$parent->getName()])){ |
|
62 | 62 | $results[] = $this->readProperties($parent); |
63 | 63 | $parent = $parent->getParentClass(); |
64 | 64 | } |
@@ -91,8 +91,8 @@ discard block |
||
91 | 91 | { |
92 | 92 | $result = []; |
93 | 93 | |
94 | - foreach ($properties as $target) { |
|
95 | - if ($target instanceof \Throwable) { |
|
94 | + foreach ($properties as $target){ |
|
95 | + if ($target instanceof \Throwable){ |
|
96 | 96 | $result[] = sprintf( |
97 | 97 | '<fg=red>%s [f: %s, l: %s]</fg=red>', |
98 | 98 | $target->getMessage(), |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | continue; |
103 | 103 | } |
104 | 104 | |
105 | - if ($target === null) { |
|
105 | + if ($target === null){ |
|
106 | 106 | $result[] = '<fg=yellow>undefined</fg=yellow>'; |
107 | 107 | continue; |
108 | 108 | } |
@@ -115,16 +115,16 @@ discard block |
||
115 | 115 | |
116 | 116 | private function readProperties(\ReflectionClass $class): array |
117 | 117 | { |
118 | - if (isset($this->cache[$class->getFileName()])) { |
|
118 | + if (isset($this->cache[$class->getFileName()])){ |
|
119 | 119 | $proto = $this->cache[$class->getFileName()]; |
120 | - } else { |
|
120 | + }else{ |
|
121 | 121 | $proto = $this->getExtractor()->getPrototypeProperties(file_get_contents($class->getFilename())); |
122 | 122 | $this->cache[$class->getFileName()] = $proto; |
123 | 123 | } |
124 | 124 | |
125 | 125 | $result = []; |
126 | - foreach ($proto as $name) { |
|
127 | - if (!isset($result[$name])) { |
|
126 | + foreach ($proto as $name){ |
|
127 | + if (!isset($result[$name])){ |
|
128 | 128 | $result[$name] = $this->registry->resolveProperty($name); |
129 | 129 | } |
130 | 130 | } |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | |
135 | 135 | private function reverse(array $results): ?\Generator |
136 | 136 | { |
137 | - foreach (array_reverse($results) as $result) { |
|
137 | + foreach (array_reverse($results) as $result){ |
|
138 | 138 | yield from $result; |
139 | 139 | } |
140 | 140 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | public function perform(): void |
52 | 52 | { |
53 | 53 | $prototyped = $this->locator->getTargetClasses(); |
54 | - if ($prototyped === []) { |
|
54 | + if ($prototyped === []){ |
|
55 | 55 | $this->writeln('<comment>No prototyped classes found.</comment>'); |
56 | 56 | |
57 | 57 | return; |
@@ -59,18 +59,18 @@ discard block |
||
59 | 59 | |
60 | 60 | $targets = []; |
61 | 61 | |
62 | - foreach ($prototyped as $class) { |
|
62 | + foreach ($prototyped as $class){ |
|
63 | 63 | $proto = $this->getPrototypeProperties($class, $prototyped); |
64 | - if (empty($proto)) { |
|
64 | + if (empty($proto)){ |
|
65 | 65 | $modified = $this->modify($class, $proto); |
66 | - if ($modified !== null) { |
|
66 | + if ($modified !== null){ |
|
67 | 67 | $targets[] = $modified; |
68 | 68 | } |
69 | 69 | continue; |
70 | 70 | } |
71 | 71 | |
72 | - foreach ($proto as $target) { |
|
73 | - if ($target instanceof \Throwable) { |
|
72 | + foreach ($proto as $target){ |
|
73 | + if ($target instanceof \Throwable){ |
|
74 | 74 | $targets[] = [ |
75 | 75 | $class->getName(), |
76 | 76 | $target->getMessage(), |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | continue 2; |
80 | 80 | } |
81 | 81 | |
82 | - if ($target === null) { |
|
82 | + if ($target === null){ |
|
83 | 83 | continue 2; |
84 | 84 | } |
85 | 85 | } |
@@ -87,14 +87,14 @@ discard block |
||
87 | 87 | $targets[] = [$class->getName(), $this->mergeNames($proto), $this->mergeTargets($proto)]; |
88 | 88 | |
89 | 89 | $modified = $this->modify($class, $proto); |
90 | - if ($modified !== null) { |
|
90 | + if ($modified !== null){ |
|
91 | 91 | $targets[] = $modified; |
92 | 92 | } |
93 | 93 | } |
94 | 94 | |
95 | - if (!empty($targets)) { |
|
95 | + if (!empty($targets)){ |
|
96 | 96 | $grid = $this->table(['Class:', 'Property:', 'Target:']); |
97 | - foreach ($targets as $target) { |
|
97 | + foreach ($targets as $target){ |
|
98 | 98 | $grid->addRow($target); |
99 | 99 | } |
100 | 100 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | private function modify(\ReflectionClass $class, array $proto): ?array |
106 | 106 | { |
107 | 107 | $classDefinition = $this->extractor->extract($class->getFilename(), $proto); |
108 | - try { |
|
108 | + try{ |
|
109 | 109 | $modified = $this->injector->injectDependencies( |
110 | 110 | file_get_contents($class->getFileName()), |
111 | 111 | $classDefinition, |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | |
117 | 117 | file_put_contents($class->getFileName(), $modified); |
118 | 118 | return null; |
119 | - } catch (\Throwable $e) { |
|
119 | + }catch (\Throwable $e){ |
|
120 | 120 | return [$class->getName(), $e->getMessage(), "{$e->getFile()}:L{$e->getLine()}"]; |
121 | 121 | } |
122 | 122 | } |