Passed
Push — master ( 9f2c4f...e942df )
by Aleksei
17:57 queued 05:15
created
src/Prototype/src/NodeVisitors/AddUse.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -20,21 +20,21 @@  discard block
 block discarded – undo
20 20
 
21 21
     public function __construct(
22 22
         private readonly ClassNode $node
23
-    ) {
23
+    ){
24 24
     }
25 25
 
26 26
     public function leaveNode(Node $node): ?Node
27 27
     {
28
-        if (!$node instanceof Node\Stmt\Namespace_) {
28
+        if (!$node instanceof Node\Stmt\Namespace_){
29 29
             return null;
30 30
         }
31 31
 
32 32
         $imported = [];
33
-        if (!$this->node->hasConstructor && $this->node->constructorParams) {
34
-            foreach ($this->node->constructorParams as $param) {
35
-                if (!empty($param->type) && $param->type->fullName) {
33
+        if (!$this->node->hasConstructor && $this->node->constructorParams){
34
+            foreach ($this->node->constructorParams as $param){
35
+                if (!empty($param->type) && $param->type->fullName){
36 36
                     $import = [$param->type->fullName, $param->type->alias];
37
-                    if (\in_array($import, $imported, true)) {
37
+                    if (\in_array($import, $imported, true)){
38 38
                         continue;
39 39
                     }
40 40
 
@@ -44,9 +44,9 @@  discard block
 block discarded – undo
44 44
             }
45 45
         }
46 46
 
47
-        foreach ($this->node->dependencies as $dependency) {
47
+        foreach ($this->node->dependencies as $dependency){
48 48
             $import = [$dependency->type->fullName, $dependency->type->alias];
49
-            if (\in_array($import, $imported, true)) {
49
+            if (\in_array($import, $imported, true)){
50 50
                 continue;
51 51
             }
52 52
 
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
 
70 70
     private function definePlacementID(Node\Stmt\Namespace_ $node): int
71 71
     {
72
-        foreach ($node->stmts as $index => $child) {
73
-            if ($child instanceof Node\Stmt\Class_) {
72
+        foreach ($node->stmts as $index => $child){
73
+            if ($child instanceof Node\Stmt\Class_){
74 74
                 return $index;
75 75
             }
76 76
         }
@@ -87,13 +87,13 @@  discard block
 block discarded – undo
87 87
     {
88 88
         $uses = $this->getExistingUseParts($stmts);
89 89
 
90
-        foreach ($nodes as $i => $node) {
91
-            if (!$node instanceof Node\Stmt\Use_) {
90
+        foreach ($nodes as $i => $node){
91
+            if (!$node instanceof Node\Stmt\Use_){
92 92
                 continue;
93 93
             }
94 94
 
95
-            foreach ($node->uses as $use) {
96
-                if (\in_array($use->name->parts, $uses, true)) {
95
+            foreach ($node->uses as $use){
96
+                if (\in_array($use->name->parts, $uses, true)){
97 97
                     unset($nodes[$i]);
98 98
                 }
99 99
             }
@@ -112,12 +112,12 @@  discard block
 block discarded – undo
112 112
     private function getExistingUseParts(array $stmts): array
113 113
     {
114 114
         $uses = [];
115
-        foreach ($stmts as $stmt) {
116
-            if (!$stmt instanceof Node\Stmt\Use_) {
115
+        foreach ($stmts as $stmt){
116
+            if (!$stmt instanceof Node\Stmt\Use_){
117 117
                 continue;
118 118
             }
119 119
 
120
-            foreach ($stmt->uses as $use) {
120
+            foreach ($stmt->uses as $use){
121 121
                 $uses[] = $use->name->parts;
122 122
             }
123 123
         }
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
     private function buildUse(string $type, ?string $alias = null): Node\Stmt\Use_
129 129
     {
130 130
         $b = new Use_(new Node\Name($type), Node\Stmt\Use_::TYPE_NORMAL);
131
-        if (!empty($alias)) {
131
+        if (!empty($alias)){
132 132
             $b->as($alias);
133 133
         }
134 134
 
Please login to merge, or discard this patch.
Braces   +34 added lines, -17 removed lines patch added patch discarded remove patch
@@ -25,16 +25,21 @@  discard block
 block discarded – undo
25 25
 
26 26
     public function leaveNode(Node $node): ?Node
27 27
     {
28
-        if (!$node instanceof Node\Stmt\Namespace_) {
28
+        if (!$node instanceof Node\Stmt\Namespace_)
29
+        {
29 30
             return null;
30 31
         }
31 32
 
32 33
         $imported = [];
33
-        if (!$this->node->hasConstructor && $this->node->constructorParams) {
34
-            foreach ($this->node->constructorParams as $param) {
35
-                if (!empty($param->type) && $param->type->fullName) {
34
+        if (!$this->node->hasConstructor && $this->node->constructorParams)
35
+        {
36
+            foreach ($this->node->constructorParams as $param)
37
+            {
38
+                if (!empty($param->type) && $param->type->fullName)
39
+                {
36 40
                     $import = [$param->type->fullName, $param->type->alias];
37
-                    if (\in_array($import, $imported, true)) {
41
+                    if (\in_array($import, $imported, true))
42
+                    {
38 43
                         continue;
39 44
                     }
40 45
 
@@ -44,9 +49,11 @@  discard block
 block discarded – undo
44 49
             }
45 50
         }
46 51
 
47
-        foreach ($this->node->dependencies as $dependency) {
52
+        foreach ($this->node->dependencies as $dependency)
53
+        {
48 54
             $import = [$dependency->type->fullName, $dependency->type->alias];
49
-            if (\in_array($import, $imported, true)) {
55
+            if (\in_array($import, $imported, true))
56
+            {
50 57
                 continue;
51 58
             }
52 59
 
@@ -69,8 +76,10 @@  discard block
 block discarded – undo
69 76
 
70 77
     private function definePlacementID(Node\Stmt\Namespace_ $node): int
71 78
     {
72
-        foreach ($node->stmts as $index => $child) {
73
-            if ($child instanceof Node\Stmt\Class_) {
79
+        foreach ($node->stmts as $index => $child)
80
+        {
81
+            if ($child instanceof Node\Stmt\Class_)
82
+            {
74 83
                 return $index;
75 84
             }
76 85
         }
@@ -87,13 +96,17 @@  discard block
 block discarded – undo
87 96
     {
88 97
         $uses = $this->getExistingUseParts($stmts);
89 98
 
90
-        foreach ($nodes as $i => $node) {
91
-            if (!$node instanceof Node\Stmt\Use_) {
99
+        foreach ($nodes as $i => $node)
100
+        {
101
+            if (!$node instanceof Node\Stmt\Use_)
102
+            {
92 103
                 continue;
93 104
             }
94 105
 
95
-            foreach ($node->uses as $use) {
96
-                if (\in_array($use->name->parts, $uses, true)) {
106
+            foreach ($node->uses as $use)
107
+            {
108
+                if (\in_array($use->name->parts, $uses, true))
109
+                {
97 110
                     unset($nodes[$i]);
98 111
                 }
99 112
             }
@@ -112,12 +125,15 @@  discard block
 block discarded – undo
112 125
     private function getExistingUseParts(array $stmts): array
113 126
     {
114 127
         $uses = [];
115
-        foreach ($stmts as $stmt) {
116
-            if (!$stmt instanceof Node\Stmt\Use_) {
128
+        foreach ($stmts as $stmt)
129
+        {
130
+            if (!$stmt instanceof Node\Stmt\Use_)
131
+            {
117 132
                 continue;
118 133
             }
119 134
 
120
-            foreach ($stmt->uses as $use) {
135
+            foreach ($stmt->uses as $use)
136
+            {
121 137
                 $uses[] = $use->name->parts;
122 138
             }
123 139
         }
@@ -128,7 +144,8 @@  discard block
 block discarded – undo
128 144
     private function buildUse(string $type, ?string $alias = null): Node\Stmt\Use_
129 145
     {
130 146
         $b = new Use_(new Node\Name($type), Node\Stmt\Use_::TYPE_NORMAL);
131
-        if (!empty($alias)) {
147
+        if (!empty($alias))
148
+        {
132 149
             $b->as($alias);
133 150
         }
134 151
 
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
@@ -16,15 +16,15 @@
 block discarded – undo
16 16
 {
17 17
     public function leaveNode(Node $node): ?Node
18 18
     {
19
-        if (!$node instanceof Node\Stmt\Class_) {
19
+        if (!$node instanceof Node\Stmt\Class_){
20 20
             return null;
21 21
         }
22 22
 
23 23
         $placementID = 0;
24
-        foreach ($node->stmts as $index => $child) {
24
+        foreach ($node->stmts as $index => $child){
25 25
             $placementID = $index;
26
-            if ($child instanceof Node\Stmt\ClassMethod) {
27
-                if ($child->name->name === '__construct') {
26
+            if ($child instanceof Node\Stmt\ClassMethod){
27
+                if ($child->name->name === '__construct'){
28 28
                     $node->setAttribute('constructor', $child);
29 29
 
30 30
                     return null;
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -16,15 +16,19 @@
 block discarded – undo
16 16
 {
17 17
     public function leaveNode(Node $node): ?Node
18 18
     {
19
-        if (!$node instanceof Node\Stmt\Class_) {
19
+        if (!$node instanceof Node\Stmt\Class_)
20
+        {
20 21
             return null;
21 22
         }
22 23
 
23 24
         $placementID = 0;
24
-        foreach ($node->stmts as $index => $child) {
25
+        foreach ($node->stmts as $index => $child)
26
+        {
25 27
             $placementID = $index;
26
-            if ($child instanceof Node\Stmt\ClassMethod) {
27
-                if ($child->name->name === '__construct') {
28
+            if ($child instanceof Node\Stmt\ClassMethod)
29
+            {
30
+                if ($child->name->name === '__construct')
31
+                {
28 32
                     $node->setAttribute('constructor', $child);
29 33
 
30 34
                     return null;
Please login to merge, or discard this patch.
src/Prototype/src/NodeVisitors/ClassNode/LocateVariables.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -12,18 +12,18 @@
 block discarded – undo
12 12
 {
13 13
     private array $vars = [];
14 14
 
15
-    public function enterNode(Node $node): int|Node\Stmt\ClassMethod|null
15
+    public function enterNode(Node $node): int | Node\Stmt\ClassMethod | null
16 16
     {
17
-        if ($node instanceof Node\Stmt\Class_) {
18
-            foreach ($node->stmts as $stmt) {
19
-                if ($stmt instanceof Node\Stmt\ClassMethod && $stmt->name === '__construct') {
17
+        if ($node instanceof Node\Stmt\Class_){
18
+            foreach ($node->stmts as $stmt){
19
+                if ($stmt instanceof Node\Stmt\ClassMethod && $stmt->name === '__construct'){
20 20
                     return $stmt;
21 21
                 }
22 22
             }
23 23
             return NodeTraverser::DONT_TRAVERSE_CHILDREN;
24 24
         }
25 25
 
26
-        if ($node instanceof Node\Expr\Variable) {
26
+        if ($node instanceof Node\Expr\Variable){
27 27
             $this->vars[] = $node->name;
28 28
         }
29 29
 
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -14,16 +14,20 @@
 block discarded – undo
14 14
 
15 15
     public function enterNode(Node $node): int|Node\Stmt\ClassMethod|null
16 16
     {
17
-        if ($node instanceof Node\Stmt\Class_) {
18
-            foreach ($node->stmts as $stmt) {
19
-                if ($stmt instanceof Node\Stmt\ClassMethod && $stmt->name === '__construct') {
17
+        if ($node instanceof Node\Stmt\Class_)
18
+        {
19
+            foreach ($node->stmts as $stmt)
20
+            {
21
+                if ($stmt instanceof Node\Stmt\ClassMethod && $stmt->name === '__construct')
22
+                {
20 23
                     return $stmt;
21 24
                 }
22 25
             }
23 26
             return NodeTraverser::DONT_TRAVERSE_CHILDREN;
24 27
         }
25 28
 
26
-        if ($node instanceof Node\Expr\Variable) {
29
+        if ($node instanceof Node\Expr\Variable)
30
+        {
27 31
             $this->vars[] = $node->name;
28 32
         }
29 33
 
Please login to merge, or discard this patch.
src/Prototype/src/NodeVisitors/ClassNode/LocateStatements.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@
 block discarded – undo
16 16
 
17 17
     public function enterNode(Node $node): void
18 18
     {
19
-        if ($node instanceof Node\Stmt\Use_) {
20
-            foreach ($node->uses as $use) {
19
+        if ($node instanceof Node\Stmt\Use_){
20
+            foreach ($node->uses as $use){
21 21
                 $this->imports[] = [
22 22
                     'name'  => \implode('\\', $use->name->parts),
23 23
                     'alias' => $use->alias->name ?? null,
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,8 +16,10 @@
 block discarded – undo
16 16
 
17 17
     public function enterNode(Node $node): void
18 18
     {
19
-        if ($node instanceof Node\Stmt\Use_) {
20
-            foreach ($node->uses as $use) {
19
+        if ($node instanceof Node\Stmt\Use_)
20
+        {
21
+            foreach ($node->uses as $use)
22
+            {
21 23
                 $this->imports[] = [
22 24
                     'name'  => \implode('\\', $use->name->parts),
23 25
                     'alias' => $use->alias->name ?? null,
Please login to merge, or discard this patch.
src/Prototype/src/NodeVisitors/ClassNode/DeclareClass.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@
 block discarded – undo
15 15
 
16 16
     public function enterNode(Node $node): ?int
17 17
     {
18
-        if ($node instanceof Node\Stmt\Namespace_) {
18
+        if ($node instanceof Node\Stmt\Namespace_){
19 19
             $this->namespace = \implode('\\', $node->name->parts);
20 20
         }
21 21
 
22
-        if ($node instanceof Node\Stmt\Class_) {
22
+        if ($node instanceof Node\Stmt\Class_){
23 23
             $this->class = $node->name->name;
24 24
 
25 25
             return NodeTraverser::STOP_TRAVERSAL;
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,11 +15,13 @@
 block discarded – undo
15 15
 
16 16
     public function enterNode(Node $node): ?int
17 17
     {
18
-        if ($node instanceof Node\Stmt\Namespace_) {
18
+        if ($node instanceof Node\Stmt\Namespace_)
19
+        {
19 20
             $this->namespace = \implode('\\', $node->name->parts);
20 21
         }
21 22
 
22
-        if ($node instanceof Node\Stmt\Class_) {
23
+        if ($node instanceof Node\Stmt\Class_)
24
+        {
23 25
             $this->class = $node->name->name;
24 26
 
25 27
             return NodeTraverser::STOP_TRAVERSAL;
Please login to merge, or discard this patch.
src/Prototype/src/NodeVisitors/RemoveTrait.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -15,28 +15,28 @@
 block discarded – undo
15 15
  */
16 16
 final class RemoveTrait extends NodeVisitorAbstract
17 17
 {
18
-    public function leaveNode(Node $node): int|Node|null
18
+    public function leaveNode(Node $node): int | Node | null
19 19
     {
20
-        if (!$node instanceof Node\Stmt\TraitUse) {
20
+        if (!$node instanceof Node\Stmt\TraitUse){
21 21
             return null;
22 22
         }
23 23
 
24
-        foreach ($node->traits as $index => $use) {
25
-            if ($use instanceof Node\Name) {
24
+        foreach ($node->traits as $index => $use){
25
+            if ($use instanceof Node\Name){
26 26
                 $name = $this->trimSlashes(\implode('\\', $use->parts));
27 27
                 if (
28 28
                     \in_array($name, [
29 29
                         $this->trimSlashes(PrototypeTrait::class),
30 30
                         Utils::shortName(PrototypeTrait::class),
31 31
                     ], true)
32
-                ) {
32
+                ){
33 33
                     unset($node->traits[$index]);
34 34
                 }
35 35
             }
36 36
         }
37 37
 
38 38
         $node->traits = \array_values($node->traits);
39
-        if (empty($node->traits)) {
39
+        if (empty($node->traits)){
40 40
             return NodeTraverser::REMOVE_NODE;
41 41
         }
42 42
 
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -17,12 +17,15 @@  discard block
 block discarded – undo
17 17
 {
18 18
     public function leaveNode(Node $node): int|Node|null
19 19
     {
20
-        if (!$node instanceof Node\Stmt\TraitUse) {
20
+        if (!$node instanceof Node\Stmt\TraitUse)
21
+        {
21 22
             return null;
22 23
         }
23 24
 
24
-        foreach ($node->traits as $index => $use) {
25
-            if ($use instanceof Node\Name) {
25
+        foreach ($node->traits as $index => $use)
26
+        {
27
+            if ($use instanceof Node\Name)
28
+            {
26 29
                 $name = $this->trimSlashes(\implode('\\', $use->parts));
27 30
                 if (
28 31
                     \in_array($name, [
@@ -36,7 +39,8 @@  discard block
 block discarded – undo
36 39
         }
37 40
 
38 41
         $node->traits = \array_values($node->traits);
39
-        if (empty($node->traits)) {
42
+        if (empty($node->traits))
43
+        {
40 44
             return NodeTraverser::REMOVE_NODE;
41 45
         }
42 46
 
Please login to merge, or discard this patch.
src/Prototype/src/NodeVisitors/RemoveUse.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -14,19 +14,19 @@
 block discarded – undo
14 14
  */
15 15
 final class RemoveUse extends NodeVisitorAbstract
16 16
 {
17
-    public function leaveNode(Node $node): int|Node|null
17
+    public function leaveNode(Node $node): int | Node | null
18 18
     {
19
-        if (!$node instanceof Node\Stmt\Use_) {
19
+        if (!$node instanceof Node\Stmt\Use_){
20 20
             return null;
21 21
         }
22 22
 
23
-        foreach ($node->uses as $index => $use) {
24
-            if ($use->name->toString() === PrototypeTrait::class) {
23
+        foreach ($node->uses as $index => $use){
24
+            if ($use->name->toString() === PrototypeTrait::class){
25 25
                 unset($node->uses[$index]);
26 26
             }
27 27
         }
28 28
 
29
-        if (empty($node->uses)) {
29
+        if (empty($node->uses)){
30 30
             return NodeTraverser::REMOVE_NODE;
31 31
         }
32 32
 
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -16,17 +16,21 @@
 block discarded – undo
16 16
 {
17 17
     public function leaveNode(Node $node): int|Node|null
18 18
     {
19
-        if (!$node instanceof Node\Stmt\Use_) {
19
+        if (!$node instanceof Node\Stmt\Use_)
20
+        {
20 21
             return null;
21 22
         }
22 23
 
23
-        foreach ($node->uses as $index => $use) {
24
-            if ($use->name->toString() === PrototypeTrait::class) {
24
+        foreach ($node->uses as $index => $use)
25
+        {
26
+            if ($use->name->toString() === PrototypeTrait::class)
27
+            {
25 28
                 unset($node->uses[$index]);
26 29
             }
27 30
         }
28 31
 
29
-        if (empty($node->uses)) {
32
+        if (empty($node->uses))
33
+        {
30 34
             return NodeTraverser::REMOVE_NODE;
31 35
         }
32 36
 
Please login to merge, or discard this patch.
src/Prototype/src/PrototypeRegistry.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 
19 19
     public function __construct(
20 20
         private readonly ContainerInterface $container
21
-    ) {
21
+    ){
22 22
     }
23 23
 
24 24
     /**
@@ -40,18 +40,18 @@  discard block
 block discarded – undo
40 40
     /**
41 41
      * Resolves the name of prototype dependency into target class name.
42 42
      */
43
-    public function resolveProperty(string $name): Dependency|ContainerExceptionInterface|null
43
+    public function resolveProperty(string $name): Dependency | ContainerExceptionInterface | null
44 44
     {
45 45
         $dependency = $this->dependencies[$name] ?? null;
46
-        if ($dependency === null) {
46
+        if ($dependency === null){
47 47
             return null;
48 48
         }
49 49
 
50
-        try {
50
+        try{
51 51
             $this->container->get($dependency->type->name());
52 52
 
53 53
             return $dependency;
54
-        } catch (ContainerExceptionInterface $e) {
54
+        }catch (ContainerExceptionInterface $e){
55 55
             return $e;
56 56
         }
57 57
     }
Please login to merge, or discard this patch.
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -43,15 +43,19 @@
 block discarded – undo
43 43
     public function resolveProperty(string $name): Dependency|ContainerExceptionInterface|null
44 44
     {
45 45
         $dependency = $this->dependencies[$name] ?? null;
46
-        if ($dependency === null) {
46
+        if ($dependency === null)
47
+        {
47 48
             return null;
48 49
         }
49 50
 
50
-        try {
51
+        try
52
+        {
51 53
             $this->container->get($dependency->type->name());
52 54
 
53 55
             return $dependency;
54
-        } catch (ContainerExceptionInterface $e) {
56
+        }
57
+        catch (ContainerExceptionInterface $e)
58
+        {
55 59
             return $e;
56 60
         }
57 61
     }
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
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
     public function __get(string $name): mixed
24 24
     {
25 25
         $container = ContainerScope::getContainer();
26
-        if ($container === null || !$container->has(PrototypeRegistry::class)) {
26
+        if ($container === null || !$container->has(PrototypeRegistry::class)){
27 27
             throw new ScopeException(
28 28
                 \sprintf('Unable to resolve prototyped dependency `%s`, invalid container scope', $name)
29 29
             );
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
             $target === null ||
38 38
             $target instanceof \Throwable ||
39 39
             $target->type->fullName === null
40
-        ) {
40
+        ){
41 41
             throw new PrototypeException(
42 42
                 \sprintf('Undefined prototype property `%s`', $name),
43 43
                 0,
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,8 @@
 block discarded – undo
23 23
     public function __get(string $name): mixed
24 24
     {
25 25
         $container = ContainerScope::getContainer();
26
-        if ($container === null || !$container->has(PrototypeRegistry::class)) {
26
+        if ($container === null || !$container->has(PrototypeRegistry::class))
27
+        {
27 28
             throw new ScopeException(
28 29
                 \sprintf('Unable to resolve prototyped dependency `%s`, invalid container scope', $name)
29 30
             );
Please login to merge, or discard this patch.