Passed
Pull Request — master (#831)
by Maxim
07:40
created
src/Core/tests/Internal/Factory/CommonCasesTest.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@
 block discarded – undo
85 85
 
86 86
     public function testClosureFactory(): void
87 87
     {
88
-        $this->bind(Bucket::class, function ($data) {
88
+        $this->bind(Bucket::class, function ($data){
89 89
             return new Bucket('via-closure', $data);
90 90
         });
91 91
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -85,7 +85,8 @@  discard block
 block discarded – undo
85 85
 
86 86
     public function testClosureFactory(): void
87 87
     {
88
-        $this->bind(Bucket::class, function ($data) {
88
+        $this->bind(Bucket::class, function ($data)
89
+        {
89 90
             return new Bucket('via-closure', $data);
90 91
         });
91 92
 
@@ -125,7 +126,8 @@  discard block
 block discarded – undo
125 126
         $sample = new SampleClass();
126 127
 
127 128
         $this->bind(Bucket::class, [self::class, 'makeBucketWithSample']);
128
-        $this->bind(SampleClass::class, function () use ($sample) {
129
+        $this->bind(SampleClass::class, function () use ($sample)
130
+        {
129 131
             return $sample;
130 132
         });
131 133
 
Please login to merge, or discard this patch.
src/Core/tests/Exception/ClosureRendererTraitTest.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
     public function testClassWithNamespace(): void
94 94
     {
95 95
         $this->assertSame(
96
-            'function (?' . Container::class . ' ...$v)',
96
+            'function (?'.Container::class.' ...$v)',
97 97
             $this->renderClosureForTesting(fn (?Container ...$v) => null),
98 98
         );
99 99
     }
@@ -102,14 +102,14 @@  discard block
 block discarded – undo
102 102
     {
103 103
         $this->assertSame(
104 104
             'function (self|string|int|null $v)',
105
-            $this->renderClosureForTesting(fn (self|string|int|null $v) => null),
105
+            $this->renderClosureForTesting(fn (self | string | int | null $v) => null),
106 106
         );
107 107
     }
108 108
 
109 109
     public function testTypeIntersection(): void
110 110
     {
111 111
         $this->assertSame(
112
-            'function (' . ContainerInterface::class . '&' . ContainerExceptionInterface::class . ' $v)',
112
+            'function ('.ContainerInterface::class.'&'.ContainerExceptionInterface::class.' $v)',
113 113
             $this->renderClosureForTesting(fn (ContainerInterface&ContainerExceptionInterface $v) => null),
114 114
         );
115 115
     }
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
     {
128 128
         $this->assertSame(
129 129
             'function (Foo|Bar $v)',
130
-            $this->renderClosureForTesting(fn (\Foo|\Bar $v) => null),
130
+            $this->renderClosureForTesting(fn (\Foo | \Bar $v) => null),
131 131
         );
132 132
     }
133 133
 
Please login to merge, or discard this patch.
src/Core/tests/Fixtures/TypedClass.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,6 +13,6 @@
 block discarded – undo
13 13
         public bool $bool,
14 14
         public array $array = [],
15 15
         public ?string $pong = null
16
-    ) {
16
+    ){
17 17
     }
18 18
 }
Please login to merge, or discard this patch.
src/Core/tests/InjectableTest.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 
32 32
     public function testInvalidInjector(): void
33 33
     {
34
-        $excepted = "Class 'Spiral\Tests\Core\Fixtures\InvalidInjector' must be an " .
34
+        $excepted = "Class 'Spiral\Tests\Core\Fixtures\InvalidInjector' must be an ".
35 35
                     "instance of InjectorInterface for 'Spiral\Tests\Core\Fixtures\TestConfig'";
36 36
         $this->expectException(InjectionException::class);
37 37
         $this->expectExceptionMessage($excepted);
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
     public function testInvalidRuntimeInjector(): void
57 57
     {
58
-        $excepted = "Class 'Spiral\Tests\Core\Fixtures\InvalidInjector' must be an " .
58
+        $excepted = "Class 'Spiral\Tests\Core\Fixtures\InvalidInjector' must be an ".
59 59
             "instance of InjectorInterface for 'Spiral\Tests\Core\Fixtures\TestConfig'";
60 60
         $this->expectException(InjectionException::class);
61 61
         $this->expectExceptionMessage($excepted);
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
         $container->bind(ConfigsInterface::class, $configurator);
103 103
 
104 104
         $configurator->shouldReceive('createInjection')
105
-            ->with(m::on(static function (ReflectionClass $r) {
105
+            ->with(m::on(static function (ReflectionClass $r){
106 106
                 return $r->getName() === TestConfig::class;
107 107
             }), null)
108 108
             ->andReturn($expected)
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
         $container->bind(ConfigsInterface::class, $configurator);
121 121
 
122 122
         $configurator->shouldReceive('createInjection')
123
-            ->with(m::on(static function (ReflectionClass $r) {
123
+            ->with(m::on(static function (ReflectionClass $r){
124 124
                 return $r->getName() === TestConfig::class;
125 125
             }), 'context')
126 126
             ->andReturn($expected)
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -102,7 +102,8 @@  discard block
 block discarded – undo
102 102
         $container->bind(ConfigsInterface::class, $configurator);
103 103
 
104 104
         $configurator->shouldReceive('createInjection')
105
-            ->with(m::on(static function (ReflectionClass $r) {
105
+            ->with(m::on(static function (ReflectionClass $r)
106
+            {
106 107
                 return $r->getName() === TestConfig::class;
107 108
             }), null)
108 109
             ->andReturn($expected)
@@ -120,7 +121,8 @@  discard block
 block discarded – undo
120 121
         $container->bind(ConfigsInterface::class, $configurator);
121 122
 
122 123
         $configurator->shouldReceive('createInjection')
123
-            ->with(m::on(static function (ReflectionClass $r) {
124
+            ->with(m::on(static function (ReflectionClass $r)
125
+            {
124 126
                 return $r->getName() === TestConfig::class;
125 127
             }), 'context')
126 128
             ->andReturn($expected)
Please login to merge, or discard this patch.
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.