Passed
Pull Request — master (#1195)
by butschster
20:16 queued 08:35
created
src/Core/src/Internal/Config/StateBinder.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -32,21 +32,21 @@  discard block
 block discarded – undo
32 32
 {
33 33
     public function __construct(
34 34
         protected readonly State $state,
35
-    ) {}
35
+    ){}
36 36
 
37 37
     /**
38 38
      * @param TResolver|object $resolver
39 39
      */
40 40
     public function bind(string $alias, mixed $resolver): void
41 41
     {
42
-        if ($resolver instanceof Inflector && (\interface_exists($alias) || \class_exists($alias))) {
42
+        if ($resolver instanceof Inflector && (\interface_exists($alias) || \class_exists($alias))){
43 43
             $this->state->inflectors[$alias][] = $resolver;
44 44
             return;
45 45
         }
46 46
 
47
-        try {
47
+        try{
48 48
             $config = $this->makeConfig($resolver, false);
49
-        } catch (\Throwable $e) {
49
+        }catch (\Throwable $e){
50 50
             throw $this->invalidBindingException($alias, $e);
51 51
         }
52 52
 
@@ -58,9 +58,9 @@  discard block
 block discarded – undo
58 58
      */
59 59
     public function bindSingleton(string $alias, mixed $resolver): void
60 60
     {
61
-        try {
61
+        try{
62 62
             $config = $this->makeConfig($resolver, true);
63
-        } catch (\Throwable $e) {
63
+        }catch (\Throwable $e){
64 64
             throw $this->invalidBindingException($alias, $e);
65 65
         }
66 66
 
@@ -72,13 +72,13 @@  discard block
 block discarded – undo
72 72
         $bindings = &$this->state->bindings;
73 73
 
74 74
         $flags = [];
75
-        while ($binding = $bindings[$alias] ?? null and $binding::class === Alias::class) {
75
+        while ($binding = $bindings[$alias] ?? null and $binding::class === Alias::class){
76 76
             //Checking alias tree
77
-            if ($flags[$binding->alias] ?? false) {
77
+            if ($flags[$binding->alias] ?? false){
78 78
                 return $binding->alias === $alias ?: throw new Exception('Circular alias detected');
79 79
             }
80 80
 
81
-            if (\array_key_exists($alias, $this->state->singletons)) {
81
+            if (\array_key_exists($alias, $this->state->singletons)){
82 82
                 return true;
83 83
             }
84 84
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
     public function removeInjector(string $class): void
103 103
     {
104 104
         unset($this->state->injectors[$class]);
105
-        if (!isset($this->state->bindings[$class]) || $this->state->bindings[$class]::class !== Injectable::class) {
105
+        if (!isset($this->state->bindings[$class]) || $this->state->bindings[$class]::class !== Injectable::class){
106 106
             return;
107 107
         }
108 108
         unset($this->state->bindings[$class]);
@@ -110,20 +110,20 @@  discard block
 block discarded – undo
110 110
 
111 111
     public function hasInjector(string $class): bool
112 112
     {
113
-        if (\array_key_exists($class, $this->state->injectors)) {
113
+        if (\array_key_exists($class, $this->state->injectors)){
114 114
             return true;
115 115
         }
116 116
 
117
-        try {
117
+        try{
118 118
             $reflection = new \ReflectionClass($class);
119
-        } catch (\ReflectionException $e) {
119
+        }catch (\ReflectionException $e){
120 120
             throw new ContainerException($e->getMessage(), $e->getCode(), $e);
121 121
         }
122 122
 
123 123
         if (
124 124
             $reflection->implementsInterface(InjectableInterface::class)
125 125
             && $reflection->hasConstant('INJECTOR')
126
-        ) {
126
+        ){
127 127
             $const = $reflection->getConstant('INJECTOR');
128 128
             $this->bindInjector($class, $const);
129 129
 
@@ -131,12 +131,12 @@  discard block
 block discarded – undo
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) && $reflection->isSubclassOf($target))
137 137
                 ||
138 138
                 (\interface_exists($target, true) && $reflection->implementsInterface($target))
139
-            ) {
139
+            ){
140 140
                 $this->state->bindings[$class] = new Injectable($injector);
141 141
 
142 142
                 return true;
@@ -163,15 +163,15 @@  discard block
 block discarded – undo
163 163
 
164 164
     private function makeConfigFromArray(array $resolver, bool $singleton): Binding
165 165
     {
166
-        if (\is_callable($resolver)) {
166
+        if (\is_callable($resolver)){
167 167
             return new Factory($resolver, $singleton);
168 168
         }
169 169
 
170 170
         // Validate lazy invokable array
171
-        if (!isset($resolver[0]) || !isset($resolver[1]) || !\is_string($resolver[1]) || $resolver[1] === '') {
171
+        if (!isset($resolver[0]) || !isset($resolver[1]) || !\is_string($resolver[1]) || $resolver[1] === ''){
172 172
             throw new InvalidArgumentException('Incompatible array declaration for resolver.');
173 173
         }
174
-        if ((!\is_string($resolver[0]) && !\is_object($resolver[0])) || $resolver[0] === '') {
174
+        if ((!\is_string($resolver[0]) && !\is_object($resolver[0])) || $resolver[0] === ''){
175 175
             throw new InvalidArgumentException('Incompatible array declaration for resolver.');
176 176
         }
177 177
 
@@ -191,13 +191,13 @@  discard block
 block discarded – undo
191 191
 
192 192
     private function setBinding(string $alias, Binding $config): void
193 193
     {
194
-        if (isset($this->state->singletons[$alias])) {
194
+        if (isset($this->state->singletons[$alias])){
195 195
             throw new SingletonOverloadException($alias);
196 196
         }
197 197
 
198 198
         $this->state->bindings[$alias] = $config;
199 199
 
200
-        if ($config instanceof Injectable) {
200
+        if ($config instanceof Injectable){
201 201
             $this->state->injectors[$alias] = $config->injector;
202 202
         }
203 203
     }
Please login to merge, or discard this patch.