| Conditions | 1 | 
| Paths | 1 | 
| Total Lines | 185 | 
| Code Lines | 120 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php  | 
            ||
| 64 | public function jsonDataProvider(): array  | 
            ||
| 65 |     { | 
            ||
| 66 | $objectWithClosureInProperty = new stdClass();  | 
            ||
| 67 | // @formatter:off  | 
            ||
| 68 | $objectWithClosureInProperty->a = fn () => 1;  | 
            ||
| 69 | // @formatter:on  | 
            ||
| 70 | $objectWithClosureInPropertyId = spl_object_id($objectWithClosureInProperty);  | 
            ||
| 71 | $objectWithClosureInPropertyClosureId = spl_object_id($objectWithClosureInProperty->a);  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 72 | |||
| 73 | $emptyObject = new stdClass();  | 
            ||
| 74 | $emptyObjectId = spl_object_id($emptyObject);  | 
            ||
| 75 | |||
| 76 | // @formatter:off  | 
            ||
| 77 | $shortFunctionObject = fn () => 1;  | 
            ||
| 78 | // @formatter:on  | 
            ||
| 79 | $shortFunctionObjectId = spl_object_id($shortFunctionObject);  | 
            ||
| 80 | |||
| 81 | // @formatter:off  | 
            ||
| 82 | $staticShortFunctionObject = static fn () => 1;  | 
            ||
| 83 | // @formatter:on  | 
            ||
| 84 | $staticShortFunctionObjectId = spl_object_id($staticShortFunctionObject);  | 
            ||
| 85 | |||
| 86 | // @formatter:off  | 
            ||
| 87 |         $functionObject = function () { | 
            ||
| 88 | return 1;  | 
            ||
| 89 | };  | 
            ||
| 90 | // @formatter:on  | 
            ||
| 91 | $functionObjectId = spl_object_id($functionObject);  | 
            ||
| 92 | |||
| 93 | // @formatter:off  | 
            ||
| 94 |         $staticFunctionObject = static function () { | 
            ||
| 95 | return 1;  | 
            ||
| 96 | };  | 
            ||
| 97 | // @formatter:on  | 
            ||
| 98 | $staticFunctionObjectId = spl_object_id($staticFunctionObject);  | 
            ||
| 99 | |||
| 100 | // @formatter:off  | 
            ||
| 101 | $closureWithNullCollisionOperatorObject = fn () => $_ENV['var'] ?? null;  | 
            ||
| 102 | // @formatter:on  | 
            ||
| 103 | $closureWithNullCollisionOperatorObjectId = spl_object_id($closureWithNullCollisionOperatorObject);  | 
            ||
| 104 | |||
| 105 | // @formatter:off  | 
            ||
| 106 |         $closureWithUsualClassNameObject = fn (Dumper $date) => new \DateTimeZone(''); | 
            ||
| 107 | // @formatter:on  | 
            ||
| 108 | $closureWithUsualClassNameObjectId = spl_object_id($closureWithUsualClassNameObject);  | 
            ||
| 109 | |||
| 110 | // @formatter:off  | 
            ||
| 111 |         $closureWithAliasedClassNameObject = fn (Dumper $date) => new \DateTimeZone(''); | 
            ||
| 112 | // @formatter:on  | 
            ||
| 113 | $closureWithAliasedClassNameObjectId = spl_object_id($closureWithAliasedClassNameObject);  | 
            ||
| 114 | |||
| 115 | // @formatter:off  | 
            ||
| 116 |         $closureWithAliasedNamespaceObject = fn (D\Dumper $date) => new \DateTimeZone(''); | 
            ||
| 117 | // @formatter:on  | 
            ||
| 118 | $closureWithAliasedNamespaceObjectId = spl_object_id($closureWithAliasedNamespaceObject);  | 
            ||
| 119 | |||
| 120 | // @formatter:off  | 
            ||
| 121 |         $closureInArrayObject = fn () => new \DateTimeZone(''); | 
            ||
| 122 | // @formatter:on  | 
            ||
| 123 | $closureInArrayObjectId = spl_object_id($closureInArrayObject);  | 
            ||
| 124 | |||
| 125 | return [  | 
            ||
| 126 | 'empty object' => [  | 
            ||
| 127 | $emptyObject,  | 
            ||
| 128 | <<<S  | 
            ||
| 129 |                 {"stdClass#{$emptyObjectId}":"{stateless object}"} | 
            ||
| 130 | S,  | 
            ||
| 131 | ],  | 
            ||
| 132 | 'short function' => [  | 
            ||
| 133 | $shortFunctionObject,  | 
            ||
| 134 | <<<S  | 
            ||
| 135 |                 {"Closure#{$shortFunctionObjectId}":"fn () => 1"} | 
            ||
| 136 | S,  | 
            ||
| 137 | ],  | 
            ||
| 138 | 'short static function' => [  | 
            ||
| 139 | $staticShortFunctionObject,  | 
            ||
| 140 | <<<S  | 
            ||
| 141 |                 {"Closure#{$staticShortFunctionObjectId}":"static fn () => 1"} | 
            ||
| 142 | S,  | 
            ||
| 143 | ],  | 
            ||
| 144 | 'function' => [  | 
            ||
| 145 | $functionObject,  | 
            ||
| 146 | <<<S  | 
            ||
| 147 |                 {"Closure#{$functionObjectId}":"function () {\\n            return 1;\\n        }"} | 
            ||
| 148 | S,  | 
            ||
| 149 | ],  | 
            ||
| 150 | 'static function' => [  | 
            ||
| 151 | $staticFunctionObject,  | 
            ||
| 152 | <<<S  | 
            ||
| 153 |                 {"Closure#{$staticFunctionObjectId}":"static function () {\\n            return 1;\\n        }"} | 
            ||
| 154 | S,  | 
            ||
| 155 | ],  | 
            ||
| 156 | 'string' => [  | 
            ||
| 157 | 'Hello, Yii!',  | 
            ||
| 158 | '"Hello, Yii!"',  | 
            ||
| 159 | ],  | 
            ||
| 160 | 'empty string' => [  | 
            ||
| 161 | '',  | 
            ||
| 162 | '""',  | 
            ||
| 163 | ],  | 
            ||
| 164 | 'null' => [  | 
            ||
| 165 | null,  | 
            ||
| 166 | 'null',  | 
            ||
| 167 | ],  | 
            ||
| 168 | 'integer' => [  | 
            ||
| 169 | 1,  | 
            ||
| 170 | '1',  | 
            ||
| 171 | ],  | 
            ||
| 172 | 'integer with separator' => [  | 
            ||
| 173 | 1_23_456,  | 
            ||
| 174 | '123456',  | 
            ||
| 175 | ],  | 
            ||
| 176 | 'boolean' => [  | 
            ||
| 177 | true,  | 
            ||
| 178 | 'true',  | 
            ||
| 179 | ],  | 
            ||
| 180 | 'resource' => [  | 
            ||
| 181 |                 fopen('php://input', 'rb'), | 
            ||
| 182 |                 '{"timed_out":false,"blocked":true,"eof":false,"wrapper_type":"PHP","stream_type":"Input","mode":"rb","unread_bytes":0,"seekable":true,"uri":"php:\/\/input"}', | 
            ||
| 183 | ],  | 
            ||
| 184 | 'empty array' => [  | 
            ||
| 185 | [],  | 
            ||
| 186 | '[]',  | 
            ||
| 187 | ],  | 
            ||
| 188 | 'array of 3 elements, automatic keys' => [  | 
            ||
| 189 | [  | 
            ||
| 190 | 'one',  | 
            ||
| 191 | 'two',  | 
            ||
| 192 | 'three',  | 
            ||
| 193 | ],  | 
            ||
| 194 | '["one","two","three"]',  | 
            ||
| 195 | ],  | 
            ||
| 196 | 'array of 3 elements, custom keys' => [  | 
            ||
| 197 | [  | 
            ||
| 198 | 2 => 'one',  | 
            ||
| 199 | 'two' => 'two',  | 
            ||
| 200 | 0 => 'three',  | 
            ||
| 201 | ],  | 
            ||
| 202 |                 '{"2":"one","two":"two","0":"three"}', | 
            ||
| 203 | ],  | 
            ||
| 204 | 'closure in array' => [  | 
            ||
| 205 | // @formatter:off  | 
            ||
| 206 | [$closureInArrayObject],  | 
            ||
| 207 | // @formatter:on  | 
            ||
| 208 | <<<S  | 
            ||
| 209 |                 [{"Closure#{$closureInArrayObjectId}":"fn () => new \\\DateTimeZone('')"}] | 
            ||
| 210 | S,  | 
            ||
| 211 | ],  | 
            ||
| 212 | 'original class name' => [  | 
            ||
| 213 | $closureWithUsualClassNameObject,  | 
            ||
| 214 | <<<S  | 
            ||
| 215 |                 {"Closure#{$closureWithUsualClassNameObjectId}":"fn (\\\Yiisoft\\\Yii\\\Debug\\\Dumper \$date) => new \\\DateTimeZone('')"} | 
            ||
| 216 | S,  | 
            ||
| 217 | ],  | 
            ||
| 218 | 'class alias' => [  | 
            ||
| 219 | $closureWithAliasedClassNameObject,  | 
            ||
| 220 | <<<S  | 
            ||
| 221 |                 {"Closure#{$closureWithAliasedClassNameObjectId}":"fn (\\\Yiisoft\\\Yii\\\Debug\\\Dumper \$date) => new \\\DateTimeZone('')"} | 
            ||
| 222 | S,  | 
            ||
| 223 | ],  | 
            ||
| 224 | 'namespace alias' => [  | 
            ||
| 225 | $closureWithAliasedNamespaceObject,  | 
            ||
| 226 | <<<S  | 
            ||
| 227 |                 {"Closure#{$closureWithAliasedNamespaceObjectId}":"fn (\\\Yiisoft\\\Yii\\\Debug\\\Dumper \$date) => new \\\DateTimeZone('')"} | 
            ||
| 228 | S,  | 
            ||
| 229 | ],  | 
            ||
| 230 | 'closure with null-collision operator' => [  | 
            ||
| 231 | $closureWithNullCollisionOperatorObject,  | 
            ||
| 232 | <<<S  | 
            ||
| 233 |                 {"Closure#{$closureWithNullCollisionOperatorObjectId}":"fn () => \$_ENV['var'] ?? null"} | 
            ||
| 234 | S,  | 
            ||
| 235 | ],  | 
            ||
| 236 | 'utf8 supported' => [  | 
            ||
| 237 | '🤣',  | 
            ||
| 238 | '"🤣"',  | 
            ||
| 239 | ],  | 
            ||
| 240 | 'closure in property supported' => [  | 
            ||
| 241 | $objectWithClosureInProperty,  | 
            ||
| 242 | <<<S  | 
            ||
| 243 |                 {"stdClass#{$objectWithClosureInPropertyId}":{"public \$a":{"Closure#{$objectWithClosureInPropertyClosureId}":"fn () => 1"}}} | 
            ||
| 244 | S,  | 
            ||
| 245 | ],  | 
            ||
| 246 | 'binary string' => [  | 
            ||
| 247 |                 pack('H*', md5('binary string')), | 
            ||
| 248 | '"ɍ��^��\u00191\u0017�]�-f�"',  | 
            ||
| 249 | ],  | 
            ||
| 267 |