Completed
Push — master ( 6366df...fbe022 )
by Kirill
23s queued 19s
created
src/Prototype/src/Command/DumpCommand.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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'
Please login to merge, or discard this patch.
Braces   +15 added lines, -7 removed lines patch added patch discarded remove patch
@@ -33,7 +33,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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'
Please login to merge, or discard this patch.
src/Prototype/src/NodeVisitors/LocateProperties.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -50,13 +50,13 @@
 block discarded – undo
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
             }
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -54,9 +54,12 @@
 block discarded – undo
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
             }
Please login to merge, or discard this patch.
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 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
 
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 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
 
Please login to merge, or discard this patch.
src/Prototype/src/NodeVisitors/DefineConstructor.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -27,15 +27,15 @@
 block discarded – undo
27 27
      */
28 28
     public function leaveNode(Node $node)
29 29
     {
30
-        if (!$node instanceof Node\Stmt\Class_) {
30
+        if (!$node instanceof Node\Stmt\Class_){
31 31
             return null;
32 32
         }
33 33
 
34 34
         $placementID = 0;
35
-        foreach ($node->stmts as $index => $child) {
35
+        foreach ($node->stmts as $index => $child){
36 36
             $placementID = $index;
37
-            if ($child instanceof Node\Stmt\ClassMethod) {
38
-                if ($child->name->name === '__construct') {
37
+            if ($child instanceof Node\Stmt\ClassMethod){
38
+                if ($child->name->name === '__construct'){
39 39
                     $node->setAttribute('constructor', $child);
40 40
 
41 41
                     return null;
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -27,15 +27,19 @@
 block discarded – undo
27 27
      */
28 28
     public function leaveNode(Node $node)
29 29
     {
30
-        if (!$node instanceof Node\Stmt\Class_) {
30
+        if (!$node instanceof Node\Stmt\Class_)
31
+        {
31 32
             return null;
32 33
         }
33 34
 
34 35
         $placementID = 0;
35
-        foreach ($node->stmts as $index => $child) {
36
+        foreach ($node->stmts as $index => $child)
37
+        {
36 38
             $placementID = $index;
37
-            if ($child instanceof Node\Stmt\ClassMethod) {
38
-                if ($child->name->name === '__construct') {
39
+            if ($child instanceof Node\Stmt\ClassMethod)
40
+            {
41
+                if ($child->name->name === '__construct')
42
+                {
39 43
                     $node->setAttribute('constructor', $child);
40 44
 
41 45
                     return null;
Please login to merge, or discard this patch.
src/Prototype/src/NodeVisitors/AddUse.php 2 patches
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -42,16 +42,16 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public function leaveNode(Node $node)
44 44
     {
45
-        if (!$node instanceof Node\Stmt\Namespace_) {
45
+        if (!$node instanceof Node\Stmt\Namespace_){
46 46
             return null;
47 47
         }
48 48
 
49 49
         $imported = [];
50
-        if (!$this->node->hasConstructor && $this->node->constructorParams) {
51
-            foreach ($this->node->constructorParams as $param) {
52
-                if (!empty($param->type) && $param->type->fullName) {
50
+        if (!$this->node->hasConstructor && $this->node->constructorParams){
51
+            foreach ($this->node->constructorParams as $param){
52
+                if (!empty($param->type) && $param->type->fullName){
53 53
                     $import = [$param->type->fullName, $param->type->alias];
54
-                    if (in_array($import, $imported, true)) {
54
+                    if (in_array($import, $imported, true)){
55 55
                         continue;
56 56
                     }
57 57
 
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
             }
62 62
         }
63 63
 
64
-        foreach ($this->node->dependencies as $dependency) {
64
+        foreach ($this->node->dependencies as $dependency){
65 65
             $import = [$dependency->type->fullName, $dependency->type->alias];
66
-            if (in_array($import, $imported, true)) {
66
+            if (in_array($import, $imported, true)){
67 67
                 continue;
68 68
             }
69 69
 
@@ -90,8 +90,8 @@  discard block
 block discarded – undo
90 90
      */
91 91
     private function definePlacementID(Node\Stmt\Namespace_ $node): int
92 92
     {
93
-        foreach ($node->stmts as $index => $child) {
94
-            if ($child instanceof Node\Stmt\Class_) {
93
+        foreach ($node->stmts as $index => $child){
94
+            if ($child instanceof Node\Stmt\Class_){
95 95
                 return $index;
96 96
             }
97 97
         }
@@ -108,13 +108,13 @@  discard block
 block discarded – undo
108 108
     {
109 109
         $uses = $this->getExistingUseParts($stmts);
110 110
 
111
-        foreach ($nodes as $i => $node) {
112
-            if (!$node instanceof Node\Stmt\Use_) {
111
+        foreach ($nodes as $i => $node){
112
+            if (!$node instanceof Node\Stmt\Use_){
113 113
                 continue;
114 114
             }
115 115
 
116
-            foreach ($node->uses as $use) {
117
-                if (in_array($use->name->parts, $uses, true)) {
116
+            foreach ($node->uses as $use){
117
+                if (in_array($use->name->parts, $uses, true)){
118 118
                     unset($nodes[$i]);
119 119
                 }
120 120
             }
@@ -130,12 +130,12 @@  discard block
 block discarded – undo
130 130
     private function getExistingUseParts(array $stmts): array
131 131
     {
132 132
         $uses = [];
133
-        foreach ($stmts as $stmt) {
134
-            if (!$stmt instanceof Node\Stmt\Use_) {
133
+        foreach ($stmts as $stmt){
134
+            if (!$stmt instanceof Node\Stmt\Use_){
135 135
                 continue;
136 136
             }
137 137
 
138
-            foreach ($stmt->uses as $use) {
138
+            foreach ($stmt->uses as $use){
139 139
                 $uses[] = $use->name->parts;
140 140
             }
141 141
         }
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
     private function buildUse(string $type, ?string $alias = null): Node\Stmt\Use_
152 152
     {
153 153
         $b = new Use_(new Node\Name($type), Node\Stmt\Use_::TYPE_NORMAL);
154
-        if (!empty($alias)) {
154
+        if (!empty($alias)){
155 155
             $b->as($alias);
156 156
         }
157 157
 
Please login to merge, or discard this patch.
Braces   +34 added lines, -17 removed lines patch added patch discarded remove patch
@@ -42,16 +42,21 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public function leaveNode(Node $node)
44 44
     {
45
-        if (!$node instanceof Node\Stmt\Namespace_) {
45
+        if (!$node instanceof Node\Stmt\Namespace_)
46
+        {
46 47
             return null;
47 48
         }
48 49
 
49 50
         $imported = [];
50
-        if (!$this->node->hasConstructor && $this->node->constructorParams) {
51
-            foreach ($this->node->constructorParams as $param) {
52
-                if (!empty($param->type) && $param->type->fullName) {
51
+        if (!$this->node->hasConstructor && $this->node->constructorParams)
52
+        {
53
+            foreach ($this->node->constructorParams as $param)
54
+            {
55
+                if (!empty($param->type) && $param->type->fullName)
56
+                {
53 57
                     $import = [$param->type->fullName, $param->type->alias];
54
-                    if (in_array($import, $imported, true)) {
58
+                    if (in_array($import, $imported, true))
59
+                    {
55 60
                         continue;
56 61
                     }
57 62
 
@@ -61,9 +66,11 @@  discard block
 block discarded – undo
61 66
             }
62 67
         }
63 68
 
64
-        foreach ($this->node->dependencies as $dependency) {
69
+        foreach ($this->node->dependencies as $dependency)
70
+        {
65 71
             $import = [$dependency->type->fullName, $dependency->type->alias];
66
-            if (in_array($import, $imported, true)) {
72
+            if (in_array($import, $imported, true))
73
+            {
67 74
                 continue;
68 75
             }
69 76
 
@@ -90,8 +97,10 @@  discard block
 block discarded – undo
90 97
      */
91 98
     private function definePlacementID(Node\Stmt\Namespace_ $node): int
92 99
     {
93
-        foreach ($node->stmts as $index => $child) {
94
-            if ($child instanceof Node\Stmt\Class_) {
100
+        foreach ($node->stmts as $index => $child)
101
+        {
102
+            if ($child instanceof Node\Stmt\Class_)
103
+            {
95 104
                 return $index;
96 105
             }
97 106
         }
@@ -108,13 +117,17 @@  discard block
 block discarded – undo
108 117
     {
109 118
         $uses = $this->getExistingUseParts($stmts);
110 119
 
111
-        foreach ($nodes as $i => $node) {
112
-            if (!$node instanceof Node\Stmt\Use_) {
120
+        foreach ($nodes as $i => $node)
121
+        {
122
+            if (!$node instanceof Node\Stmt\Use_)
123
+            {
113 124
                 continue;
114 125
             }
115 126
 
116
-            foreach ($node->uses as $use) {
117
-                if (in_array($use->name->parts, $uses, true)) {
127
+            foreach ($node->uses as $use)
128
+            {
129
+                if (in_array($use->name->parts, $uses, true))
130
+                {
118 131
                     unset($nodes[$i]);
119 132
                 }
120 133
             }
@@ -130,12 +143,15 @@  discard block
 block discarded – undo
130 143
     private function getExistingUseParts(array $stmts): array
131 144
     {
132 145
         $uses = [];
133
-        foreach ($stmts as $stmt) {
134
-            if (!$stmt instanceof Node\Stmt\Use_) {
146
+        foreach ($stmts as $stmt)
147
+        {
148
+            if (!$stmt instanceof Node\Stmt\Use_)
149
+            {
135 150
                 continue;
136 151
             }
137 152
 
138
-            foreach ($stmt->uses as $use) {
153
+            foreach ($stmt->uses as $use)
154
+            {
139 155
                 $uses[] = $use->name->parts;
140 156
             }
141 157
         }
@@ -151,7 +167,8 @@  discard block
 block discarded – undo
151 167
     private function buildUse(string $type, ?string $alias = null): Node\Stmt\Use_
152 168
     {
153 169
         $b = new Use_(new Node\Name($type), Node\Stmt\Use_::TYPE_NORMAL);
154
-        if (!empty($alias)) {
170
+        if (!empty($alias))
171
+        {
155 172
             $b->as($alias);
156 173
         }
157 174
 
Please login to merge, or discard this patch.
src/Prototype/src/Traits/PrototypeTrait.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
     public function __get(string $name)
34 34
     {
35 35
         $container = ContainerScope::getContainer();
36
-        if ($container === null || !$container->has(PrototypeRegistry::class)) {
36
+        if ($container === null || !$container->has(PrototypeRegistry::class)){
37 37
             throw new ScopeException(
38 38
                 "Unable to resolve prototyped dependency `{$name}`, invalid container scope"
39 39
             );
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
             $target === null ||
48 48
             $target instanceof \Throwable ||
49 49
             $target->type->fullName === null
50
-        ) {
50
+        ){
51 51
             throw new PrototypeException(
52 52
                 "Undefined prototype property `{$name}`",
53 53
                 0,
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,8 @@
 block discarded – undo
33 33
     public function __get(string $name)
34 34
     {
35 35
         $container = ContainerScope::getContainer();
36
-        if ($container === null || !$container->has(PrototypeRegistry::class)) {
36
+        if ($container === null || !$container->has(PrototypeRegistry::class))
37
+        {
37 38
             throw new ScopeException(
38 39
                 "Unable to resolve prototyped dependency `{$name}`, invalid container scope"
39 40
             );
Please login to merge, or discard this patch.
src/Prototype/src/PrototypeRegistry.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -64,15 +64,15 @@
 block discarded – undo
64 64
     public function resolveProperty(string $name)
65 65
     {
66 66
         $dependency = $this->dependencies[$name] ?? null;
67
-        if ($dependency === null) {
67
+        if ($dependency === null){
68 68
             return null;
69 69
         }
70 70
 
71
-        try {
71
+        try{
72 72
             $this->container->get($dependency->type->name());
73 73
 
74 74
             return $dependency;
75
-        } catch (ContainerExceptionInterface $e) {
75
+        }catch (ContainerExceptionInterface $e){
76 76
             return $e;
77 77
         }
78 78
     }
Please login to merge, or discard this patch.
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -64,15 +64,19 @@
 block discarded – undo
64 64
     public function resolveProperty(string $name)
65 65
     {
66 66
         $dependency = $this->dependencies[$name] ?? null;
67
-        if ($dependency === null) {
67
+        if ($dependency === null)
68
+        {
68 69
             return null;
69 70
         }
70 71
 
71
-        try {
72
+        try
73
+        {
72 74
             $this->container->get($dependency->type->name());
73 75
 
74 76
             return $dependency;
75
-        } catch (ContainerExceptionInterface $e) {
77
+        }
78
+        catch (ContainerExceptionInterface $e)
79
+        {
76 80
             return $e;
77 81
         }
78 82
     }
Please login to merge, or discard this patch.
src/Prototype/src/Utils.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
     public static function shortName(string $name): string
26 26
     {
27 27
         $pos = mb_strrpos($name, '\\');
28
-        if ($pos === false) {
28
+        if ($pos === false){
29 29
             return $name;
30 30
         }
31 31
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
     public static function trimTrailingDigits(string $name, int $number): string
59 59
     {
60 60
         $pos = mb_strripos($name, (string)$number);
61
-        if ($pos === false) {
61
+        if ($pos === false){
62 62
             return $name;
63 63
         }
64 64
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,7 +25,8 @@  discard block
 block discarded – undo
25 25
     public static function shortName(string $name): string
26 26
     {
27 27
         $pos = mb_strrpos($name, '\\');
28
-        if ($pos === false) {
28
+        if ($pos === false)
29
+        {
29 30
             return $name;
30 31
         }
31 32
 
@@ -58,7 +59,8 @@  discard block
 block discarded – undo
58 59
     public static function trimTrailingDigits(string $name, int $number): string
59 60
     {
60 61
         $pos = mb_strripos($name, (string)$number);
61
-        if ($pos === false) {
62
+        if ($pos === false)
63
+        {
62 64
             return $name;
63 65
         }
64 66
 
Please login to merge, or discard this patch.
src/Prototype/tests/Traverse/Extractor.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@
 block discarded – undo
57 57
     private function traverse(string $code, NodeVisitor ...$visitors): void
58 58
     {
59 59
         $tr = new NodeTraverser();
60
-        foreach ($visitors as $visitor) {
60
+        foreach ($visitors as $visitor){
61 61
             $tr->addVisitor($visitor);
62 62
         }
63 63
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,8 @@
 block discarded – undo
57 57
     private function traverse(string $code, NodeVisitor ...$visitors): void
58 58
     {
59 59
         $tr = new NodeTraverser();
60
-        foreach ($visitors as $visitor) {
60
+        foreach ($visitors as $visitor)
61
+        {
61 62
             $tr->addVisitor($visitor);
62 63
         }
63 64
 
Please login to merge, or discard this patch.