Passed
Pull Request — master (#656)
by Abdul Malik
11:30 queued 05:15
created
src/Prototype/src/NodeVisitors/RemoveUse.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -27,17 +27,17 @@
 block discarded – undo
27 27
      */
28 28
     public function leaveNode(Node $node)
29 29
     {
30
-        if (!$node instanceof Use_) {
30
+        if (!$node instanceof 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
 
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -27,17 +27,21 @@
 block discarded – undo
27 27
      */
28 28
     public function leaveNode(Node $node)
29 29
     {
30
-        if (!$node instanceof Use_) {
30
+        if (!$node instanceof 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
 
Please login to merge, or discard this patch.
src/Prototype/src/Bootloader/PrototypeBootloader.php 2 patches
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -130,8 +130,8 @@  discard block
 block discarded – undo
130 130
     public function initAnnotations(ContainerInterface $container, bool $reset = false): void
131 131
     {
132 132
         $prototyped = $this->memory->loadData('prototyped');
133
-        if (!$reset && $prototyped !== null) {
134
-            foreach ($prototyped as $property => $class) {
133
+        if (!$reset && $prototyped !== null){
134
+            foreach ($prototyped as $property => $class){
135 135
                 $this->bindProperty($property, $class);
136 136
             }
137 137
 
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
         $reader = $container->get(ReaderInterface::class);
144 144
 
145 145
         $prototyped = [];
146
-        foreach ($locator->getClasses() as $class) {
146
+        foreach ($locator->getClasses() as $class){
147 147
             $meta = $reader->firstClassMetadata($class, Prototyped::class);
148 148
 
149
-            if ($meta === null) {
149
+            if ($meta === null){
150 150
                 continue;
151 151
             }
152 152
 
@@ -162,19 +162,19 @@  discard block
 block discarded – undo
162 162
      */
163 163
     public function initCycle(ContainerInterface $container): void
164 164
     {
165
-        if (!$container->has(SchemaInterface::class)) {
165
+        if (!$container->has(SchemaInterface::class)){
166 166
             return;
167 167
         }
168 168
 
169 169
         /** @var ORM\SchemaInterface|null $schema */
170 170
         $schema = $container->get(SchemaInterface::class);
171
-        if ($schema === null) {
171
+        if ($schema === null){
172 172
             return;
173 173
         }
174 174
 
175
-        foreach ($schema->getRoles() as $role) {
175
+        foreach ($schema->getRoles() as $role){
176 176
             $repository = $schema->define($role, SchemaInterface::REPOSITORY);
177
-            if ($repository === Repository::class || $repository === null) {
177
+            if ($repository === Repository::class || $repository === null){
178 178
                 // default repository can not be wired
179 179
                 continue;
180 180
             }
@@ -185,23 +185,23 @@  discard block
 block discarded – undo
185 185
 
186 186
     private function initDefaults(ContainerInterface $container): void
187 187
     {
188
-        foreach (self::DEFAULT_SHORTCUTS as $property => $shortcut) {
189
-            if (is_array($shortcut) && isset($shortcut['resolve'])) {
190
-                if (isset($shortcut['with'])) {
188
+        foreach (self::DEFAULT_SHORTCUTS as $property => $shortcut){
189
+            if (is_array($shortcut) && isset($shortcut['resolve'])){
190
+                if (isset($shortcut['with'])){
191 191
                     // check dependencies
192
-                    foreach ($shortcut['with'] as $dep) {
193
-                        if (!class_exists($dep, true) && !interface_exists($dep, true)) {
192
+                    foreach ($shortcut['with'] as $dep){
193
+                        if (!class_exists($dep, true) && !interface_exists($dep, true)){
194 194
                             continue 2;
195 195
                         }
196 196
                     }
197 197
                 }
198 198
 
199
-                try {
199
+                try{
200 200
                     $target = $container->get($shortcut['resolve']);
201
-                    if (is_object($target)) {
201
+                    if (is_object($target)){
202 202
                         $this->bindProperty($property, get_class($target));
203 203
                     }
204
-                } catch (ContainerExceptionInterface $e) {
204
+                }catch (ContainerExceptionInterface $e){
205 205
                     continue;
206 206
                 }
207 207
 
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
                 is_string($shortcut)
213 213
                 && (class_exists($shortcut, true)
214 214
                     || interface_exists($shortcut, true))
215
-            ) {
215
+            ){
216 216
                 $this->bindProperty($property, $shortcut);
217 217
             }
218 218
         }
Please login to merge, or discard this patch.
Braces   +33 added lines, -16 removed lines patch added patch discarded remove patch
@@ -130,8 +130,10 @@  discard block
 block discarded – undo
130 130
     public function initAnnotations(ContainerInterface $container, bool $reset = false): void
131 131
     {
132 132
         $prototyped = $this->memory->loadData('prototyped');
133
-        if (!$reset && $prototyped !== null) {
134
-            foreach ($prototyped as $property => $class) {
133
+        if (!$reset && $prototyped !== null)
134
+        {
135
+            foreach ($prototyped as $property => $class)
136
+            {
135 137
                 $this->bindProperty($property, $class);
136 138
             }
137 139
 
@@ -143,10 +145,12 @@  discard block
 block discarded – undo
143 145
         $reader = $container->get(ReaderInterface::class);
144 146
 
145 147
         $prototyped = [];
146
-        foreach ($locator->getClasses() as $class) {
148
+        foreach ($locator->getClasses() as $class)
149
+        {
147 150
             $meta = $reader->firstClassMetadata($class, Prototyped::class);
148 151
 
149
-            if ($meta === null) {
152
+            if ($meta === null)
153
+            {
150 154
                 continue;
151 155
             }
152 156
 
@@ -162,19 +166,23 @@  discard block
 block discarded – undo
162 166
      */
163 167
     public function initCycle(ContainerInterface $container): void
164 168
     {
165
-        if (!$container->has(SchemaInterface::class)) {
169
+        if (!$container->has(SchemaInterface::class))
170
+        {
166 171
             return;
167 172
         }
168 173
 
169 174
         /** @var ORM\SchemaInterface|null $schema */
170 175
         $schema = $container->get(SchemaInterface::class);
171
-        if ($schema === null) {
176
+        if ($schema === null)
177
+        {
172 178
             return;
173 179
         }
174 180
 
175
-        foreach ($schema->getRoles() as $role) {
181
+        foreach ($schema->getRoles() as $role)
182
+        {
176 183
             $repository = $schema->define($role, SchemaInterface::REPOSITORY);
177
-            if ($repository === Repository::class || $repository === null) {
184
+            if ($repository === Repository::class || $repository === null)
185
+            {
178 186
                 // default repository can not be wired
179 187
                 continue;
180 188
             }
@@ -185,23 +193,32 @@  discard block
 block discarded – undo
185 193
 
186 194
     private function initDefaults(ContainerInterface $container): void
187 195
     {
188
-        foreach (self::DEFAULT_SHORTCUTS as $property => $shortcut) {
189
-            if (is_array($shortcut) && isset($shortcut['resolve'])) {
190
-                if (isset($shortcut['with'])) {
196
+        foreach (self::DEFAULT_SHORTCUTS as $property => $shortcut)
197
+        {
198
+            if (is_array($shortcut) && isset($shortcut['resolve']))
199
+            {
200
+                if (isset($shortcut['with']))
201
+                {
191 202
                     // check dependencies
192
-                    foreach ($shortcut['with'] as $dep) {
193
-                        if (!class_exists($dep, true) && !interface_exists($dep, true)) {
203
+                    foreach ($shortcut['with'] as $dep)
204
+                    {
205
+                        if (!class_exists($dep, true) && !interface_exists($dep, true))
206
+                        {
194 207
                             continue 2;
195 208
                         }
196 209
                     }
197 210
                 }
198 211
 
199
-                try {
212
+                try
213
+                {
200 214
                     $target = $container->get($shortcut['resolve']);
201
-                    if (is_object($target)) {
215
+                    if (is_object($target))
216
+                    {
202 217
                         $this->bindProperty($property, get_class($target));
203 218
                     }
204
-                } catch (ContainerExceptionInterface $e) {
219
+                }
220
+                catch (ContainerExceptionInterface $e)
221
+                {
205 222
                     continue;
206 223
                 }
207 224
 
Please login to merge, or discard this patch.
src/Prototype/src/NodeExtractor.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
         Names $namesResolver,
41 41
         Namespaces $namespacesResolver,
42 42
         Parser $parser = null
43
-    ) {
43
+    ){
44 44
         $this->namesResolver = $namesResolver;
45 45
         $this->namespacesResolver = $namespacesResolver;
46 46
         $this->parser = $parser ?? (new ParserFactory())->create(ParserFactory::ONLY_PHP7);
@@ -77,11 +77,11 @@  discard block
 block discarded – undo
77 77
         $declarator = new DeclareClass();
78 78
         $this->traverse($filename, $declarator);
79 79
 
80
-        if (empty($declarator->getClass())) {
80
+        if (empty($declarator->getClass())){
81 81
             throw new ClassNotDeclaredException($filename);
82 82
         }
83 83
 
84
-        if ($declarator->getNamespace()) {
84
+        if ($declarator->getNamespace()){
85 85
             return ClassNode::createWithNamespace($declarator->getClass(), $declarator->getNamespace());
86 86
         }
87 87
 
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
     {
93 93
         $tr = new NodeTraverser();
94 94
 
95
-        foreach ($visitors as $visitor) {
95
+        foreach ($visitors as $visitor){
96 96
             $tr->addVisitor($visitor);
97 97
         }
98 98
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 
102 102
     private function fillStmts(ClassNode $definition, array $imports): void
103 103
     {
104
-        foreach ($imports as $import) {
104
+        foreach ($imports as $import){
105 105
             $definition->addImportUsage($import['name'], $import['alias']);
106 106
         }
107 107
     }
@@ -114,10 +114,10 @@  discard block
 block discarded – undo
114 114
         $reflection = new ReflectionClass("{$definition->namespace}\\{$definition->class}");
115 115
 
116 116
         $constructor = $reflection->getConstructor();
117
-        if ($constructor !== null) {
117
+        if ($constructor !== null){
118 118
             $definition->hasConstructor = $constructor->getDeclaringClass()->getName() === $reflection->getName();
119 119
 
120
-            foreach ($reflection->getConstructor()->getParameters() as $parameter) {
120
+            foreach ($reflection->getConstructor()->getParameters() as $parameter){
121 121
                 $definition->addParam($parameter);
122 122
             }
123 123
         }
@@ -129,8 +129,8 @@  discard block
 block discarded – undo
129 129
      */
130 130
     private function fillConstructorVars(array $vars, ClassNode $definition): void
131 131
     {
132
-        foreach ($vars as $k => $var) {
133
-            if (isset($definition->constructorParams[$var])) {
132
+        foreach ($vars as $k => $var){
133
+            if (isset($definition->constructorParams[$var])){
134 134
                 unset($vars[$k]);
135 135
             }
136 136
         }
Please login to merge, or discard this patch.
Braces   +16 added lines, -8 removed lines patch added patch discarded remove patch
@@ -77,11 +77,13 @@  discard block
 block discarded – undo
77 77
         $declarator = new DeclareClass();
78 78
         $this->traverse($filename, $declarator);
79 79
 
80
-        if (empty($declarator->getClass())) {
80
+        if (empty($declarator->getClass()))
81
+        {
81 82
             throw new ClassNotDeclaredException($filename);
82 83
         }
83 84
 
84
-        if ($declarator->getNamespace()) {
85
+        if ($declarator->getNamespace())
86
+        {
85 87
             return ClassNode::createWithNamespace($declarator->getClass(), $declarator->getNamespace());
86 88
         }
87 89
 
@@ -92,7 +94,8 @@  discard block
 block discarded – undo
92 94
     {
93 95
         $tr = new NodeTraverser();
94 96
 
95
-        foreach ($visitors as $visitor) {
97
+        foreach ($visitors as $visitor)
98
+        {
96 99
             $tr->addVisitor($visitor);
97 100
         }
98 101
 
@@ -101,7 +104,8 @@  discard block
 block discarded – undo
101 104
 
102 105
     private function fillStmts(ClassNode $definition, array $imports): void
103 106
     {
104
-        foreach ($imports as $import) {
107
+        foreach ($imports as $import)
108
+        {
105 109
             $definition->addImportUsage($import['name'], $import['alias']);
106 110
         }
107 111
     }
@@ -114,10 +118,12 @@  discard block
 block discarded – undo
114 118
         $reflection = new ReflectionClass("{$definition->namespace}\\{$definition->class}");
115 119
 
116 120
         $constructor = $reflection->getConstructor();
117
-        if ($constructor !== null) {
121
+        if ($constructor !== null)
122
+        {
118 123
             $definition->hasConstructor = $constructor->getDeclaringClass()->getName() === $reflection->getName();
119 124
 
120
-            foreach ($reflection->getConstructor()->getParameters() as $parameter) {
125
+            foreach ($reflection->getConstructor()->getParameters() as $parameter)
126
+            {
121 127
                 $definition->addParam($parameter);
122 128
             }
123 129
         }
@@ -129,8 +135,10 @@  discard block
 block discarded – undo
129 135
      */
130 136
     private function fillConstructorVars(array $vars, ClassNode $definition): void
131 137
     {
132
-        foreach ($vars as $k => $var) {
133
-            if (isset($definition->constructorParams[$var])) {
138
+        foreach ($vars as $k => $var)
139
+        {
140
+            if (isset($definition->constructorParams[$var]))
141
+            {
134 142
                 unset($vars[$k]);
135 143
             }
136 144
         }
Please login to merge, or discard this patch.
src/Prototype/src/Injector.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      */
47 47
     public function __construct(Lexer $lexer = null, PrettyPrinterAbstract $printer = null)
48 48
     {
49
-        if ($lexer === null) {
49
+        if ($lexer === null){
50 50
             $lexer = new Emulative([
51 51
                 'usedAttributes' => [
52 52
                     'comments',
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
         bool $useTypedProperties = false,
79 79
         bool $noPhpDoc = false
80 80
     ): string {
81
-        if (empty($node->dependencies)) {
82
-            if ($removeTrait) {
81
+        if (empty($node->dependencies)){
82
+            if ($removeTrait){
83 83
                 $tr = new NodeTraverser();
84 84
                 $tr->addVisitor(new RemoveUse());
85 85
                 $tr->addVisitor(new RemoveTrait());
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
         $tr = new NodeTraverser();
94 94
         $tr->addVisitor(new AddUse($node));
95 95
 
96
-        if ($removeTrait) {
96
+        if ($removeTrait){
97 97
             $tr->addVisitor(new RemoveUse());
98 98
             $tr->addVisitor(new RemoveTrait());
99 99
         }
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -46,7 +46,8 @@  discard block
 block discarded – undo
46 46
      */
47 47
     public function __construct(Lexer $lexer = null, PrettyPrinterAbstract $printer = null)
48 48
     {
49
-        if ($lexer === null) {
49
+        if ($lexer === null)
50
+        {
50 51
             $lexer = new Emulative([
51 52
                 'usedAttributes' => [
52 53
                     'comments',
@@ -78,8 +79,10 @@  discard block
 block discarded – undo
78 79
         bool $useTypedProperties = false,
79 80
         bool $noPhpDoc = false
80 81
     ): string {
81
-        if (empty($node->dependencies)) {
82
-            if ($removeTrait) {
82
+        if (empty($node->dependencies))
83
+        {
84
+            if ($removeTrait)
85
+            {
83 86
                 $tr = new NodeTraverser();
84 87
                 $tr->addVisitor(new RemoveUse());
85 88
                 $tr->addVisitor(new RemoveTrait());
@@ -93,7 +96,8 @@  discard block
 block discarded – undo
93 96
         $tr = new NodeTraverser();
94 97
         $tr->addVisitor(new AddUse($node));
95 98
 
96
-        if ($removeTrait) {
99
+        if ($removeTrait)
100
+        {
97 101
             $tr->addVisitor(new RemoveUse());
98 102
             $tr->addVisitor(new RemoveTrait());
99 103
         }
Please login to merge, or discard this patch.
src/Prototype/src/Traits/PrototypeTrait.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
     public function __get(string $name)
33 33
     {
34 34
         $container = ContainerScope::getContainer();
35
-        if ($container === null || !$container->has(PrototypeRegistry::class)) {
35
+        if ($container === null || !$container->has(PrototypeRegistry::class)){
36 36
             throw new ScopeException(
37 37
                 "Unable to resolve prototyped dependency `{$name}`, invalid container scope"
38 38
             );
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
             $target === null ||
47 47
             $target instanceof Throwable ||
48 48
             $target->type->fullName === null
49
-        ) {
49
+        ){
50 50
             throw new PrototypeException(
51 51
                 "Undefined prototype property `{$name}`",
52 52
                 0,
Please login to merge, or discard this patch.
src/Prototype/src/ClassNode/ConstructorParam.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -57,13 +57,13 @@
 block discarded – undo
57 57
         $stmt->name = $parameter->getName();
58 58
 
59 59
         $type = $parameter->getType();
60
-        if ($type instanceof ReflectionNamedType) {
60
+        if ($type instanceof ReflectionNamedType){
61 61
             $stmt->type = Type::create($type->getName());
62 62
             $stmt->builtIn = $type->isBuiltin();
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
         }
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -57,13 +57,15 @@
 block discarded – undo
57 57
         $stmt->name = $parameter->getName();
58 58
 
59 59
         $type = $parameter->getType();
60
-        if ($type instanceof ReflectionNamedType) {
60
+        if ($type instanceof ReflectionNamedType)
61
+        {
61 62
             $stmt->type = Type::create($type->getName());
62 63
             $stmt->builtIn = $type->isBuiltin();
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
         }
Please login to merge, or discard this patch.
src/Prototype/src/Command/InjectCommand.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
     public function perform(): void
54 54
     {
55 55
         $prototyped = $this->locator->getTargetClasses();
56
-        if ($prototyped === []) {
56
+        if ($prototyped === []){
57 57
             $this->writeln('<comment>No prototyped classes found.</comment>');
58 58
 
59 59
             return;
@@ -61,18 +61,18 @@  discard block
 block discarded – undo
61 61
 
62 62
         $targets = [];
63 63
 
64
-        foreach ($prototyped as $class) {
64
+        foreach ($prototyped as $class){
65 65
             $proto = $this->getPrototypeProperties($class, $prototyped);
66
-            if (empty($proto)) {
66
+            if (empty($proto)){
67 67
                 $modified = $this->modify($class, $proto);
68
-                if ($modified !== null) {
68
+                if ($modified !== null){
69 69
                     $targets[] = $modified;
70 70
                 }
71 71
                 continue;
72 72
             }
73 73
 
74
-            foreach ($proto as $target) {
75
-                if ($target instanceof Throwable) {
74
+            foreach ($proto as $target){
75
+                if ($target instanceof Throwable){
76 76
                     $targets[] = [
77 77
                         $class->getName(),
78 78
                         $target->getMessage(),
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
                     continue 2;
82 82
                 }
83 83
 
84
-                if ($target === null) {
84
+                if ($target === null){
85 85
                     continue 2;
86 86
                 }
87 87
             }
@@ -89,14 +89,14 @@  discard block
 block discarded – undo
89 89
             $targets[] = [$class->getName(), $this->mergeNames($proto), $this->mergeTargets($proto)];
90 90
 
91 91
             $modified = $this->modify($class, $proto);
92
-            if ($modified !== null) {
92
+            if ($modified !== null){
93 93
                 $targets[] = $modified;
94 94
             }
95 95
         }
96 96
 
97
-        if (!empty($targets)) {
97
+        if (!empty($targets)){
98 98
             $grid = $this->table(['Class:', 'Property:', 'Target:']);
99
-            foreach ($targets as $target) {
99
+            foreach ($targets as $target){
100 100
                 $grid->addRow($target);
101 101
             }
102 102
 
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
     private function modify(ReflectionClass $class, array $proto): ?array
108 108
     {
109 109
         $classDefinition = $this->extractor->extract($class->getFilename(), $proto);
110
-        try {
110
+        try{
111 111
             $modified = $this->injector->injectDependencies(
112 112
                 file_get_contents($class->getFileName()),
113 113
                 $classDefinition,
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 
119 119
             file_put_contents($class->getFileName(), $modified);
120 120
             return null;
121
-        } catch (Throwable $e) {
121
+        }catch (Throwable $e){
122 122
             return [$class->getName(), $e->getMessage(), "{$e->getFile()}:L{$e->getLine()}"];
123 123
         }
124 124
     }
Please login to merge, or discard this patch.
Braces   +25 added lines, -12 removed lines patch added patch discarded remove patch
@@ -53,7 +53,8 @@  discard block
 block discarded – undo
53 53
     public function perform(): void
54 54
     {
55 55
         $prototyped = $this->locator->getTargetClasses();
56
-        if ($prototyped === []) {
56
+        if ($prototyped === [])
57
+        {
57 58
             $this->writeln('<comment>No prototyped classes found.</comment>');
58 59
 
59 60
             return;
@@ -61,18 +62,23 @@  discard block
 block discarded – undo
61 62
 
62 63
         $targets = [];
63 64
 
64
-        foreach ($prototyped as $class) {
65
+        foreach ($prototyped as $class)
66
+        {
65 67
             $proto = $this->getPrototypeProperties($class, $prototyped);
66
-            if (empty($proto)) {
68
+            if (empty($proto))
69
+            {
67 70
                 $modified = $this->modify($class, $proto);
68
-                if ($modified !== null) {
71
+                if ($modified !== null)
72
+                {
69 73
                     $targets[] = $modified;
70 74
                 }
71 75
                 continue;
72 76
             }
73 77
 
74
-            foreach ($proto as $target) {
75
-                if ($target instanceof Throwable) {
78
+            foreach ($proto as $target)
79
+            {
80
+                if ($target instanceof Throwable)
81
+                {
76 82
                     $targets[] = [
77 83
                         $class->getName(),
78 84
                         $target->getMessage(),
@@ -81,7 +87,8 @@  discard block
 block discarded – undo
81 87
                     continue 2;
82 88
                 }
83 89
 
84
-                if ($target === null) {
90
+                if ($target === null)
91
+                {
85 92
                     continue 2;
86 93
                 }
87 94
             }
@@ -89,14 +96,17 @@  discard block
 block discarded – undo
89 96
             $targets[] = [$class->getName(), $this->mergeNames($proto), $this->mergeTargets($proto)];
90 97
 
91 98
             $modified = $this->modify($class, $proto);
92
-            if ($modified !== null) {
99
+            if ($modified !== null)
100
+            {
93 101
                 $targets[] = $modified;
94 102
             }
95 103
         }
96 104
 
97
-        if (!empty($targets)) {
105
+        if (!empty($targets))
106
+        {
98 107
             $grid = $this->table(['Class:', 'Property:', 'Target:']);
99
-            foreach ($targets as $target) {
108
+            foreach ($targets as $target)
109
+            {
100 110
                 $grid->addRow($target);
101 111
             }
102 112
 
@@ -107,7 +117,8 @@  discard block
 block discarded – undo
107 117
     private function modify(ReflectionClass $class, array $proto): ?array
108 118
     {
109 119
         $classDefinition = $this->extractor->extract($class->getFilename(), $proto);
110
-        try {
120
+        try
121
+        {
111 122
             $modified = $this->injector->injectDependencies(
112 123
                 file_get_contents($class->getFileName()),
113 124
                 $classDefinition,
@@ -118,7 +129,9 @@  discard block
 block discarded – undo
118 129
 
119 130
             file_put_contents($class->getFileName(), $modified);
120 131
             return null;
121
-        } catch (Throwable $e) {
132
+        }
133
+        catch (Throwable $e)
134
+        {
122 135
             return [$class->getName(), $e->getMessage(), "{$e->getFile()}:L{$e->getLine()}"];
123 136
         }
124 137
     }
Please login to merge, or discard this patch.
src/Prototype/src/Command/AbstractCommand.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
         $results = [$this->readProperties($class)];
55 55
 
56 56
         $parent = $class->getParentClass();
57
-        while ($parent instanceof ReflectionClass && isset($all[$parent->getName()])) {
57
+        while ($parent instanceof ReflectionClass && isset($all[$parent->getName()])){
58 58
             $results[] = $this->readProperties($parent);
59 59
             $parent = $parent->getParentClass();
60 60
         }
@@ -82,8 +82,8 @@  discard block
 block discarded – undo
82 82
     {
83 83
         $result = [];
84 84
 
85
-        foreach ($properties as $target) {
86
-            if ($target instanceof Throwable) {
85
+        foreach ($properties as $target){
86
+            if ($target instanceof Throwable){
87 87
                 $result[] = sprintf(
88 88
                     '<fg=red>%s [f: %s, l: %s]</fg=red>',
89 89
                     $target->getMessage(),
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
                 continue;
94 94
             }
95 95
 
96
-            if ($target === null) {
96
+            if ($target === null){
97 97
                 $result[] = '<fg=yellow>undefined</fg=yellow>';
98 98
                 continue;
99 99
             }
@@ -109,16 +109,16 @@  discard block
 block discarded – undo
109 109
      */
110 110
     private function readProperties(ReflectionClass $class): array
111 111
     {
112
-        if (isset($this->cache[$class->getFileName()])) {
112
+        if (isset($this->cache[$class->getFileName()])){
113 113
             $proto = $this->cache[$class->getFileName()];
114
-        } else {
114
+        }else{
115 115
             $proto = $this->getExtractor()->getPrototypeProperties(file_get_contents($class->getFilename()));
116 116
             $this->cache[$class->getFileName()] = $proto;
117 117
         }
118 118
 
119 119
         $result = [];
120
-        foreach ($proto as $name) {
121
-            if (!isset($result[$name])) {
120
+        foreach ($proto as $name){
121
+            if (!isset($result[$name])){
122 122
                 $result[$name] = $this->registry->resolveProperty($name);
123 123
             }
124 124
         }
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
      */
134 134
     private function reverse(array $results): Generator
135 135
     {
136
-        foreach (\array_reverse($results) as $result) {
136
+        foreach (\array_reverse($results) as $result){
137 137
             yield from $result;
138 138
         }
139 139
     }
Please login to merge, or discard this patch.
Braces   +19 added lines, -9 removed lines patch added patch discarded remove patch
@@ -54,7 +54,8 @@  discard block
 block discarded – undo
54 54
         $results = [$this->readProperties($class)];
55 55
 
56 56
         $parent = $class->getParentClass();
57
-        while ($parent instanceof ReflectionClass && isset($all[$parent->getName()])) {
57
+        while ($parent instanceof ReflectionClass && isset($all[$parent->getName()]))
58
+        {
58 59
             $results[] = $this->readProperties($parent);
59 60
             $parent = $parent->getParentClass();
60 61
         }
@@ -82,8 +83,10 @@  discard block
 block discarded – undo
82 83
     {
83 84
         $result = [];
84 85
 
85
-        foreach ($properties as $target) {
86
-            if ($target instanceof Throwable) {
86
+        foreach ($properties as $target)
87
+        {
88
+            if ($target instanceof Throwable)
89
+            {
87 90
                 $result[] = sprintf(
88 91
                     '<fg=red>%s [f: %s, l: %s]</fg=red>',
89 92
                     $target->getMessage(),
@@ -93,7 +96,8 @@  discard block
 block discarded – undo
93 96
                 continue;
94 97
             }
95 98
 
96
-            if ($target === null) {
99
+            if ($target === null)
100
+            {
97 101
                 $result[] = '<fg=yellow>undefined</fg=yellow>';
98 102
                 continue;
99 103
             }
@@ -109,16 +113,21 @@  discard block
 block discarded – undo
109 113
      */
110 114
     private function readProperties(ReflectionClass $class): array
111 115
     {
112
-        if (isset($this->cache[$class->getFileName()])) {
116
+        if (isset($this->cache[$class->getFileName()]))
117
+        {
113 118
             $proto = $this->cache[$class->getFileName()];
114
-        } else {
119
+        }
120
+        else
121
+        {
115 122
             $proto = $this->getExtractor()->getPrototypeProperties(file_get_contents($class->getFilename()));
116 123
             $this->cache[$class->getFileName()] = $proto;
117 124
         }
118 125
 
119 126
         $result = [];
120
-        foreach ($proto as $name) {
121
-            if (!isset($result[$name])) {
127
+        foreach ($proto as $name)
128
+        {
129
+            if (!isset($result[$name]))
130
+            {
122 131
                 $result[$name] = $this->registry->resolveProperty($name);
123 132
             }
124 133
         }
@@ -133,7 +142,8 @@  discard block
 block discarded – undo
133 142
      */
134 143
     private function reverse(array $results): Generator
135 144
     {
136
-        foreach (\array_reverse($results) as $result) {
145
+        foreach (\array_reverse($results) as $result)
146
+        {
137 147
             yield from $result;
138 148
         }
139 149
     }
Please login to merge, or discard this patch.
src/Prototype/src/Command/DumpCommand.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
         $prototypeBootloader->initAnnotations($this->container, true);
38 38
 
39 39
         $dependencies = $this->registry->getPropertyBindings();
40
-        if ($dependencies === []) {
40
+        if ($dependencies === []){
41 41
             $this->writeln('<comment>No prototyped shortcuts found.</comment>');
42 42
             return;
43 43
         }
@@ -46,14 +46,14 @@  discard block
 block discarded – undo
46 46
 
47 47
         $trait = new ReflectionClass(PrototypeTrait::class);
48 48
         $docComment = $trait->getDocComment();
49
-        if ($docComment === false) {
49
+        if ($docComment === false){
50 50
             $this->write('<fg=reg>DOCComment is missing</fg=red>');
51 51
             return;
52 52
         }
53 53
 
54 54
         $filename = $trait->getFileName();
55 55
 
56
-        try {
56
+        try{
57 57
             file_put_contents(
58 58
                 $filename,
59 59
                 str_replace(
@@ -62,17 +62,17 @@  discard block
 block discarded – undo
62 62
                     file_get_contents($filename)
63 63
                 )
64 64
             );
65
-        } catch (Throwable $e) {
66
-            $this->write('<fg=red>' . $e->getMessage() . "</fg=red>\n");
65
+        }catch (Throwable $e){
66
+            $this->write('<fg=red>'.$e->getMessage()."</fg=red>\n");
67 67
             return;
68 68
         }
69 69
 
70 70
         $this->write("<fg=green>complete</fg=green>\n");
71 71
 
72
-        if ($this->isVerbose()) {
72
+        if ($this->isVerbose()){
73 73
             $grid = $this->table(['Property:', 'Target:']);
74 74
 
75
-            foreach ($dependencies as $dependency) {
75
+            foreach ($dependencies as $dependency){
76 76
                 $grid->addRow([$dependency->var, $dependency->type->fullName]);
77 77
             }
78 78
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
         );
89 89
         $an->lines[] = new Line('');
90 90
 
91
-        foreach ($dependencies as $dependency) {
91
+        foreach ($dependencies as $dependency){
92 92
             $an->lines[] = new Line(
93 93
                 sprintf('\\%s $%s', $dependency->type->fullName, $dependency->var),
94 94
                 'property'
Please login to merge, or discard this patch.
Braces   +15 added lines, -7 removed lines patch added patch discarded remove patch
@@ -37,7 +37,8 @@  discard block
 block discarded – undo
37 37
         $prototypeBootloader->initAnnotations($this->container, true);
38 38
 
39 39
         $dependencies = $this->registry->getPropertyBindings();
40
-        if ($dependencies === []) {
40
+        if ($dependencies === [])
41
+        {
41 42
             $this->writeln('<comment>No prototyped shortcuts found.</comment>');
42 43
             return;
43 44
         }
@@ -46,14 +47,16 @@  discard block
 block discarded – undo
46 47
 
47 48
         $trait = new ReflectionClass(PrototypeTrait::class);
48 49
         $docComment = $trait->getDocComment();
49
-        if ($docComment === false) {
50
+        if ($docComment === false)
51
+        {
50 52
             $this->write('<fg=reg>DOCComment is missing</fg=red>');
51 53
             return;
52 54
         }
53 55
 
54 56
         $filename = $trait->getFileName();
55 57
 
56
-        try {
58
+        try
59
+        {
57 60
             file_put_contents(
58 61
                 $filename,
59 62
                 str_replace(
@@ -62,17 +65,21 @@  discard block
 block discarded – undo
62 65
                     file_get_contents($filename)
63 66
                 )
64 67
             );
65
-        } catch (Throwable $e) {
68
+        }
69
+        catch (Throwable $e)
70
+        {
66 71
             $this->write('<fg=red>' . $e->getMessage() . "</fg=red>\n");
67 72
             return;
68 73
         }
69 74
 
70 75
         $this->write("<fg=green>complete</fg=green>\n");
71 76
 
72
-        if ($this->isVerbose()) {
77
+        if ($this->isVerbose())
78
+        {
73 79
             $grid = $this->table(['Property:', 'Target:']);
74 80
 
75
-            foreach ($dependencies as $dependency) {
81
+            foreach ($dependencies as $dependency)
82
+            {
76 83
                 $grid->addRow([$dependency->var, $dependency->type->fullName]);
77 84
             }
78 85
 
@@ -88,7 +95,8 @@  discard block
 block discarded – undo
88 95
         );
89 96
         $an->lines[] = new Line('');
90 97
 
91
-        foreach ($dependencies as $dependency) {
98
+        foreach ($dependencies as $dependency)
99
+        {
92 100
             $an->lines[] = new Line(
93 101
                 sprintf('\\%s $%s', $dependency->type->fullName, $dependency->var),
94 102
                 'property'
Please login to merge, or discard this patch.