Completed
Push — master ( 3f6dc1...16ccd5 )
by Lars
01:39
created
src/Arrayy.php 1 patch
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
      */
308 308
     public function appendImmutable($value, $key = null): self
309 309
     {
310
-        $generator = function () use ($key, $value): \Generator {
310
+        $generator = function() use ($key, $value): \Generator {
311 311
             if ($this->properties !== []) {
312 312
                 $this->checkType($key, $value);
313 313
             }
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
                  */
697 697
                 $this->callAtPath(
698 698
                     $containerPath,
699
-                    static function ($container) use ($lastOffset, &$offsetExists) {
699
+                    static function($container) use ($lastOffset, &$offsetExists) {
700 700
                         $offsetExists = \array_key_exists($lastOffset, $container);
701 701
                     }
702 702
                 );
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
                  */
800 800
                 $this->callAtPath(
801 801
                     \implode($this->pathSeparator, $path),
802
-                    static function (&$offset) use ($pathToUnset) {
802
+                    static function(&$offset) use ($pathToUnset) {
803 803
                         if (\is_array($offset)) {
804 804
                             unset($offset[$pathToUnset]);
805 805
                         } else {
@@ -853,7 +853,7 @@  discard block
 block discarded – undo
853 853
         }
854 854
 
855 855
         if (\strpos($iteratorClass, '\\') === 0) {
856
-            $iteratorClass = '\\' . $iteratorClass;
856
+            $iteratorClass = '\\'.$iteratorClass;
857 857
             if (\class_exists($iteratorClass)) {
858 858
                 /**
859 859
                  * @psalm-suppress PropertyTypeCoercion
@@ -864,7 +864,7 @@  discard block
 block discarded – undo
864 864
             }
865 865
         }
866 866
 
867
-        throw new \InvalidArgumentException('The iterator class does not exist: ' . $iteratorClass);
867
+        throw new \InvalidArgumentException('The iterator class does not exist: '.$iteratorClass);
868 868
     }
869 869
 
870 870
     /**
@@ -1039,13 +1039,13 @@  discard block
 block discarded – undo
1039 1039
 
1040 1040
         foreach ($this->getGenerator() as $key => $item) {
1041 1041
             if ($item instanceof self) {
1042
-                $result[$prefix . $key] = $item->appendToEachKey($prefix);
1042
+                $result[$prefix.$key] = $item->appendToEachKey($prefix);
1043 1043
             } elseif (\is_array($item)) {
1044
-                $result[$prefix . $key] = self::create($item, $this->iteratorClass, false)
1044
+                $result[$prefix.$key] = self::create($item, $this->iteratorClass, false)
1045 1045
                     ->appendToEachKey($prefix)
1046 1046
                     ->toArray();
1047 1047
             } else {
1048
-                $result[$prefix . $key] = $item;
1048
+                $result[$prefix.$key] = $item;
1049 1049
             }
1050 1050
         }
1051 1051
 
@@ -1076,7 +1076,7 @@  discard block
 block discarded – undo
1076 1076
             } elseif (\is_object($item) === true) {
1077 1077
                 $result[$key] = $item;
1078 1078
             } else {
1079
-                $result[$key] = $prefix . $item;
1079
+                $result[$key] = $prefix.$item;
1080 1080
             }
1081 1081
         }
1082 1082
 
@@ -1284,7 +1284,7 @@  discard block
 block discarded – undo
1284 1284
     public function clean(): self
1285 1285
     {
1286 1286
         return $this->filter(
1287
-            static function ($value) {
1287
+            static function($value) {
1288 1288
                 return (bool) $value;
1289 1289
             }
1290 1290
         );
@@ -1615,9 +1615,9 @@  discard block
 block discarded – undo
1615 1615
 
1616 1616
         foreach ($items as $key => $value) {
1617 1617
             if (\is_array($value) && !empty($value)) {
1618
-                $flatten[] = $this->flatten($delimiter, $prepend . $key . $delimiter, $value);
1618
+                $flatten[] = $this->flatten($delimiter, $prepend.$key.$delimiter, $value);
1619 1619
             } else {
1620
-                $flatten[] = [$prepend . $key => $value];
1620
+                $flatten[] = [$prepend.$key => $value];
1621 1621
             }
1622 1622
         }
1623 1623
 
@@ -1795,7 +1795,7 @@  discard block
 block discarded – undo
1795 1795
          */
1796 1796
         \array_walk(
1797 1797
             $array,
1798
-            static function (&$val) {
1798
+            static function(&$val) {
1799 1799
                 if ((string) $val === $val) {
1800 1800
                     $val = \trim($val);
1801 1801
                 }
@@ -2327,7 +2327,7 @@  discard block
 block discarded – undo
2327 2327
         }
2328 2328
 
2329 2329
         if ($flag === \ARRAY_FILTER_USE_KEY) {
2330
-            $generator = function () use ($closure) {
2330
+            $generator = function() use ($closure) {
2331 2331
                 foreach ($this->getGenerator() as $key => $value) {
2332 2332
                     if ($closure($key) === true) {
2333 2333
                         yield $key => $value;
@@ -2335,7 +2335,7 @@  discard block
 block discarded – undo
2335 2335
                 }
2336 2336
             };
2337 2337
         } elseif ($flag === \ARRAY_FILTER_USE_BOTH) {
2338
-            $generator = function () use ($closure) {
2338
+            $generator = function() use ($closure) {
2339 2339
                 foreach ($this->getGenerator() as $key => $value) {
2340 2340
                     if ($closure($value, $key) === true) {
2341 2341
                         yield $key => $value;
@@ -2343,7 +2343,7 @@  discard block
 block discarded – undo
2343 2343
                 }
2344 2344
             };
2345 2345
         } else {
2346
-            $generator = function () use ($closure) {
2346
+            $generator = function() use ($closure) {
2347 2347
                 foreach ($this->getGenerator() as $key => $value) {
2348 2348
                     if ($closure($value) === true) {
2349 2349
                         yield $key => $value;
@@ -2398,40 +2398,40 @@  discard block
 block discarded – undo
2398 2398
         }
2399 2399
 
2400 2400
         $ops = [
2401
-            'eq' => static function ($item, $prop, $value): bool {
2401
+            'eq' => static function($item, $prop, $value): bool {
2402 2402
                 return $item[$prop] === $value;
2403 2403
             },
2404
-            'gt' => static function ($item, $prop, $value): bool {
2404
+            'gt' => static function($item, $prop, $value): bool {
2405 2405
                 return $item[$prop] > $value;
2406 2406
             },
2407
-            'ge' => static function ($item, $prop, $value): bool {
2407
+            'ge' => static function($item, $prop, $value): bool {
2408 2408
                 return $item[$prop] >= $value;
2409 2409
             },
2410
-            'gte' => static function ($item, $prop, $value): bool {
2410
+            'gte' => static function($item, $prop, $value): bool {
2411 2411
                 return $item[$prop] >= $value;
2412 2412
             },
2413
-            'lt' => static function ($item, $prop, $value): bool {
2413
+            'lt' => static function($item, $prop, $value): bool {
2414 2414
                 return $item[$prop] < $value;
2415 2415
             },
2416
-            'le' => static function ($item, $prop, $value): bool {
2416
+            'le' => static function($item, $prop, $value): bool {
2417 2417
                 return $item[$prop] <= $value;
2418 2418
             },
2419
-            'lte' => static function ($item, $prop, $value): bool {
2419
+            'lte' => static function($item, $prop, $value): bool {
2420 2420
                 return $item[$prop] <= $value;
2421 2421
             },
2422
-            'ne' => static function ($item, $prop, $value): bool {
2422
+            'ne' => static function($item, $prop, $value): bool {
2423 2423
                 return $item[$prop] !== $value;
2424 2424
             },
2425
-            'contains' => static function ($item, $prop, $value): bool {
2425
+            'contains' => static function($item, $prop, $value): bool {
2426 2426
                 return \in_array($item[$prop], (array) $value, true);
2427 2427
             },
2428
-            'notContains' => static function ($item, $prop, $value): bool {
2428
+            'notContains' => static function($item, $prop, $value): bool {
2429 2429
                 return !\in_array($item[$prop], (array) $value, true);
2430 2430
             },
2431
-            'newer' => static function ($item, $prop, $value): bool {
2431
+            'newer' => static function($item, $prop, $value): bool {
2432 2432
                 return \strtotime($item[$prop]) > \strtotime($value);
2433 2433
             },
2434
-            'older' => static function ($item, $prop, $value): bool {
2434
+            'older' => static function($item, $prop, $value): bool {
2435 2435
                 return \strtotime($item[$prop]) < \strtotime($value);
2436 2436
             },
2437 2437
         ];
@@ -2439,7 +2439,7 @@  discard block
 block discarded – undo
2439 2439
         $result = \array_values(
2440 2440
             \array_filter(
2441 2441
                 $this->toArray(false, true),
2442
-                static function ($item) use (
2442
+                static function($item) use (
2443 2443
                     $property,
2444 2444
                     $value,
2445 2445
                     $ops,
@@ -2653,7 +2653,7 @@  discard block
 block discarded – undo
2653 2653
      */
2654 2654
     public function flip(): self
2655 2655
     {
2656
-        $generator = function (): \Generator {
2656
+        $generator = function(): \Generator {
2657 2657
             foreach ($this->getGenerator() as $key => $value) {
2658 2658
                 yield (string) $value => $key;
2659 2659
             }
@@ -2914,9 +2914,9 @@  discard block
 block discarded – undo
2914 2914
         $jsonObject = \json_decode($json, false);
2915 2915
 
2916 2916
         $mapper = new \Arrayy\Mapper\Json();
2917
-        $mapper->undefinedPropertyHandler = static function ($object, $key, $jsonValue) use ($class) {
2917
+        $mapper->undefinedPropertyHandler = static function($object, $key, $jsonValue) use ($class) {
2918 2918
             if ($class->checkPropertiesMismatchInConstructor) {
2919
-                throw new \TypeError('Property mismatch - input: ' . \print_r(['key' => $key, 'jsonValue' => $jsonValue], true) . ' for object: ' . \get_class($object));
2919
+                throw new \TypeError('Property mismatch - input: '.\print_r(['key' => $key, 'jsonValue' => $jsonValue], true).' for object: '.\get_class($object));
2920 2920
             }
2921 2921
         };
2922 2922
 
@@ -3285,7 +3285,7 @@  discard block
 block discarded – undo
3285 3285
      */
3286 3286
     public function implode(string $glue = '', string $prefix = ''): string
3287 3287
     {
3288
-        return $prefix . $this->implode_recursive($glue, $this->toArray(), false);
3288
+        return $prefix.$this->implode_recursive($glue, $this->toArray(), false);
3289 3289
     }
3290 3290
 
3291 3291
     /**
@@ -3394,7 +3394,7 @@  discard block
 block discarded – undo
3394 3394
                 \array_uintersect(
3395 3395
                     $this->toArray(),
3396 3396
                     $search,
3397
-                    static function ($a, $b) {
3397
+                    static function($a, $b) {
3398 3398
                         return $a === $b ? 0 : -1;
3399 3399
                     }
3400 3400
                 ),
@@ -3730,13 +3730,13 @@  discard block
 block discarded – undo
3730 3730
         // non recursive
3731 3731
 
3732 3732
         if ($search_values === null) {
3733
-            $arrayFunction = function (): \Generator {
3733
+            $arrayFunction = function(): \Generator {
3734 3734
                 foreach ($this->getGenerator() as $key => $value) {
3735 3735
                     yield $key;
3736 3736
                 }
3737 3737
             };
3738 3738
         } else {
3739
-            $arrayFunction = function () use ($search_values, $strict): \Generator {
3739
+            $arrayFunction = function() use ($search_values, $strict): \Generator {
3740 3740
                 $is_array_tmp = \is_array($search_values);
3741 3741
 
3742 3742
                 /** @noinspection PhpParameterByRefIsNotUsedAsReferenceInspection */
@@ -3976,7 +3976,7 @@  discard block
 block discarded – undo
3976 3976
         $useArguments = \func_num_args() > 2;
3977 3977
 
3978 3978
         return static::create(
3979
-            function () use ($useArguments, $callable, $useKeyAsSecondParameter, $arguments) {
3979
+            function() use ($useArguments, $callable, $useKeyAsSecondParameter, $arguments) {
3980 3980
                 foreach ($this->getGenerator() as $key => $value) {
3981 3981
                     if ($useArguments) {
3982 3982
                         if ($useKeyAsSecondParameter) {
@@ -4447,7 +4447,7 @@  discard block
 block discarded – undo
4447 4447
      */
4448 4448
     public function nth(int $step, int $offset = 0): self
4449 4449
     {
4450
-        $arrayFunction = function () use ($step, $offset): \Generator {
4450
+        $arrayFunction = function() use ($step, $offset): \Generator {
4451 4451
             $position = 0;
4452 4452
             foreach ($this->getGenerator() as $key => $value) {
4453 4453
                 if ($position++ % $step !== $offset) {
@@ -4481,7 +4481,7 @@  discard block
 block discarded – undo
4481 4481
     {
4482 4482
         $keys = \array_flip($keys);
4483 4483
 
4484
-        $generator = function () use ($keys): \Generator {
4484
+        $generator = function() use ($keys): \Generator {
4485 4485
             foreach ($this->getGenerator() as $key => $value) {
4486 4486
                 if (isset($keys[$key])) {
4487 4487
                     yield $key => $value;
@@ -4611,7 +4611,7 @@  discard block
 block discarded – undo
4611 4611
      */
4612 4612
     public function prependImmutable($value, $key = null)
4613 4613
     {
4614
-        $generator = function () use ($key, $value): \Generator {
4614
+        $generator = function() use ($key, $value): \Generator {
4615 4615
             if ($this->properties !== []) {
4616 4616
                 $this->checkType($key, $value);
4617 4617
             }
@@ -4662,7 +4662,7 @@  discard block
 block discarded – undo
4662 4662
                 )->prependToEachKey($suffix)
4663 4663
                     ->toArray();
4664 4664
             } else {
4665
-                $result[$key . $suffix] = $item;
4665
+                $result[$key.$suffix] = $item;
4666 4666
             }
4667 4667
         }
4668 4668
 
@@ -4702,7 +4702,7 @@  discard block
 block discarded – undo
4702 4702
             } elseif (\is_object($item) === true) {
4703 4703
                 $result[$key] = $item;
4704 4704
             } else {
4705
-                $result[$key] = $item . $suffix;
4705
+                $result[$key] = $item.$suffix;
4706 4706
             }
4707 4707
         }
4708 4708
 
@@ -5507,7 +5507,7 @@  discard block
 block discarded – undo
5507 5507
          * @psalm-suppress MissingClosureParamType
5508 5508
          */
5509 5509
         return $this->each(
5510
-            static function ($value) use ($search, $replacement) {
5510
+            static function($value) use ($search, $replacement) {
5511 5511
                 return \str_replace($search, $replacement, $value);
5512 5512
             }
5513 5513
         );
@@ -6191,7 +6191,7 @@  discard block
 block discarded – undo
6191 6191
              * @psalm-suppress MissingClosureParamType
6192 6192
              */
6193 6193
             $results = $arrayy->each(
6194
-                static function ($value) use ($sorter) {
6194
+                static function($value) use ($sorter) {
6195 6195
                     if (\is_callable($sorter) === true) {
6196 6196
                         return $sorter($value);
6197 6197
                     }
@@ -6264,7 +6264,7 @@  discard block
 block discarded – undo
6264 6264
     public function split(int $numberOfPieces = 2, bool $keepKeys = false): self
6265 6265
     {
6266 6266
         if ($keepKeys) {
6267
-            $generator = function () use ($numberOfPieces) {
6267
+            $generator = function() use ($numberOfPieces) {
6268 6268
                 $carry = [];
6269 6269
                 $i = 1;
6270 6270
                 foreach ($this->getGenerator() as $key => $value) {
@@ -6287,7 +6287,7 @@  discard block
 block discarded – undo
6287 6287
                 }
6288 6288
             };
6289 6289
         } else {
6290
-            $generator = function () use ($numberOfPieces) {
6290
+            $generator = function() use ($numberOfPieces) {
6291 6291
                 $carry = [];
6292 6292
                 $i = 1;
6293 6293
                 foreach ($this->getGenerator() as $key => $value) {
@@ -6334,7 +6334,7 @@  discard block
 block discarded – undo
6334 6334
     public function stripEmpty(): self
6335 6335
     {
6336 6336
         return $this->filter(
6337
-            static function ($item) {
6337
+            static function($item) {
6338 6338
                 if ($item === null) {
6339 6339
                     return false;
6340 6340
                 }
@@ -6538,7 +6538,7 @@  discard block
 block discarded – undo
6538 6538
          * @psalm-suppress MissingClosureParamType
6539 6539
          */
6540 6540
         $this->array = $this->reduce(
6541
-            static function ($resultArray, $value) {
6541
+            static function($resultArray, $value) {
6542 6542
                 if (!\in_array($value, $resultArray, true)) {
6543 6543
                     $resultArray[] = $value;
6544 6544
                 }
@@ -6577,7 +6577,7 @@  discard block
 block discarded – undo
6577 6577
          */
6578 6578
         $this->array = \array_reduce(
6579 6579
             \array_keys($array),
6580
-            static function ($resultArray, $key) use ($array) {
6580
+            static function($resultArray, $key) use ($array) {
6581 6581
                 if (!\in_array($array[$key], $resultArray, true)) {
6582 6582
                     $resultArray[$key] = $array[$key];
6583 6583
                 }
@@ -6662,7 +6662,7 @@  discard block
 block discarded – undo
6662 6662
     public function values(): self
6663 6663
     {
6664 6664
         return static::create(
6665
-            function () {
6665
+            function() {
6666 6666
                 /** @noinspection YieldFromCanBeUsedInspection */
6667 6667
                 foreach ($this->getGenerator() as $value) {
6668 6668
                     yield $value;
@@ -6739,7 +6739,7 @@  discard block
 block discarded – undo
6739 6739
     public function where(string $keyOrPropertyOrMethod, $value): self
6740 6740
     {
6741 6741
         return $this->filter(
6742
-            function ($item) use ($keyOrPropertyOrMethod, $value) {
6742
+            function($item) use ($keyOrPropertyOrMethod, $value) {
6743 6743
                 $accessorValue = $this->extractValue(
6744 6744
                     $item,
6745 6745
                     $keyOrPropertyOrMethod
@@ -7029,7 +7029,7 @@  discard block
 block discarded – undo
7029 7029
     protected function getPropertiesFromPhpDoc()
7030 7030
     {
7031 7031
         static $PROPERTY_CACHE = [];
7032
-        $cacheKey = 'Class::' . static::class;
7032
+        $cacheKey = 'Class::'.static::class;
7033 7033
 
7034 7034
         if (isset($PROPERTY_CACHE[$cacheKey])) {
7035 7035
             return $PROPERTY_CACHE[$cacheKey];
@@ -7335,7 +7335,7 @@  discard block
 block discarded – undo
7335 7335
         if ($array === null) {
7336 7336
             $array = [];
7337 7337
         } elseif (!\is_array($array)) {
7338
-            throw new \RuntimeException('Can not set value at this path "' . $key . '" because (' . \gettype($array) . ')"' . \print_r($array, true) . '" is not an array.');
7338
+            throw new \RuntimeException('Can not set value at this path "'.$key.'" because ('.\gettype($array).')"'.\print_r($array, true).'" is not an array.');
7339 7339
         }
7340 7340
 
7341 7341
         $array[$key] = $value;
@@ -7407,7 +7407,7 @@  discard block
 block discarded – undo
7407 7407
                 &&
7408 7408
                 \count(\array_diff_key($properties, $data)) > 0
7409 7409
             ) {
7410
-                throw new \TypeError('Property mismatch - input: ' . \print_r(\array_keys($data), true) . ' | expected: ' . \print_r(\array_keys($properties), true));
7410
+                throw new \TypeError('Property mismatch - input: '.\print_r(\array_keys($data), true).' | expected: '.\print_r(\array_keys($properties), true));
7411 7411
             }
7412 7412
 
7413 7413
             foreach ($data as $key => &$valueInner) {
@@ -7524,7 +7524,7 @@  discard block
 block discarded – undo
7524 7524
              *
7525 7525
              * @return void
7526 7526
              */
7527
-            static function (&$item) {
7527
+            static function(&$item) {
7528 7528
                 if ($item instanceof self) {
7529 7529
                     $item = $item->getArray();
7530 7530
                 }
@@ -7549,7 +7549,7 @@  discard block
 block discarded – undo
7549 7549
             &&
7550 7550
             $this->checkPropertiesMismatch === true
7551 7551
         ) {
7552
-            throw new \TypeError('The key "' . $key . '" does not exists as "@property" phpdoc. (' . \get_class($this) . ').');
7552
+            throw new \TypeError('The key "'.$key.'" does not exists as "@property" phpdoc. ('.\get_class($this).').');
7553 7553
         }
7554 7554
 
7555 7555
         if (isset($this->properties[self::ARRAYY_HELPER_TYPES_FOR_ALL_PROPERTIES])) {
Please login to merge, or discard this patch.