Passed
Pull Request — master (#737)
by Vadim
07:15
created
src/Core/tests/Fixtures/TypedClass.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,6 +20,6 @@
 block discarded – undo
20 20
         bool $bool,
21 21
         array $array = [],
22 22
         string $pong = null
23
-    ) {
23
+    ){
24 24
     }
25 25
 }
Please login to merge, or discard this patch.
src/Core/tests/FactoryTest.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
         $container = new Container();
42 42
         $this->assertInstanceOf(FactoryInterface::class, $container);
43 43
 
44
-        $container->bind(Bucket::class, function ($data) {
44
+        $container->bind(Bucket::class, function ($data){
45 45
             return new Bucket('via-closure', $data);
46 46
         });
47 47
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -41,7 +41,8 @@  discard block
 block discarded – undo
41 41
         $container = new Container();
42 42
         $this->assertInstanceOf(FactoryInterface::class, $container);
43 43
 
44
-        $container->bind(Bucket::class, function ($data) {
44
+        $container->bind(Bucket::class, function ($data)
45
+        {
45 46
             return new Bucket('via-closure', $data);
46 47
         });
47 48
 
@@ -78,7 +79,8 @@  discard block
 block discarded – undo
78 79
         $sample = new SampleClass();
79 80
 
80 81
         $container->bind(Bucket::class, [self::class, 'makeBucketWithSample']);
81
-        $container->bind(SampleClass::class, function () use ($sample) {
82
+        $container->bind(SampleClass::class, function () use ($sample)
83
+        {
82 84
             return $sample;
83 85
         });
84 86
 
Please login to merge, or discard this patch.
src/Core/tests/ScopesTest.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -40,11 +40,11 @@  discard block
 block discarded – undo
40 40
 
41 41
         $this->assertNull(ContainerScope::getContainer());
42 42
 
43
-        try {
43
+        try{
44 44
             $this->assertTrue(ContainerScope::runScope($container, function () use ($container): void {
45 45
                 throw new RuntimeException('exception');
46 46
             }));
47
-        } catch (\Throwable $e) {
47
+        }catch (\Throwable $e){
48 48
         }
49 49
 
50 50
         $this->assertInstanceOf(RuntimeException::class, $e);
@@ -91,14 +91,14 @@  discard block
 block discarded – undo
91 91
             return $c->get('bucket')->getName() == 'b' && $c->has('other');
92 92
         }));
93 93
 
94
-        try {
94
+        try{
95 95
             $this->assertTrue($c->runScope([
96 96
                 'bucket' => new Bucket('b'),
97 97
                 'other'  => new SampleClass()
98 98
             ], function () use ($c): void {
99 99
                 throw new RuntimeException('exception');
100 100
             }));
101
-        } catch (\Throwable $e) {
101
+        }catch (\Throwable $e){
102 102
         }
103 103
 
104 104
         $this->assertSame('a', $c->get('bucket')->getName());
Please login to merge, or discard this patch.
Braces   +16 added lines, -7 removed lines patch added patch discarded remove patch
@@ -27,7 +27,8 @@  discard block
 block discarded – undo
27 27
 
28 28
         $this->assertNull(ContainerScope::getContainer());
29 29
 
30
-        $this->assertTrue(ContainerScope::runScope($container, function () use ($container) {
30
+        $this->assertTrue(ContainerScope::runScope($container, function () use ($container)
31
+        {
31 32
             return $container === ContainerScope::getContainer();
32 33
         }));
33 34
 
@@ -40,11 +41,14 @@  discard block
 block discarded – undo
40 41
 
41 42
         $this->assertNull(ContainerScope::getContainer());
42 43
 
43
-        try {
44
+        try
45
+        {
44 46
             $this->assertTrue(ContainerScope::runScope($container, function () use ($container): void {
45 47
                 throw new RuntimeException('exception');
46 48
             }));
47
-        } catch (\Throwable $e) {
49
+        }
50
+        catch (\Throwable $e)
51
+        {
48 52
         }
49 53
 
50 54
         $this->assertInstanceOf(RuntimeException::class, $e);
@@ -62,7 +66,8 @@  discard block
 block discarded – undo
62 66
         $this->assertTrue($c->runScope([
63 67
             'bucket' => new Bucket('b'),
64 68
             'other'  => new SampleClass()
65
-        ], function () use ($c) {
69
+        ], function () use ($c)
70
+        {
66 71
             $this->assertSame('b', $c->get('bucket')->getName());
67 72
             $this->assertTrue($c->has('other'));
68 73
 
@@ -84,21 +89,25 @@  discard block
 block discarded – undo
84 89
         $this->assertTrue($c->runScope([
85 90
             'bucket' => new Bucket('b'),
86 91
             'other'  => new SampleClass()
87
-        ], function () use ($c) {
92
+        ], function () use ($c)
93
+        {
88 94
             $this->assertSame('b', $c->get('bucket')->getName());
89 95
             $this->assertTrue($c->has('other'));
90 96
 
91 97
             return $c->get('bucket')->getName() == 'b' && $c->has('other');
92 98
         }));
93 99
 
94
-        try {
100
+        try
101
+        {
95 102
             $this->assertTrue($c->runScope([
96 103
                 'bucket' => new Bucket('b'),
97 104
                 'other'  => new SampleClass()
98 105
             ], function () use ($c): void {
99 106
                 throw new RuntimeException('exception');
100 107
             }));
101
-        } catch (\Throwable $e) {
108
+        }
109
+        catch (\Throwable $e)
110
+        {
102 111
         }
103 112
 
104 113
         $this->assertSame('a', $c->get('bucket')->getName());
Please login to merge, or discard this patch.
src/Core/tests/SingletonsTest.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
     {
72 72
         $container = new Container();
73 73
 
74
-        $container->bindSingleton('sampleClass', function () {
74
+        $container->bindSingleton('sampleClass', function (){
75 75
             return new SampleClass();
76 76
         });
77 77
 
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
         $container = new Container();
99 99
         $container->bindSingleton('singleton', 'sampleClass');
100 100
 
101
-        $container->bind('sampleClass', function () {
101
+        $container->bind('sampleClass', function (){
102 102
             return new SampleClass();
103 103
         });
104 104
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -60,7 +60,8 @@  discard block
 block discarded – undo
60 60
 
61 61
         $instance = new SampleClass();
62 62
 
63
-        $container->bindSingleton('sampleClass', function () use ($instance) {
63
+        $container->bindSingleton('sampleClass', function () use ($instance)
64
+        {
64 65
             return $instance;
65 66
         });
66 67
 
@@ -71,7 +72,8 @@  discard block
 block discarded – undo
71 72
     {
72 73
         $container = new Container();
73 74
 
74
-        $container->bindSingleton('sampleClass', function () {
75
+        $container->bindSingleton('sampleClass', function ()
76
+        {
75 77
             return new SampleClass();
76 78
         });
77 79
 
@@ -98,7 +100,8 @@  discard block
 block discarded – undo
98 100
         $container = new Container();
99 101
         $container->bindSingleton('singleton', 'sampleClass');
100 102
 
101
-        $container->bind('sampleClass', function () {
103
+        $container->bind('sampleClass', function ()
104
+        {
102 105
             return new SampleClass();
103 106
         });
104 107
 
Please login to merge, or discard this patch.
src/Core/tests/InjectableTest.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 
37 37
     public function testInvalidInjector(): void
38 38
     {
39
-        $excepted = "Class 'Spiral\Tests\Core\Fixtures\InvalidInjector' must be an " .
39
+        $excepted = "Class 'Spiral\Tests\Core\Fixtures\InvalidInjector' must be an ".
40 40
                     "instance of InjectorInterface for 'Spiral\Tests\Core\Fixtures\TestConfig'";
41 41
         $this->expectException(InjectionException::class);
42 42
         $this->expectExceptionMessage($excepted);
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 
61 61
     public function testInvalidRuntimeInjector(): void
62 62
     {
63
-        $excepted = "Class 'Spiral\Tests\Core\Fixtures\InvalidInjector' must be an " .
63
+        $excepted = "Class 'Spiral\Tests\Core\Fixtures\InvalidInjector' must be an ".
64 64
             "instance of InjectorInterface for 'Spiral\Tests\Core\Fixtures\TestConfig'";
65 65
         $this->expectException(InjectionException::class);
66 66
         $this->expectExceptionMessage($excepted);
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
         $container->bind(ConfigsInterface::class, $configurator);
126 126
 
127 127
         $configurator->shouldReceive('createInjection')
128
-            ->with(m::on(static function (ReflectionClass $r) {
128
+            ->with(m::on(static function (ReflectionClass $r){
129 129
                 return $r->getName() === TestConfig::class;
130 130
             }), null)
131 131
             ->andReturn($expected)
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
         $container->bind(ConfigsInterface::class, $configurator);
144 144
 
145 145
         $configurator->shouldReceive('createInjection')
146
-            ->with(m::on(static function (ReflectionClass $r) {
146
+            ->with(m::on(static function (ReflectionClass $r){
147 147
                 return $r->getName() === TestConfig::class;
148 148
             }), 'context')
149 149
             ->andReturn($expected)
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
         $container->bind(ConfigsInterface::class, $configurator);
162 162
 
163 163
         $configurator->shouldReceive('createInjection')
164
-            ->with(m::on(static function (ReflectionClass $r) {
164
+            ->with(m::on(static function (ReflectionClass $r){
165 165
                 return $r->getName() === TestConfig::class;
166 166
             }), 'contextArgument')
167 167
             ->andReturn($expected)
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -125,7 +125,8 @@  discard block
 block discarded – undo
125 125
         $container->bind(ConfigsInterface::class, $configurator);
126 126
 
127 127
         $configurator->shouldReceive('createInjection')
128
-            ->with(m::on(static function (ReflectionClass $r) {
128
+            ->with(m::on(static function (ReflectionClass $r)
129
+            {
129 130
                 return $r->getName() === TestConfig::class;
130 131
             }), null)
131 132
             ->andReturn($expected)
@@ -143,7 +144,8 @@  discard block
 block discarded – undo
143 144
         $container->bind(ConfigsInterface::class, $configurator);
144 145
 
145 146
         $configurator->shouldReceive('createInjection')
146
-            ->with(m::on(static function (ReflectionClass $r) {
147
+            ->with(m::on(static function (ReflectionClass $r)
148
+            {
147 149
                 return $r->getName() === TestConfig::class;
148 150
             }), 'context')
149 151
             ->andReturn($expected)
@@ -161,7 +163,8 @@  discard block
 block discarded – undo
161 163
         $container->bind(ConfigsInterface::class, $configurator);
162 164
 
163 165
         $configurator->shouldReceive('createInjection')
164
-            ->with(m::on(static function (ReflectionClass $r) {
166
+            ->with(m::on(static function (ReflectionClass $r)
167
+            {
165 168
                 return $r->getName() === TestConfig::class;
166 169
             }), 'contextArgument')
167 170
             ->andReturn($expected)
Please login to merge, or discard this patch.
src/Core/tests/BindingsTest.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
 
26 26
         $this->assertFalse($container->has('abc'));
27 27
 
28
-        $container->bind('abc', function () {
28
+        $container->bind('abc', function (){
29 29
             return 'hello';
30 30
         });
31 31
 
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
         $container = new Container();
39 39
 
40 40
         $this->assertFalse($container->has('abc'));
41
-        $container->bind('abc', function () {
41
+        $container->bind('abc', function (){
42 42
             return 'hello';
43 43
         });
44 44
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,7 +25,8 @@  discard block
 block discarded – undo
25 25
 
26 26
         $this->assertFalse($container->has('abc'));
27 27
 
28
-        $container->bind('abc', function () {
28
+        $container->bind('abc', function ()
29
+        {
29 30
             return 'hello';
30 31
         });
31 32
 
@@ -38,7 +39,8 @@  discard block
 block discarded – undo
38 39
         $container = new Container();
39 40
 
40 41
         $this->assertFalse($container->has('abc'));
41
-        $container->bind('abc', function () {
42
+        $container->bind('abc', function ()
43
+        {
42 44
             return 'hello';
43 45
         });
44 46
 
Please login to merge, or discard this patch.
src/Core/src/ContainerScope.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -46,11 +46,11 @@
 block discarded – undo
46 46
     {
47 47
         [$previous, self::$container] = [self::$container, $container];
48 48
 
49
-        try {
49
+        try{
50 50
             return $scope();
51
-        } catch (Throwable $e) {
51
+        }catch (Throwable $e){
52 52
             throw $e;
53
-        } finally {
53
+        }finally{
54 54
             self::$container = $previous;
55 55
         }
56 56
     }
Please login to merge, or discard this patch.
Braces   +8 added lines, -3 removed lines patch added patch discarded remove patch
@@ -46,11 +46,16 @@
 block discarded – undo
46 46
     {
47 47
         [$previous, self::$container] = [self::$container, $container];
48 48
 
49
-        try {
49
+        try
50
+        {
50 51
             return $scope();
51
-        } catch (Throwable $e) {
52
+        }
53
+        catch (Throwable $e)
54
+        {
52 55
             throw $e;
53
-        } finally {
56
+        }
57
+        finally
58
+        {
54 59
             self::$container = $previous;
55 60
         }
56 61
     }
Please login to merge, or discard this patch.
src/Core/src/Exception/Container/ArgumentException.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -44,8 +44,8 @@
 block discarded – undo
44 44
         $this->context = $context;
45 45
 
46 46
         $name = $context->getName();
47
-        if ($context instanceof ReflectionMethod) {
48
-            $name = $context->class . '::' . $name;
47
+        if ($context instanceof ReflectionMethod){
48
+            $name = $context->class.'::'.$name;
49 49
         }
50 50
 
51 51
         parent::__construct("Unable to resolve '{$parameter->name}' argument in '{$name}'");
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,7 +44,8 @@
 block discarded – undo
44 44
         $this->context = $context;
45 45
 
46 46
         $name = $context->getName();
47
-        if ($context instanceof ReflectionMethod) {
47
+        if ($context instanceof ReflectionMethod)
48
+        {
48 49
             $name = $context->class . '::' . $name;
49 50
         }
50 51
 
Please login to merge, or discard this patch.
src/Core/src/Container/Autowire.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -58,22 +58,22 @@  discard block
 block discarded – undo
58 58
      */
59 59
     public static function wire($definition): Autowire
60 60
     {
61
-        if ($definition instanceof self) {
61
+        if ($definition instanceof self){
62 62
             return $definition;
63 63
         }
64 64
 
65
-        if (is_string($definition)) {
65
+        if (is_string($definition)){
66 66
             return new Autowire($definition);
67 67
         }
68 68
 
69
-        if (is_array($definition) && isset($definition['class'])) {
69
+        if (is_array($definition) && isset($definition['class'])){
70 70
             return new Autowire(
71 71
                 $definition['class'],
72 72
                 $definition['options'] ?? $definition['params'] ?? []
73 73
             );
74 74
         }
75 75
 
76
-        if (is_object($definition)) {
76
+        if (is_object($definition)){
77 77
             $autowire = new self(get_class($definition), []);
78 78
             $autowire->target = $definition;
79 79
             return $autowire;
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
      */
93 93
     public function resolve(FactoryInterface $factory, array $parameters = [])
94 94
     {
95
-        if ($this->target !== null) {
95
+        if ($this->target !== null){
96 96
             // pre-wired
97 97
             return $this->target;
98 98
         }
Please login to merge, or discard this patch.
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -58,22 +58,26 @@  discard block
 block discarded – undo
58 58
      */
59 59
     public static function wire($definition): Autowire
60 60
     {
61
-        if ($definition instanceof self) {
61
+        if ($definition instanceof self)
62
+        {
62 63
             return $definition;
63 64
         }
64 65
 
65
-        if (is_string($definition)) {
66
+        if (is_string($definition))
67
+        {
66 68
             return new Autowire($definition);
67 69
         }
68 70
 
69
-        if (is_array($definition) && isset($definition['class'])) {
71
+        if (is_array($definition) && isset($definition['class']))
72
+        {
70 73
             return new Autowire(
71 74
                 $definition['class'],
72 75
                 $definition['options'] ?? $definition['params'] ?? []
73 76
             );
74 77
         }
75 78
 
76
-        if (is_object($definition)) {
79
+        if (is_object($definition))
80
+        {
77 81
             $autowire = new self(get_class($definition), []);
78 82
             $autowire->target = $definition;
79 83
             return $autowire;
@@ -92,7 +96,8 @@  discard block
 block discarded – undo
92 96
      */
93 97
     public function resolve(FactoryInterface $factory, array $parameters = [])
94 98
     {
95
-        if ($this->target !== null) {
99
+        if ($this->target !== null)
100
+        {
96 101
             // pre-wired
97 102
             return $this->target;
98 103
         }
Please login to merge, or discard this patch.