Passed
Pull Request — master (#955)
by Maxim
09:18
created
src/Framework/Command/Router/ListCommand.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -27,8 +27,8 @@  discard block
 block discarded – undo
27 27
     {
28 28
         $grid = $this->table(['Name:', 'Verbs:', 'Pattern:', 'Target:', 'Group:']);
29 29
 
30
-        foreach ($router->getRoutes() as $name => $route) {
31
-            if ($route instanceof Route) {
30
+        foreach ($router->getRoutes() as $name => $route){
31
+            if ($route instanceof Route){
32 32
                 $grid->addRow(
33 33
                     [
34 34
                         $name,
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
     private function getRouteGroups(GroupRegistry $registry, string $routeName): array
53 53
     {
54 54
         $groups = [];
55
-        foreach ($registry as $groupName => $group) {
56
-            if ($group->hasRoute($routeName)) {
55
+        foreach ($registry as $groupName => $group){
56
+            if ($group->hasRoute($routeName)){
57 57
                 $groups[] = $groupName;
58 58
             }
59 59
         }
@@ -63,12 +63,12 @@  discard block
 block discarded – undo
63 63
 
64 64
     private function getVerbs(Route $route): string
65 65
     {
66
-        if ($route->getVerbs() === Route::VERBS) {
66
+        if ($route->getVerbs() === Route::VERBS){
67 67
             return '*';
68 68
         }
69 69
 
70 70
         $result = [];
71
-        foreach ($route->getVerbs() as $verb) {
71
+        foreach ($route->getVerbs() as $verb){
72 72
             $result[] = match (\strtolower($verb)) {
73 73
                 'get' => '<fg=green>GET</>',
74 74
                 'post' => '<fg=blue>POST</>',
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
         $pattern = \preg_replace_callback(
96 96
             '/<([^>]*)>/',
97 97
             static fn ($m) => \sprintf('<fg=magenta>%s</>', $m[0]),
98
-            !empty($prefix) ? $prefix . '/' . \trim($pattern, '/') : $pattern
98
+            !empty($prefix) ? $prefix.'/'.\trim($pattern, '/') : $pattern
99 99
         );
100 100
 
101 101
         return $pattern;
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
     private function getTarget(Route $route, KernelInterface $kernel): string
109 109
     {
110 110
         $target = $this->getValue($route, 'target');
111
-        switch (true) {
111
+        switch (true){
112 112
             case $target instanceof \Closure:
113 113
                 $reflection = new \ReflectionFunction($target);
114 114
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 
134 134
             case $target instanceof Group:
135 135
                 $result = [];
136
-                foreach ($this->getValue($target, 'controllers') as $alias => $class) {
136
+                foreach ($this->getValue($target, 'controllers') as $alias => $class){
137 137
                     $result[] = \sprintf('%s => %s', $alias, $this->relativeClass($class, $kernel));
138 138
                 }
139 139
 
@@ -152,10 +152,10 @@  discard block
 block discarded – undo
152 152
 
153 153
     private function getValue(object $object, string $property): mixed
154 154
     {
155
-        try {
155
+        try{
156 156
             $r = new \ReflectionObject($object);
157 157
             $prop = $r->getProperty($property);
158
-        } catch (\Throwable $e) {
158
+        }catch (\Throwable $e){
159 159
             return $e->getMessage();
160 160
         }
161 161
 
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
     {
167 167
         $r = new \ReflectionObject($kernel);
168 168
 
169
-        if (\str_starts_with($class, $r->getNamespaceName())) {
169
+        if (\str_starts_with($class, $r->getNamespaceName())){
170 170
             return \substr($class, \strlen($r->getNamespaceName()) + 1);
171 171
         }
172 172
 
Please login to merge, or discard this patch.
src/Core/src/Internal/Config/StateBinder.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  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
     /**
@@ -40,14 +40,14 @@  discard block
 block discarded – undo
40 40
      */
41 41
     public function bind(string $alias, mixed $resolver): void
42 42
     {
43
-        if ($resolver instanceof Inflector && (\interface_exists($alias) || \class_exists($alias))) {
43
+        if ($resolver instanceof Inflector && (\interface_exists($alias) || \class_exists($alias))){
44 44
             $this->state->inflectors[$alias][] = $resolver;
45 45
             return;
46 46
         }
47 47
 
48
-        try {
48
+        try{
49 49
             $config = $this->makeConfig($resolver, false);
50
-        } catch (\Throwable $e) {
50
+        }catch (\Throwable $e){
51 51
             throw $this->invalidBindingException($alias, $e);
52 52
         }
53 53
 
@@ -59,9 +59,9 @@  discard block
 block discarded – undo
59 59
      */
60 60
     public function bindSingleton(string $alias, mixed $resolver): void
61 61
     {
62
-        try {
62
+        try{
63 63
             $config = $this->makeConfig($resolver, true);
64
-        } catch (\Throwable $e) {
64
+        }catch (\Throwable $e){
65 65
             throw $this->invalidBindingException($alias, $e);
66 66
         }
67 67
 
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
         $bindings = &$this->state->bindings;
74 74
 
75 75
         $flags = [];
76
-        while ($binding = $bindings[$alias] ?? null and $binding::class === Alias::class) {
76
+        while ($binding = $bindings[$alias] ?? null and $binding::class === Alias::class){
77 77
             //Checking alias tree
78
-            if ($flags[$binding->alias] ?? false) {
78
+            if ($flags[$binding->alias] ?? false){
79 79
                 return $binding->alias === $alias ?: throw new Exception('Circular alias detected');
80 80
             }
81 81
 
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
     public function removeInjector(string $class): void
101 101
     {
102 102
         unset($this->state->injectors[$class]);
103
-        if (!isset($this->state->bindings[$class]) || $this->state->bindings[$class]::class !== Injectable::class) {
103
+        if (!isset($this->state->bindings[$class]) || $this->state->bindings[$class]::class !== Injectable::class){
104 104
             return;
105 105
         }
106 106
         unset($this->state->bindings[$class]);
@@ -108,20 +108,20 @@  discard block
 block discarded – undo
108 108
 
109 109
     public function hasInjector(string $class): bool
110 110
     {
111
-        try {
111
+        try{
112 112
             $reflection = new \ReflectionClass($class);
113
-        } catch (\ReflectionException $e) {
113
+        }catch (\ReflectionException $e){
114 114
             throw new ContainerException($e->getMessage(), $e->getCode(), $e);
115 115
         }
116 116
 
117
-        if (\array_key_exists($class, $this->state->injectors)) {
117
+        if (\array_key_exists($class, $this->state->injectors)){
118 118
             return true;
119 119
         }
120 120
 
121 121
         if (
122 122
             $reflection->implementsInterface(InjectableInterface::class)
123 123
             && $reflection->hasConstant('INJECTOR')
124
-        ) {
124
+        ){
125 125
             $const = $reflection->getConstant('INJECTOR');
126 126
             $this->bindInjector($class, $const);
127 127
 
@@ -129,12 +129,12 @@  discard block
 block discarded – undo
129 129
         }
130 130
 
131 131
         // check interfaces
132
-        foreach ($this->state->injectors as $target => $injector) {
132
+        foreach ($this->state->injectors as $target => $injector){
133 133
             if (
134 134
                 (\class_exists($target, true) && $reflection->isSubclassOf($target))
135 135
                 ||
136 136
                 (\interface_exists($target, true) && $reflection->implementsInterface($target))
137
-            ) {
137
+            ){
138 138
                 $this->state->bindings[$class] = new Injectable($injector);
139 139
 
140 140
                 return true;
@@ -161,15 +161,15 @@  discard block
 block discarded – undo
161 161
 
162 162
     private function makeConfigFromArray(array $resolver, bool $singleton): Binding
163 163
     {
164
-        if (\is_callable($resolver)) {
164
+        if (\is_callable($resolver)){
165 165
             return new Factory($resolver, $singleton);
166 166
         }
167 167
 
168 168
         // Validate lazy invokable array
169
-        if (!isset($resolver[0]) || !isset($resolver[1]) || !\is_string($resolver[1]) || $resolver[1] === '') {
169
+        if (!isset($resolver[0]) || !isset($resolver[1]) || !\is_string($resolver[1]) || $resolver[1] === ''){
170 170
             throw new InvalidArgumentException('Incompatible array declaration for resolver.');
171 171
         }
172
-        if ((!\is_string($resolver[0]) && !\is_object($resolver[0])) || $resolver[0] === '') {
172
+        if ((!\is_string($resolver[0]) && !\is_object($resolver[0])) || $resolver[0] === ''){
173 173
             throw new InvalidArgumentException('Incompatible array declaration for resolver.');
174 174
         }
175 175
 
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 
188 188
     private function setBinding(string $alias, Binding $config): void
189 189
     {
190
-        if (isset($this->state->singletons[$alias])) {
190
+        if (isset($this->state->singletons[$alias])){
191 191
             throw new SingletonOverloadException($alias);
192 192
         }
193 193
 
Please login to merge, or discard this patch.