Passed
Pull Request — master (#1045)
by Aleksei
20:34 queued 09:02
created
src/Core/src/Internal/Proxy/ProxyClassRenderer.php 2 patches
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -27,24 +27,24 @@  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 45
             $hasRefs = false;
46 46
             $return = $method->hasReturnType() && (string)$method->getReturnType() === 'void' ? '' : 'return ';
47
-            $call = ($method->isStatic() ? '::' : '->') . $method->getName();
47
+            $call = ($method->isStatic() ? '::' : '->').$method->getName();
48 48
             $context = $method->isStatic() ? 'null' : '$this->__container_proxy_context';
49 49
             $containerStr = match (false) {
50 50
                 $attachContainer => 'null',
@@ -64,12 +64,12 @@  discard block
 block discarded – undo
64 64
                 PHP;
65 65
 
66 66
             $args = [];
67
-            foreach ($method->getParameters() as $param) {
67
+            foreach ($method->getParameters() as $param){
68 68
                 $hasRefs = $hasRefs || $param->isPassedByReference();
69
-                $args[] = ($param->isVariadic() ? '...' : '') . '$' . $param->getName();
69
+                $args[] = ($param->isVariadic() ? '...' : '').'$'.$param->getName();
70 70
             }
71 71
 
72
-            if (!$hasRefs && !$method->isVariadic()) {
72
+            if (!$hasRefs && !$method->isVariadic()){
73 73
                 $classBody[] = self::renderMethod(
74 74
                     $method,
75 75
                     <<<PHP
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 
82 82
             $argsStr = \implode(', ', $args);
83 83
 
84
-            if ($method->isVariadic()) {
84
+            if ($method->isVariadic()){
85 85
                 $classBody[] = self::renderMethod(
86 86
                     $method,
87 87
                     <<<PHP
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 
104 104
         $traitsStr = $traits === [] ? '' : \implode(
105 105
             "\n    ",
106
-            \array_map(fn (string $trait): string => 'use \\' . \ltrim($trait, '\\') . ';', $traits)
106
+            \array_map(fn (string $trait) : string => 'use \\'.\ltrim($trait, '\\').';', $traits)
107 107
         );
108 108
         return <<<PHP
109 109
             $classNamespaceStr
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
             $m->getName(),
127 127
             \implode(', ', \array_map([self::class, 'renderParameter'], $m->getParameters())),
128 128
             $m->hasReturnType()
129
-                ? ': ' . self::renderParameterTypes($m->getReturnType(), $m->getDeclaringClass())
129
+                ? ': '.self::renderParameterTypes($m->getReturnType(), $m->getDeclaringClass())
130 130
                 : '',
131 131
             $body,
132 132
         );
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
                 $param->hasType() ? self::renderParameterTypes($param->getType(), $param->getDeclaringClass()) : '',
141 141
                 $param->isPassedByReference() ? '&' : '',
142 142
                 $param->isVariadic() ? '...' : '',
143
-                '$' . $param->getName(),
144
-                $param->isOptional() && !$param->isVariadic() ? ' = ' . self::renderDefaultValue($param) : '',
143
+                '$'.$param->getName(),
144
+                $param->isOptional() && !$param->isVariadic() ? ' = '.self::renderDefaultValue($param) : '',
145 145
             ),
146 146
             ' '
147 147
         );
@@ -149,8 +149,8 @@  discard block
 block discarded – undo
149 149
 
150 150
     public static function renderParameterTypes(\ReflectionType $types, \ReflectionClass $class): string
151 151
     {
152
-        if ($types instanceof \ReflectionNamedType) {
153
-            return ($types->allowsNull() && $types->getName() !== 'mixed' ? '?' : '') . ($types->isBuiltin()
152
+        if ($types instanceof \ReflectionNamedType){
153
+            return ($types->allowsNull() && $types->getName() !== 'mixed' ? '?' : '').($types->isBuiltin()
154 154
                     ? $types->getName()
155 155
                     : self::normalizeClassType($types, $class));
156 156
         }
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
         };
163 163
 
164 164
         $result = [];
165
-        foreach ($types as $type) {
165
+        foreach ($types as $type){
166 166
             $result[] = $type->isBuiltin()
167 167
                 ? $type->getName()
168 168
                 : self::normalizeClassType($type, $class);
@@ -173,12 +173,12 @@  discard block
 block discarded – undo
173 173
 
174 174
     public static function renderDefaultValue(\ReflectionParameter $param): string
175 175
     {
176
-        if ($param->isDefaultValueConstant()) {
176
+        if ($param->isDefaultValueConstant()){
177 177
             $result = $param->getDefaultValueConstantName();
178 178
 
179 179
             return \explode('::', $result)[0] === 'self'
180 180
                 ? $result
181
-                : '\\' . $result;
181
+                : '\\'.$result;
182 182
         }
183 183
 
184 184
         $cut = self::cutDefaultValue($param);
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 
191 191
     public static function normalizeClassType(\ReflectionNamedType $type, \ReflectionClass $class): string
192 192
     {
193
-        return '\\' . ($type->getName() === 'self' ? $class->getName() : $type->getName());
193
+        return '\\'.($type->getName() === 'self' ? $class->getName() : $type->getName());
194 194
     }
195 195
 
196 196
     private static function cutDefaultValue(\ReflectionParameter $param): string
Please login to merge, or discard this patch.
Braces   +21 added lines, -10 removed lines patch added patch discarded remove patch
@@ -27,18 +27,23 @@  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 32
             $classShortName = \substr($className, \strrpos($className, '\\') + 1);
32 33
             $classNamespaceStr = 'namespace ' . \substr($className, 0, \strrpos($className, '\\')) . ';';
33
-        } else {
34
+        }
35
+        else
36
+        {
34 37
             $classShortName = $className;
35 38
             $classNamespaceStr = '';
36 39
         }
37 40
 
38 41
         $interface = $type->getName();
39 42
         $classBody = [];
40
-        foreach ($type->getMethods() as $method) {
41
-            if ($method->isConstructor()) {
43
+        foreach ($type->getMethods() as $method)
44
+        {
45
+            if ($method->isConstructor())
46
+            {
42 47
                 throw new \LogicException('Constructor is not allowed in a proxy.');
43 48
             }
44 49
 
@@ -64,12 +69,14 @@  discard block
 block discarded – undo
64 69
                 PHP;
65 70
 
66 71
             $args = [];
67
-            foreach ($method->getParameters() as $param) {
72
+            foreach ($method->getParameters() as $param)
73
+            {
68 74
                 $hasRefs = $hasRefs || $param->isPassedByReference();
69 75
                 $args[] = ($param->isVariadic() ? '...' : '') . '$' . $param->getName();
70 76
             }
71 77
 
72
-            if (!$hasRefs && !$method->isVariadic()) {
78
+            if (!$hasRefs && !$method->isVariadic())
79
+            {
73 80
                 $classBody[] = self::renderMethod(
74 81
                     $method,
75 82
                     <<<PHP
@@ -81,7 +88,8 @@  discard block
 block discarded – undo
81 88
 
82 89
             $argsStr = \implode(', ', $args);
83 90
 
84
-            if ($method->isVariadic()) {
91
+            if ($method->isVariadic())
92
+            {
85 93
                 $classBody[] = self::renderMethod(
86 94
                     $method,
87 95
                     <<<PHP
@@ -149,7 +157,8 @@  discard block
 block discarded – undo
149 157
 
150 158
     public static function renderParameterTypes(\ReflectionType $types, \ReflectionClass $class): string
151 159
     {
152
-        if ($types instanceof \ReflectionNamedType) {
160
+        if ($types instanceof \ReflectionNamedType)
161
+        {
153 162
             return ($types->allowsNull() && $types->getName() !== 'mixed' ? '?' : '') . ($types->isBuiltin()
154 163
                     ? $types->getName()
155 164
                     : self::normalizeClassType($types, $class));
@@ -162,7 +171,8 @@  discard block
 block discarded – undo
162 171
         };
163 172
 
164 173
         $result = [];
165
-        foreach ($types as $type) {
174
+        foreach ($types as $type)
175
+        {
166 176
             $result[] = $type->isBuiltin()
167 177
                 ? $type->getName()
168 178
                 : self::normalizeClassType($type, $class);
@@ -173,7 +183,8 @@  discard block
 block discarded – undo
173 183
 
174 184
     public static function renderDefaultValue(\ReflectionParameter $param): string
175 185
     {
176
-        if ($param->isDefaultValueConstant()) {
186
+        if ($param->isDefaultValueConstant())
187
+        {
177 188
             $result = $param->getDefaultValueConstantName();
178 189
 
179 190
             return \explode('::', $result)[0] === 'self'
Please login to merge, or discard this patch.