Passed
Pull Request — master (#1222)
by Aleksei
10:55
created
src/Core/src/Internal/Proxy/ProxyClassRenderer.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -27,29 +27,29 @@  discard block
 block discarded – undo
27 27
             MagicCallTrait::class,
28 28
         ] : [];
29 29
 
30
-        if (\str_contains($className, '\\')) {
30
+        if (\str_contains($className, '\\')){
31 31
             $classShortName = \substr($className, \strrpos($className, '\\') + 1);
32
-            $classNamespaceStr = 'namespace ' . \substr($className, 0, \strrpos($className, '\\')) . ';';
33
-        } else {
32
+            $classNamespaceStr = 'namespace '.\substr($className, 0, \strrpos($className, '\\')).';';
33
+        }else{
34 34
             $classShortName = $className;
35 35
             $classNamespaceStr = '';
36 36
         }
37 37
 
38 38
         $interface = $type->getName();
39 39
         $classBody = [];
40
-        foreach ($type->getMethods() as $method) {
41
-            if ($method->isConstructor()) {
40
+        foreach ($type->getMethods() as $method){
41
+            if ($method->isConstructor()){
42 42
                 throw new \LogicException('Constructor is not allowed in a proxy.');
43 43
             }
44 44
 
45
-            if ($method->isDestructor()) {
45
+            if ($method->isDestructor()){
46 46
                 $classBody[] = self::renderMethod($method);
47 47
                 continue;
48 48
             }
49 49
 
50 50
             $hasRefs = false;
51
-            $return = $method->hasReturnType() && (string) $method->getReturnType() === 'void' ? '' : 'return ';
52
-            $call = ($method->isStatic() ? '::' : '->') . $method->getName();
51
+            $return = $method->hasReturnType() && (string)$method->getReturnType() === 'void' ? '' : 'return ';
52
+            $call = ($method->isStatic() ? '::' : '->').$method->getName();
53 53
             $context = $method->isStatic() ? 'null' : '$this->__container_proxy_context';
54 54
             $containerStr = match (false) {
55 55
                 $attachContainer => 'null',
@@ -69,12 +69,12 @@  discard block
 block discarded – undo
69 69
                 PHP;
70 70
 
71 71
             $args = [];
72
-            foreach ($method->getParameters() as $param) {
72
+            foreach ($method->getParameters() as $param){
73 73
                 $hasRefs = $hasRefs || $param->isPassedByReference();
74
-                $args[] = ($param->isVariadic() ? '...' : '') . '$' . $param->getName();
74
+                $args[] = ($param->isVariadic() ? '...' : '').'$'.$param->getName();
75 75
             }
76 76
 
77
-            if (!$hasRefs && !$method->isVariadic()) {
77
+            if (!$hasRefs && !$method->isVariadic()){
78 78
                 $classBody[] = self::renderMethod(
79 79
                     $method,
80 80
                     <<<PHP
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 
87 87
             $argsStr = \implode(', ', $args);
88 88
 
89
-            if ($method->isVariadic()) {
89
+            if ($method->isVariadic()){
90 90
                 $classBody[] = self::renderMethod(
91 91
                     $method,
92 92
                     <<<PHP
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 
109 109
         $traitsStr = $traits === [] ? '' : \implode(
110 110
             "\n    ",
111
-            \array_map(static fn(string $trait): string => 'use \\' . \ltrim($trait, '\\') . ';', $traits),
111
+            \array_map(static fn(string $trait) : string => 'use \\'.\ltrim($trait, '\\').';', $traits),
112 112
         );
113 113
         return <<<PHP
114 114
             $classNamespaceStr
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
             $m->getName(),
132 132
             \implode(', ', \array_map(self::renderParameter(...), $m->getParameters())),
133 133
             $m->hasReturnType()
134
-                ? ': ' . self::renderParameterTypes($m->getReturnType(), $m->getDeclaringClass())
134
+                ? ': '.self::renderParameterTypes($m->getReturnType(), $m->getDeclaringClass())
135 135
                 : '',
136 136
             $body,
137 137
         );
@@ -145,8 +145,8 @@  discard block
 block discarded – undo
145 145
                 $param->hasType() ? 'mixed' : '',
146 146
                 $param->isPassedByReference() ? '&' : '',
147 147
                 $param->isVariadic() ? '...' : '',
148
-                '$' . $param->getName(),
149
-                $param->isOptional() && !$param->isVariadic() ? ' = ' . self::renderDefaultValue($param) : '',
148
+                '$'.$param->getName(),
149
+                $param->isOptional() && !$param->isVariadic() ? ' = '.self::renderDefaultValue($param) : '',
150 150
             ),
151 151
             ' ',
152 152
         );
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
 
155 155
     public static function renderParameterTypes(\ReflectionType $types, \ReflectionClass $class): string
156 156
     {
157
-        if ($types instanceof \ReflectionNamedType) {
158
-            return ($types->allowsNull() && $types->getName() !== 'mixed' ? '?' : '') . ($types->isBuiltin()
157
+        if ($types instanceof \ReflectionNamedType){
158
+            return ($types->allowsNull() && $types->getName() !== 'mixed' ? '?' : '').($types->isBuiltin()
159 159
                     ? $types->getName()
160 160
                     : self::normalizeClassType($types, $class));
161 161
         }
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
         };
168 168
 
169 169
         $result = [];
170
-        foreach ($types as $type) {
170
+        foreach ($types as $type){
171 171
             $result[] = $type->isBuiltin()
172 172
                 ? $type->getName()
173 173
                 : self::normalizeClassType($type, $class);
@@ -178,12 +178,12 @@  discard block
 block discarded – undo
178 178
 
179 179
     public static function renderDefaultValue(\ReflectionParameter $param): string
180 180
     {
181
-        if ($param->isDefaultValueConstant()) {
181
+        if ($param->isDefaultValueConstant()){
182 182
             $result = $param->getDefaultValueConstantName();
183 183
 
184
-            return \explode('::', (string) $result)[0] === 'self'
184
+            return \explode('::', (string)$result)[0] === 'self'
185 185
                 ? $result
186
-                : '\\' . $result;
186
+                : '\\'.$result;
187 187
         }
188 188
 
189 189
         $cut = self::cutDefaultValue($param);
@@ -197,14 +197,14 @@  discard block
 block discarded – undo
197 197
     {
198 198
         return match($type->getName()) {
199 199
             'static' => 'static',
200
-            'self' => '\\' . $class->getName(),
201
-            default => '\\' . $type->getName(),
200
+            'self' => '\\'.$class->getName(),
201
+            default => '\\'.$type->getName(),
202 202
         };
203 203
     }
204 204
 
205 205
     private static function cutDefaultValue(\ReflectionParameter $param): string
206 206
     {
207
-        $string = (string) $param;
207
+        $string = (string)$param;
208 208
 
209 209
         return \trim(\substr($string, \strpos($string, '=') + 1, -1));
210 210
     }
Please login to merge, or discard this patch.