Passed
Pull Request — master (#1005)
by Maxim
10:03
created
src/Prototype/src/Config/PrototypeConfig.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,6 +27,6 @@
 block discarded – undo
27 27
      */
28 28
     public function getBindings(): array
29 29
     {
30
-        return (array) ($this->config['bindings'] ?? []);
30
+        return (array)($this->config['bindings'] ?? []);
31 31
     }
32 32
 }
Please login to merge, or discard this patch.
src/Prototype/src/PrototypeLocatorListener.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -23,13 +23,13 @@  discard block
 block discarded – undo
23 23
     public function __construct(
24 24
         private readonly ReaderInterface $reader,
25 25
         private readonly PrototypeBootloader $prototype
26
-    ) {
26
+    ){
27 27
     }
28 28
 
29 29
     public function listen(ReflectionClass $class): void
30 30
     {
31 31
         $attribute = $this->reader->firstClassMetadata($class, Prototyped::class);
32
-        if ($attribute === null) {
32
+        if ($attribute === null){
33 33
             return;
34 34
         }
35 35
 
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 
39 39
     public function finalize(): void
40 40
     {
41
-        foreach ($this->attributes as $property => $class) {
41
+        foreach ($this->attributes as $property => $class){
42 42
             $this->prototype->bindProperty($property, $class);
43 43
         }
44 44
     }
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,7 +29,8 @@  discard block
 block discarded – undo
29 29
     public function listen(ReflectionClass $class): void
30 30
     {
31 31
         $attribute = $this->reader->firstClassMetadata($class, Prototyped::class);
32
-        if ($attribute === null) {
32
+        if ($attribute === null)
33
+        {
33 34
             return;
34 35
         }
35 36
 
@@ -38,7 +39,8 @@  discard block
 block discarded – undo
38 39
 
39 40
     public function finalize(): void
40 41
     {
41
-        foreach ($this->attributes as $property => $class) {
42
+        foreach ($this->attributes as $property => $class)
43
+        {
42 44
             $this->prototype->bindProperty($property, $class);
43 45
         }
44 46
     }
Please login to merge, or discard this patch.
src/Prototype/src/Command/ListCommand.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
     public function perform(): int
13 13
     {
14 14
         $bindings = $this->getRegistry()->getPropertyBindings();
15
-        if ($bindings === []) {
15
+        if ($bindings === []){
16 16
             $this->comment('No prototype dependencies found.');
17 17
 
18 18
             return self::SUCCESS;
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 
21 21
         $grid = $this->table(['Name:', 'Target:']);
22 22
 
23
-        foreach ($bindings as $binding) {
23
+        foreach ($bindings as $binding){
24 24
             $grid->addRow([$binding->property, $binding->type->name()]);
25 25
         }
26 26
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@  discard block
 block discarded – undo
12 12
     public function perform(): int
13 13
     {
14 14
         $bindings = $this->getRegistry()->getPropertyBindings();
15
-        if ($bindings === []) {
15
+        if ($bindings === [])
16
+        {
16 17
             $this->comment('No prototype dependencies found.');
17 18
 
18 19
             return self::SUCCESS;
@@ -20,7 +21,8 @@  discard block
 block discarded – undo
20 21
 
21 22
         $grid = $this->table(['Name:', 'Target:']);
22 23
 
23
-        foreach ($bindings as $binding) {
24
+        foreach ($bindings as $binding)
25
+        {
24 26
             $grid->addRow([$binding->property, $binding->type->name()]);
25 27
         }
26 28
 
Please login to merge, or discard this patch.
src/Prototype/src/Command/AbstractCommand.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
     public function __construct(
20 20
         protected readonly PrototypeLocator $locator,
21 21
         protected readonly NodeExtractor $extractor
22
-    ) {
22
+    ){
23 23
         parent::__construct();
24 24
     }
25 25
 
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
         $results = [$this->readProperties($class)];
35 35
 
36 36
         $parent = $class->getParentClass();
37
-        while ($parent instanceof \ReflectionClass && isset($all[$parent->getName()])) {
37
+        while ($parent instanceof \ReflectionClass && isset($all[$parent->getName()])){
38 38
             $results[] = $this->readProperties($parent);
39 39
             $parent = $parent->getParentClass();
40 40
         }
@@ -67,8 +67,8 @@  discard block
 block discarded – undo
67 67
     {
68 68
         $result = [];
69 69
 
70
-        foreach ($properties as $target) {
71
-            if ($target instanceof Throwable) {
70
+        foreach ($properties as $target){
71
+            if ($target instanceof Throwable){
72 72
                 $result[] = \sprintf(
73 73
                     '<fg=red>%s [f: %s, l: %s]</fg=red>',
74 74
                     $target->getMessage(),
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
                 continue;
79 79
             }
80 80
 
81
-            if ($target === null) {
81
+            if ($target === null){
82 82
                 $result[] = '<fg=yellow>undefined</fg=yellow>';
83 83
                 continue;
84 84
             }
@@ -94,16 +94,16 @@  discard block
 block discarded – undo
94 94
      */
95 95
     private function readProperties(\ReflectionClass $class): array
96 96
     {
97
-        if (isset($this->cache[$class->getFileName()])) {
97
+        if (isset($this->cache[$class->getFileName()])){
98 98
             $proto = $this->cache[$class->getFileName()];
99
-        } else {
99
+        }else{
100 100
             $proto = $this->getExtractor()->getPrototypeProperties(\file_get_contents($class->getFileName()));
101 101
             $this->cache[$class->getFileName()] = $proto;
102 102
         }
103 103
 
104 104
         $result = [];
105
-        foreach ($proto as $name) {
106
-            if (!isset($result[$name])) {
105
+        foreach ($proto as $name){
106
+            if (!isset($result[$name])){
107 107
                 $result[$name] = $this->getRegistry()->resolveProperty($name);
108 108
             }
109 109
         }
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
      */
121 121
     private function reverse(array $results): \Generator
122 122
     {
123
-        foreach (\array_reverse($results) as $result) {
123
+        foreach (\array_reverse($results) as $result){
124 124
             yield from $result;
125 125
         }
126 126
     }
Please login to merge, or discard this patch.
Braces   +19 added lines, -9 removed lines patch added patch discarded remove patch
@@ -34,7 +34,8 @@  discard block
 block discarded – undo
34 34
         $results = [$this->readProperties($class)];
35 35
 
36 36
         $parent = $class->getParentClass();
37
-        while ($parent instanceof \ReflectionClass && isset($all[$parent->getName()])) {
37
+        while ($parent instanceof \ReflectionClass && isset($all[$parent->getName()]))
38
+        {
38 39
             $results[] = $this->readProperties($parent);
39 40
             $parent = $parent->getParentClass();
40 41
         }
@@ -67,8 +68,10 @@  discard block
 block discarded – undo
67 68
     {
68 69
         $result = [];
69 70
 
70
-        foreach ($properties as $target) {
71
-            if ($target instanceof Throwable) {
71
+        foreach ($properties as $target)
72
+        {
73
+            if ($target instanceof Throwable)
74
+            {
72 75
                 $result[] = \sprintf(
73 76
                     '<fg=red>%s [f: %s, l: %s]</fg=red>',
74 77
                     $target->getMessage(),
@@ -78,7 +81,8 @@  discard block
 block discarded – undo
78 81
                 continue;
79 82
             }
80 83
 
81
-            if ($target === null) {
84
+            if ($target === null)
85
+            {
82 86
                 $result[] = '<fg=yellow>undefined</fg=yellow>';
83 87
                 continue;
84 88
             }
@@ -94,16 +98,21 @@  discard block
 block discarded – undo
94 98
      */
95 99
     private function readProperties(\ReflectionClass $class): array
96 100
     {
97
-        if (isset($this->cache[$class->getFileName()])) {
101
+        if (isset($this->cache[$class->getFileName()]))
102
+        {
98 103
             $proto = $this->cache[$class->getFileName()];
99
-        } else {
104
+        }
105
+        else
106
+        {
100 107
             $proto = $this->getExtractor()->getPrototypeProperties(\file_get_contents($class->getFileName()));
101 108
             $this->cache[$class->getFileName()] = $proto;
102 109
         }
103 110
 
104 111
         $result = [];
105
-        foreach ($proto as $name) {
106
-            if (!isset($result[$name])) {
112
+        foreach ($proto as $name)
113
+        {
114
+            if (!isset($result[$name]))
115
+            {
107 116
                 $result[$name] = $this->getRegistry()->resolveProperty($name);
108 117
             }
109 118
         }
@@ -120,7 +129,8 @@  discard block
 block discarded – undo
120 129
      */
121 130
     private function reverse(array $results): \Generator
122 131
     {
123
-        foreach (\array_reverse($results) as $result) {
132
+        foreach (\array_reverse($results) as $result)
133
+        {
124 134
             yield from $result;
125 135
         }
126 136
     }
Please login to merge, or discard this patch.
src/Prototype/src/Command/InjectCommand.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
     public function perform(): int
36 36
     {
37 37
         $prototyped = $this->locator->getTargetClasses();
38
-        if ($prototyped === []) {
38
+        if ($prototyped === []){
39 39
             $this->writeln('<comment>No prototyped classes found.</comment>');
40 40
 
41 41
             return self::SUCCESS;
@@ -43,18 +43,18 @@  discard block
 block discarded – undo
43 43
 
44 44
         $targets = [];
45 45
 
46
-        foreach ($prototyped as $class) {
46
+        foreach ($prototyped as $class){
47 47
             $proto = $this->getPrototypeProperties($class, $prototyped);
48
-            if (empty($proto)) {
48
+            if (empty($proto)){
49 49
                 $modified = $this->modify($class, $proto);
50
-                if ($modified !== null) {
50
+                if ($modified !== null){
51 51
                     $targets[] = $modified;
52 52
                 }
53 53
                 continue;
54 54
             }
55 55
 
56
-            foreach ($proto as $target) {
57
-                if ($target instanceof \Throwable) {
56
+            foreach ($proto as $target){
57
+                if ($target instanceof \Throwable){
58 58
                     $targets[] = [
59 59
                         $class->getName(),
60 60
                         $target->getMessage(),
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
                     continue 2;
64 64
                 }
65 65
 
66
-                if ($target === null) {
66
+                if ($target === null){
67 67
                     continue 2;
68 68
                 }
69 69
             }
@@ -71,14 +71,14 @@  discard block
 block discarded – undo
71 71
             $targets[] = [$class->getName(), $this->mergeNames($proto), $this->mergeTargets($proto)];
72 72
 
73 73
             $modified = $this->modify($class, $proto);
74
-            if ($modified !== null) {
74
+            if ($modified !== null){
75 75
                 $targets[] = $modified;
76 76
             }
77 77
         }
78 78
 
79
-        if (!empty($targets)) {
79
+        if (!empty($targets)){
80 80
             $grid = $this->table(['Class:', 'Property:', 'Target:']);
81
-            foreach ($targets as $target) {
81
+            foreach ($targets as $target){
82 82
                 $grid->addRow($target);
83 83
             }
84 84
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
     private function modify(\ReflectionClass $class, array $proto): ?array
92 92
     {
93 93
         $classDefinition = $this->extractor->extract($class->getFileName(), $proto);
94
-        try {
94
+        try{
95 95
             $modified = $this->injector->injectDependencies(
96 96
                 \file_get_contents($class->getFileName()),
97 97
                 $classDefinition,
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
             \file_put_contents($class->getFileName(), $modified);
102 102
 
103 103
             return null;
104
-        } catch (\Throwable $e) {
104
+        }catch (\Throwable $e){
105 105
             return [$class->getName(), $e->getMessage(), \sprintf('%s:L%s', $e->getFile(), $e->getLine())];
106 106
         }
107 107
     }
Please login to merge, or discard this patch.
src/Prototype/src/Bootloader/PrototypeBootloader.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 
81 81
     public function __construct(
82 82
         private readonly ConfiguratorInterface $config
83
-    ) {
83
+    ){
84 84
     }
85 85
 
86 86
     public function init(ConsoleBootloader $console): void
@@ -124,30 +124,30 @@  discard block
 block discarded – undo
124 124
     {
125 125
         $registry = new PrototypeRegistry($container);
126 126
 
127
-        foreach ($config->getBindings() as $property => $shortcut) {
128
-            if (\is_array($shortcut) && isset($shortcut['resolve'])) {
129
-                if (isset($shortcut['with'])) {
127
+        foreach ($config->getBindings() as $property => $shortcut){
128
+            if (\is_array($shortcut) && isset($shortcut['resolve'])){
129
+                if (isset($shortcut['with'])){
130 130
                     // check dependencies
131
-                    foreach ($shortcut['with'] as $dep) {
132
-                        if (!\class_exists($dep, true) && !\interface_exists($dep, true)) {
131
+                    foreach ($shortcut['with'] as $dep){
132
+                        if (!\class_exists($dep, true) && !\interface_exists($dep, true)){
133 133
                             continue 2;
134 134
                         }
135 135
                     }
136 136
                 }
137 137
 
138
-                try {
138
+                try{
139 139
                     $target = $container->get($shortcut['resolve']);
140
-                    if (\is_object($target)) {
140
+                    if (\is_object($target)){
141 141
                         $registry->bindProperty($property, $target::class);
142 142
                     }
143
-                } catch (ContainerExceptionInterface) {
143
+                }catch (ContainerExceptionInterface){
144 144
                     continue;
145 145
                 }
146 146
 
147 147
                 continue;
148 148
             }
149 149
 
150
-            if (\is_string($shortcut) && (\class_exists($shortcut, true) || \interface_exists($shortcut, true))) {
150
+            if (\is_string($shortcut) && (\class_exists($shortcut, true) || \interface_exists($shortcut, true))){
151 151
                 $registry->bindProperty($property, $shortcut);
152 152
             }
153 153
         }
Please login to merge, or discard this patch.
Braces   +19 added lines, -9 removed lines patch added patch discarded remove patch
@@ -124,30 +124,40 @@
 block discarded – undo
124 124
     {
125 125
         $registry = new PrototypeRegistry($container);
126 126
 
127
-        foreach ($config->getBindings() as $property => $shortcut) {
128
-            if (\is_array($shortcut) && isset($shortcut['resolve'])) {
129
-                if (isset($shortcut['with'])) {
127
+        foreach ($config->getBindings() as $property => $shortcut)
128
+        {
129
+            if (\is_array($shortcut) && isset($shortcut['resolve']))
130
+            {
131
+                if (isset($shortcut['with']))
132
+                {
130 133
                     // check dependencies
131
-                    foreach ($shortcut['with'] as $dep) {
132
-                        if (!\class_exists($dep, true) && !\interface_exists($dep, true)) {
134
+                    foreach ($shortcut['with'] as $dep)
135
+                    {
136
+                        if (!\class_exists($dep, true) && !\interface_exists($dep, true))
137
+                        {
133 138
                             continue 2;
134 139
                         }
135 140
                     }
136 141
                 }
137 142
 
138
-                try {
143
+                try
144
+                {
139 145
                     $target = $container->get($shortcut['resolve']);
140
-                    if (\is_object($target)) {
146
+                    if (\is_object($target))
147
+                    {
141 148
                         $registry->bindProperty($property, $target::class);
142 149
                     }
143
-                } catch (ContainerExceptionInterface) {
150
+                }
151
+                catch (ContainerExceptionInterface)
152
+                {
144 153
                     continue;
145 154
                 }
146 155
 
147 156
                 continue;
148 157
             }
149 158
 
150
-            if (\is_string($shortcut) && (\class_exists($shortcut, true) || \interface_exists($shortcut, true))) {
159
+            if (\is_string($shortcut) && (\class_exists($shortcut, true) || \interface_exists($shortcut, true)))
160
+            {
151 161
                 $registry->bindProperty($property, $shortcut);
152 162
             }
153 163
         }
Please login to merge, or discard this patch.
src/Prototype/src/Command/DumpCommand.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
     public function perform(Writer $writer): int
24 24
     {
25 25
         $dependencies = $this->getRegistry()->getPropertyBindings();
26
-        if ($dependencies === []) {
26
+        if ($dependencies === []){
27 27
             $this->comment('No prototyped shortcuts found.');
28 28
 
29 29
             return self::SUCCESS;
@@ -35,22 +35,22 @@  discard block
 block discarded – undo
35 35
         $file = FileDeclaration::fromReflection($ref);
36 36
         $trait = $file->getTrait(PrototypeTrait::class);
37 37
 
38
-        try {
38
+        try{
39 39
             $this->buildAnnotation($trait, $dependencies);
40 40
 
41 41
             $writer->write($ref->getFileName(), $file);
42
-        } catch (\Throwable $e) {
43
-            $this->write('<fg=red>' . $e->getMessage() . "</fg=red>\n");
42
+        }catch (\Throwable $e){
43
+            $this->write('<fg=red>'.$e->getMessage()."</fg=red>\n");
44 44
 
45 45
             return self::FAILURE;
46 46
         }
47 47
 
48 48
         $this->write("<fg=green>complete</fg=green>\n");
49 49
 
50
-        if ($this->isVerbose()) {
50
+        if ($this->isVerbose()){
51 51
             $grid = $this->table(['Property:', 'Target:']);
52 52
 
53
-            foreach ($dependencies as $dependency) {
53
+            foreach ($dependencies as $dependency){
54 54
                 $grid->addRow([$dependency->var, $dependency->type->fullName]);
55 55
             }
56 56
 
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
         $trait->addComment('This DocComment is auto-generated, do not edit or commit this file to repository.');
67 67
         $trait->addComment('');
68 68
 
69
-        foreach ($dependencies as $dependency) {
69
+        foreach ($dependencies as $dependency){
70 70
             $trait->addComment(\sprintf('@property \\%s $%s', $dependency->type->fullName, $dependency->var));
71 71
         }
72 72
     }
Please login to merge, or discard this patch.
Braces   +13 added lines, -6 removed lines patch added patch discarded remove patch
@@ -23,7 +23,8 @@  discard block
 block discarded – undo
23 23
     public function perform(Writer $writer): int
24 24
     {
25 25
         $dependencies = $this->getRegistry()->getPropertyBindings();
26
-        if ($dependencies === []) {
26
+        if ($dependencies === [])
27
+        {
27 28
             $this->comment('No prototyped shortcuts found.');
28 29
 
29 30
             return self::SUCCESS;
@@ -35,11 +36,14 @@  discard block
 block discarded – undo
35 36
         $file = FileDeclaration::fromReflection($ref);
36 37
         $trait = $file->getTrait(PrototypeTrait::class);
37 38
 
38
-        try {
39
+        try
40
+        {
39 41
             $this->buildAnnotation($trait, $dependencies);
40 42
 
41 43
             $writer->write($ref->getFileName(), $file);
42
-        } catch (\Throwable $e) {
44
+        }
45
+        catch (\Throwable $e)
46
+        {
43 47
             $this->write('<fg=red>' . $e->getMessage() . "</fg=red>\n");
44 48
 
45 49
             return self::FAILURE;
@@ -47,10 +51,12 @@  discard block
 block discarded – undo
47 51
 
48 52
         $this->write("<fg=green>complete</fg=green>\n");
49 53
 
50
-        if ($this->isVerbose()) {
54
+        if ($this->isVerbose())
55
+        {
51 56
             $grid = $this->table(['Property:', 'Target:']);
52 57
 
53
-            foreach ($dependencies as $dependency) {
58
+            foreach ($dependencies as $dependency)
59
+            {
54 60
                 $grid->addRow([$dependency->var, $dependency->type->fullName]);
55 61
             }
56 62
 
@@ -66,7 +72,8 @@  discard block
 block discarded – undo
66 72
         $trait->addComment('This DocComment is auto-generated, do not edit or commit this file to repository.');
67 73
         $trait->addComment('');
68 74
 
69
-        foreach ($dependencies as $dependency) {
75
+        foreach ($dependencies as $dependency)
76
+        {
70 77
             $trait->addComment(\sprintf('@property \\%s $%s', $dependency->type->fullName, $dependency->var));
71 78
         }
72 79
     }
Please login to merge, or discard this patch.
src/Reactor/src/FileDeclaration.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -53,9 +53,9 @@
 block discarded – undo
53 53
         return self::fromElement((new Factory())->fromCode(\file_get_contents($reflection->getFileName())));
54 54
     }
55 55
 
56
-    public function addNamespace(string|PhpNamespace $namespace): PhpNamespace
56
+    public function addNamespace(string | PhpNamespace $namespace): PhpNamespace
57 57
     {
58
-        if ($namespace instanceof PhpNamespace) {
58
+        if ($namespace instanceof PhpNamespace){
59 59
             $this->element->addNamespace($namespace->getElement());
60 60
 
61 61
             return $namespace;
Please login to merge, or discard this patch.