Passed
Pull Request — master (#840)
by Maxim
12:40 queued 05:56
created
src/Core/tests/Stub/LightEngineDecorator.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 {
9 9
     public function __construct(
10 10
         public LightEngine $engine
11
-    ) {
11
+    ){
12 12
     }
13 13
 
14 14
     public function __call(string $name, array $arguments)
Please login to merge, or discard this patch.
src/Core/tests/Stub/NewObjectInParam.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,6 +10,6 @@
 block discarded – undo
10 10
 {
11 11
     public function __construct(
12 12
         private object $object = new stdClass()
13
-    ) {
13
+    ){
14 14
     }
15 15
 }
Please login to merge, or discard this patch.
src/Core/tests/InvokerTest.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
         $this->container->bindSingleton(Bucket::class, $bucket = new Bucket('foo'));
96 96
 
97 97
         $result = $this->container->invoke(
98
-            static function (Bucket $bucket, SampleClass $class, string $name, string $path = 'baz') {
98
+            static function (Bucket $bucket, SampleClass $class, string $name, string $path = 'baz'){
99 99
                 return \compact('bucket', 'class', 'name', 'path');
100 100
             },
101 101
             ['name' => 'bar']
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
         $this->expectErrorMessage('Unable to resolve required argument `name` when resolving');
114 114
 
115 115
         $this->container->invoke(
116
-            static function (Bucket $bucket, SampleClass $class, string $name, string $path = 'baz') {
116
+            static function (Bucket $bucket, SampleClass $class, string $name, string $path = 'baz'){
117 117
                 return \compact('bucket', 'class', 'name', 'path');
118 118
             },
119 119
             ['name' => 'bar']
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -95,7 +95,8 @@  discard block
 block discarded – undo
95 95
         $this->container->bindSingleton(Bucket::class, $bucket = new Bucket('foo'));
96 96
 
97 97
         $result = $this->container->invoke(
98
-            static function (Bucket $bucket, SampleClass $class, string $name, string $path = 'baz') {
98
+            static function (Bucket $bucket, SampleClass $class, string $name, string $path = 'baz')
99
+            {
99 100
                 return \compact('bucket', 'class', 'name', 'path');
100 101
             },
101 102
             ['name' => 'bar']
@@ -113,7 +114,8 @@  discard block
 block discarded – undo
113 114
         $this->expectErrorMessage('Unable to resolve required argument `name` when resolving');
114 115
 
115 116
         $this->container->invoke(
116
-            static function (Bucket $bucket, SampleClass $class, string $name, string $path = 'baz') {
117
+            static function (Bucket $bucket, SampleClass $class, string $name, string $path = 'baz')
118
+            {
117 119
                 return \compact('bucket', 'class', 'name', 'path');
118 120
             },
119 121
             ['name' => 'bar']
Please login to merge, or discard this patch.
src/Core/src/Internal/Binder.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
      *
39 39
      * @psalm-param TResolver|object $resolver
40 40
      */
41
-    public function bind(string $alias, string|array|callable|object $resolver): void
41
+    public function bind(string $alias, string | array | callable | object $resolver): void
42 42
     {
43
-        if (\is_array($resolver) || $resolver instanceof \Closure || $resolver instanceof Autowire) {
43
+        if (\is_array($resolver) || $resolver instanceof \Closure || $resolver instanceof Autowire){
44 44
             // array means = execute me, false = not singleton
45 45
             $this->state->bindings[$alias] = [$resolver, false];
46 46
 
@@ -56,9 +56,9 @@  discard block
 block discarded – undo
56 56
      *
57 57
      * @psalm-param TResolver|object $resolver
58 58
      */
59
-    public function bindSingleton(string $alias, string|array|callable|object $resolver): void
59
+    public function bindSingleton(string $alias, string | array | callable | object $resolver): void
60 60
     {
61
-        if (\is_object($resolver) && !$resolver instanceof \Closure && !$resolver instanceof Autowire) {
61
+        if (\is_object($resolver) && !$resolver instanceof \Closure && !$resolver instanceof Autowire){
62 62
             // direct binding to an instance
63 63
             $this->state->bindings[$alias] = $resolver;
64 64
 
@@ -73,12 +73,12 @@  discard block
 block discarded – undo
73 73
      */
74 74
     public function hasInstance(string $alias): bool
75 75
     {
76
-        if (!$this->container->has($alias)) {
76
+        if (!$this->container->has($alias)){
77 77
             return false;
78 78
         }
79 79
         $bindings = &$this->state->bindings;
80 80
 
81
-        while (isset($bindings[$alias]) && \is_string($bindings[$alias])) {
81
+        while (isset($bindings[$alias]) && \is_string($bindings[$alias])){
82 82
             //Checking alias tree
83 83
             $alias = $bindings[$alias];
84 84
         }
@@ -111,31 +111,31 @@  discard block
 block discarded – undo
111 111
 
112 112
     public function hasInjector(string $class): bool
113 113
     {
114
-        try {
114
+        try{
115 115
             $reflection = new \ReflectionClass($class);
116
-        } catch (\ReflectionException $e) {
116
+        }catch (\ReflectionException $e){
117 117
             throw new ContainerException($e->getMessage(), $e->getCode(), $e);
118 118
         }
119 119
 
120
-        if (\array_key_exists($class, $this->state->injectors)) {
120
+        if (\array_key_exists($class, $this->state->injectors)){
121 121
             return $this->state->injectors[$class] !== null;
122 122
         }
123 123
 
124 124
         if (
125 125
             $reflection->implementsInterface(InjectableInterface::class)
126 126
             && $reflection->hasConstant('INJECTOR')
127
-        ) {
127
+        ){
128 128
             $this->state->injectors[$class] = $reflection->getConstant('INJECTOR');
129 129
 
130 130
             return true;
131 131
         }
132 132
 
133 133
         // check interfaces
134
-        foreach ($this->state->injectors as $target => $injector) {
134
+        foreach ($this->state->injectors as $target => $injector){
135 135
             if (
136 136
                 \class_exists($target, true)
137 137
                 && $reflection->isSubclassOf($target)
138
-            ) {
138
+            ){
139 139
                 $this->state->injectors[$class] = $injector;
140 140
 
141 141
                 return true;
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
             if (
145 145
                 \interface_exists($target, true)
146 146
                 && $reflection->implementsInterface($target)
147
-            ) {
147
+            ){
148 148
                 $this->state->injectors[$class] = $injector;
149 149
 
150 150
                 return true;
Please login to merge, or discard this patch.
Braces   +17 added lines, -8 removed lines patch added patch discarded remove patch
@@ -40,7 +40,8 @@  discard block
 block discarded – undo
40 40
      */
41 41
     public function bind(string $alias, string|array|callable|object $resolver): void
42 42
     {
43
-        if (\is_array($resolver) || $resolver instanceof \Closure || $resolver instanceof Autowire) {
43
+        if (\is_array($resolver) || $resolver instanceof \Closure || $resolver instanceof Autowire)
44
+        {
44 45
             // array means = execute me, false = not singleton
45 46
             $this->state->bindings[$alias] = [$resolver, false];
46 47
 
@@ -58,7 +59,8 @@  discard block
 block discarded – undo
58 59
      */
59 60
     public function bindSingleton(string $alias, string|array|callable|object $resolver): void
60 61
     {
61
-        if (\is_object($resolver) && !$resolver instanceof \Closure && !$resolver instanceof Autowire) {
62
+        if (\is_object($resolver) && !$resolver instanceof \Closure && !$resolver instanceof Autowire)
63
+        {
62 64
             // direct binding to an instance
63 65
             $this->state->bindings[$alias] = $resolver;
64 66
 
@@ -73,12 +75,14 @@  discard block
 block discarded – undo
73 75
      */
74 76
     public function hasInstance(string $alias): bool
75 77
     {
76
-        if (!$this->container->has($alias)) {
78
+        if (!$this->container->has($alias))
79
+        {
77 80
             return false;
78 81
         }
79 82
         $bindings = &$this->state->bindings;
80 83
 
81
-        while (isset($bindings[$alias]) && \is_string($bindings[$alias])) {
84
+        while (isset($bindings[$alias]) && \is_string($bindings[$alias]))
85
+        {
82 86
             //Checking alias tree
83 87
             $alias = $bindings[$alias];
84 88
         }
@@ -111,13 +115,17 @@  discard block
 block discarded – undo
111 115
 
112 116
     public function hasInjector(string $class): bool
113 117
     {
114
-        try {
118
+        try
119
+        {
115 120
             $reflection = new \ReflectionClass($class);
116
-        } catch (\ReflectionException $e) {
121
+        }
122
+        catch (\ReflectionException $e)
123
+        {
117 124
             throw new ContainerException($e->getMessage(), $e->getCode(), $e);
118 125
         }
119 126
 
120
-        if (\array_key_exists($class, $this->state->injectors)) {
127
+        if (\array_key_exists($class, $this->state->injectors))
128
+        {
121 129
             return $this->state->injectors[$class] !== null;
122 130
         }
123 131
 
@@ -131,7 +139,8 @@  discard block
 block discarded – undo
131 139
         }
132 140
 
133 141
         // check interfaces
134
-        foreach ($this->state->injectors as $target => $injector) {
142
+        foreach ($this->state->injectors as $target => $injector)
143
+        {
135 144
             if (
136 145
                 \class_exists($target, true)
137 146
                 && $reflection->isSubclassOf($target)
Please login to merge, or discard this patch.
src/Core/src/Internal/DestructorTrait.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,14 +12,14 @@
 block discarded – undo
12 12
     public function destruct(): void
13 13
     {
14 14
         $class = new \ReflectionClass($this);
15
-        foreach ($class->getProperties() as $property) {
15
+        foreach ($class->getProperties() as $property){
16 16
             $name = $property->getName();
17
-            if (!isset($this->$name)) {
17
+            if (!isset($this->$name)){
18 18
                 continue;
19 19
             }
20 20
             $value = $this->$name;
21 21
             unset($this->$name);
22
-            if (\is_object($value) && \method_exists($value, 'destruct')) {
22
+            if (\is_object($value) && \method_exists($value, 'destruct')){
23 23
                 $value->destruct();
24 24
             }
25 25
         }
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,14 +12,17 @@
 block discarded – undo
12 12
     public function destruct(): void
13 13
     {
14 14
         $class = new \ReflectionClass($this);
15
-        foreach ($class->getProperties() as $property) {
15
+        foreach ($class->getProperties() as $property)
16
+        {
16 17
             $name = $property->getName();
17
-            if (!isset($this->$name)) {
18
+            if (!isset($this->$name))
19
+            {
18 20
                 continue;
19 21
             }
20 22
             $value = $this->$name;
21 23
             unset($this->$name);
22
-            if (\is_object($value) && \method_exists($value, 'destruct')) {
24
+            if (\is_object($value) && \method_exists($value, 'destruct'))
25
+            {
23 26
                 $value->destruct();
24 27
             }
25 28
         }
Please login to merge, or discard this patch.
src/Core/src/Internal/Registry.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
     public function __construct(
18 18
         private Config $config,
19 19
         private array $objects = [],
20
-    ) {
20
+    ){
21 21
     }
22 22
 
23 23
     public function set(string $name, object $value): void
Please login to merge, or discard this patch.
src/Core/src/Internal/ResolvingState.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -23,15 +23,15 @@  discard block
 block discarded – undo
23 23
     public function __construct(
24 24
         public readonly ReflectionFunctionAbstract $reflection,
25 25
         private array $arguments,
26
-    ) {
26
+    ){
27 27
         $this->modeNamed = $this->isNamedMode();
28 28
     }
29 29
 
30 30
     public function addResolvedValue(mixed &$value, string $key = null): void
31 31
     {
32
-        if ($key === null) {
32
+        if ($key === null){
33 33
             $this->resolvedValues[] = &$value;
34
-        } else {
34
+        }else{
35 35
             $this->resolvedValues[$key] = &$value;
36 36
         }
37 37
     }
@@ -42,25 +42,25 @@  discard block
 block discarded – undo
42 42
             ? $parameter->getName()
43 43
             : $parameter->getPosition();
44 44
 
45
-        if (!\array_key_exists($key, $this->arguments)) {
45
+        if (!\array_key_exists($key, $this->arguments)){
46 46
             return [];
47 47
         }
48 48
         $_val = &$this->arguments[$key];
49 49
 
50
-        if ($variadic && \is_array($_val)) {
50
+        if ($variadic && \is_array($_val)){
51 51
             // Save keys is possible
52 52
             $positional = true;
53 53
             $result = [];
54
-            foreach ($_val as $key => &$item) {
55
-                if (!$positional && \is_int($key)) {
54
+            foreach ($_val as $key => &$item){
55
+                if (!$positional && \is_int($key)){
56 56
                     throw new ResolvingException(
57 57
                         'Cannot use positional argument after named argument during unpacking named variadic argument.'
58 58
                     );
59 59
                 }
60 60
                 $positional = $positional && \is_int($key);
61
-                if ($positional) {
61
+                if ($positional){
62 62
                     $result[] = &$item;
63
-                } else {
63
+                }else{
64 64
                     $result[$key] = &$item;
65 65
                 }
66 66
             }
@@ -78,10 +78,10 @@  discard block
 block discarded – undo
78 78
     {
79 79
         $nums = 0;
80 80
         $strings = 0;
81
-        foreach ($this->arguments as $key => $_) {
82
-            if (\is_int($key)) {
81
+        foreach ($this->arguments as $key => $_){
82
+            if (\is_int($key)){
83 83
                 ++$nums;
84
-            } else {
84
+            }else{
85 85
                 ++$strings;
86 86
             }
87 87
         }
Please login to merge, or discard this patch.
Braces   +25 added lines, -11 removed lines patch added patch discarded remove patch
@@ -29,9 +29,12 @@  discard block
 block discarded – undo
29 29
 
30 30
     public function addResolvedValue(mixed &$value, string $key = null): void
31 31
     {
32
-        if ($key === null) {
32
+        if ($key === null)
33
+        {
33 34
             $this->resolvedValues[] = &$value;
34
-        } else {
35
+        }
36
+        else
37
+        {
35 38
             $this->resolvedValues[$key] = &$value;
36 39
         }
37 40
     }
@@ -42,25 +45,32 @@  discard block
 block discarded – undo
42 45
             ? $parameter->getName()
43 46
             : $parameter->getPosition();
44 47
 
45
-        if (!\array_key_exists($key, $this->arguments)) {
48
+        if (!\array_key_exists($key, $this->arguments))
49
+        {
46 50
             return [];
47 51
         }
48 52
         $_val = &$this->arguments[$key];
49 53
 
50
-        if ($variadic && \is_array($_val)) {
54
+        if ($variadic && \is_array($_val))
55
+        {
51 56
             // Save keys is possible
52 57
             $positional = true;
53 58
             $result = [];
54
-            foreach ($_val as $key => &$item) {
55
-                if (!$positional && \is_int($key)) {
59
+            foreach ($_val as $key => &$item)
60
+            {
61
+                if (!$positional && \is_int($key))
62
+                {
56 63
                     throw new ResolvingException(
57 64
                         'Cannot use positional argument after named argument during unpacking named variadic argument.'
58 65
                     );
59 66
                 }
60 67
                 $positional = $positional && \is_int($key);
61
-                if ($positional) {
68
+                if ($positional)
69
+                {
62 70
                     $result[] = &$item;
63
-                } else {
71
+                }
72
+                else
73
+                {
64 74
                     $result[$key] = &$item;
65 75
                 }
66 76
             }
@@ -78,10 +88,14 @@  discard block
 block discarded – undo
78 88
     {
79 89
         $nums = 0;
80 90
         $strings = 0;
81
-        foreach ($this->arguments as $key => $_) {
82
-            if (\is_int($key)) {
91
+        foreach ($this->arguments as $key => $_)
92
+        {
93
+            if (\is_int($key))
94
+            {
83 95
                 ++$nums;
84
-            } else {
96
+            }
97
+            else
98
+            {
85 99
                 ++$strings;
86 100
             }
87 101
         }
Please login to merge, or discard this patch.
src/Core/src/Internal/Invoker.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -35,18 +35,18 @@  discard block
 block discarded – undo
35 35
      */
36 36
     public function invoke(mixed $target, array $parameters = []): mixed
37 37
     {
38
-        if (\is_array($target) && isset($target[1])) {
38
+        if (\is_array($target) && isset($target[1])){
39 39
             // In a form of resolver and method
40 40
             [$resolver, $method] = $target;
41 41
 
42 42
             // Resolver instance (i.e. [ClassName::class, 'method'])
43
-            if (\is_string($resolver)) {
43
+            if (\is_string($resolver)){
44 44
                 $resolver = $this->container->get($resolver);
45 45
             }
46 46
 
47
-            try {
47
+            try{
48 48
                 $method = new \ReflectionMethod($resolver, $method);
49
-            } catch (\ReflectionException $e) {
49
+            }catch (\ReflectionException $e){
50 50
                 throw new ContainerException($e->getMessage(), $e->getCode(), $e);
51 51
             }
52 52
 
@@ -57,14 +57,14 @@  discard block
 block discarded – undo
57 57
             );
58 58
         }
59 59
 
60
-        if (\is_string($target) && \is_callable($target)) {
60
+        if (\is_string($target) && \is_callable($target)){
61 61
             $target = $target(...);
62 62
         }
63 63
 
64
-        if ($target instanceof \Closure) {
65
-            try {
64
+        if ($target instanceof \Closure){
65
+            try{
66 66
                 $reflection = new \ReflectionFunction($target);
67
-            } catch (\ReflectionException $e) {
67
+            }catch (\ReflectionException $e){
68 68
                 throw new ContainerException($e->getMessage(), $e->getCode(), $e);
69 69
             }
70 70
 
Please login to merge, or discard this patch.
Braces   +18 added lines, -8 removed lines patch added patch discarded remove patch
@@ -35,18 +35,23 @@  discard block
 block discarded – undo
35 35
      */
36 36
     public function invoke(mixed $target, array $parameters = []): mixed
37 37
     {
38
-        if (\is_array($target) && isset($target[1])) {
38
+        if (\is_array($target) && isset($target[1]))
39
+        {
39 40
             // In a form of resolver and method
40 41
             [$resolver, $method] = $target;
41 42
 
42 43
             // Resolver instance (i.e. [ClassName::class, 'method'])
43
-            if (\is_string($resolver)) {
44
+            if (\is_string($resolver))
45
+            {
44 46
                 $resolver = $this->container->get($resolver);
45 47
             }
46 48
 
47
-            try {
49
+            try
50
+            {
48 51
                 $method = new \ReflectionMethod($resolver, $method);
49
-            } catch (\ReflectionException $e) {
52
+            }
53
+            catch (\ReflectionException $e)
54
+            {
50 55
                 throw new ContainerException($e->getMessage(), $e->getCode(), $e);
51 56
             }
52 57
 
@@ -57,14 +62,19 @@  discard block
 block discarded – undo
57 62
             );
58 63
         }
59 64
 
60
-        if (\is_string($target) && \is_callable($target)) {
65
+        if (\is_string($target) && \is_callable($target))
66
+        {
61 67
             $target = $target(...);
62 68
         }
63 69
 
64
-        if ($target instanceof \Closure) {
65
-            try {
70
+        if ($target instanceof \Closure)
71
+        {
72
+            try
73
+            {
66 74
                 $reflection = new \ReflectionFunction($target);
67
-            } catch (\ReflectionException $e) {
75
+            }
76
+            catch (\ReflectionException $e)
77
+            {
68 78
                 throw new ContainerException($e->getMessage(), $e->getCode(), $e);
69 79
             }
70 80
 
Please login to merge, or discard this patch.
src/Core/src/Internal/Container.php 2 patches
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,8 @@
 block discarded – undo
50 50
      */
51 51
     public function get(string|Autowire $id, string $context = null): mixed
52 52
     {
53
-        if ($id instanceof Autowire) {
53
+        if ($id instanceof Autowire)
54
+        {
54 55
             return $id->resolve($this->factory);
55 56
         }
56 57
 
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
     use DestructorTrait;
18 18
 
19 19
     private State $state;
20
-    private FactoryInterface|Factory $factory;
20
+    private FactoryInterface | Factory $factory;
21 21
 
22 22
     public function __construct(Registry $constructor)
23 23
     {
@@ -46,9 +46,9 @@  discard block
 block discarded – undo
46 46
      * @throws ContainerException
47 47
      * @throws \Throwable
48 48
      */
49
-    public function get(string|Autowire $id, string $context = null): mixed
49
+    public function get(string | Autowire $id, string $context = null): mixed
50 50
     {
51
-        if ($id instanceof Autowire) {
51
+        if ($id instanceof Autowire){
52 52
             return $id->resolve($this->factory);
53 53
         }
54 54
 
Please login to merge, or discard this patch.