Completed
Push — master ( 1c1d16...f69cb7 )
by Lars
01:44
created
src/Arrayy.php 1 patch
Spacing   +63 added lines, -63 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
             }
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
                  */
690 690
                 $this->callAtPath(
691 691
                     $containerPath,
692
-                    static function ($container) use ($lastOffset, &$offsetExists) {
692
+                    static function($container) use ($lastOffset, &$offsetExists) {
693 693
                         $offsetExists = \array_key_exists($lastOffset, $container);
694 694
                     }
695 695
                 );
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
                  */
793 793
                 $this->callAtPath(
794 794
                     \implode($this->pathSeparator, $path),
795
-                    static function (&$offset) use ($pathToUnset) {
795
+                    static function(&$offset) use ($pathToUnset) {
796 796
                         if (\is_array($offset)) {
797 797
                             unset($offset[$pathToUnset]);
798 798
                         } else {
@@ -846,7 +846,7 @@  discard block
 block discarded – undo
846 846
         }
847 847
 
848 848
         if (\strpos($iteratorClass, '\\') === 0) {
849
-            $iteratorClass = '\\' . $iteratorClass;
849
+            $iteratorClass = '\\'.$iteratorClass;
850 850
             if (\class_exists($iteratorClass)) {
851 851
                 /**
852 852
                  * @psalm-suppress PropertyTypeCoercion
@@ -857,7 +857,7 @@  discard block
 block discarded – undo
857 857
             }
858 858
         }
859 859
 
860
-        throw new \InvalidArgumentException('The iterator class does not exist: ' . $iteratorClass);
860
+        throw new \InvalidArgumentException('The iterator class does not exist: '.$iteratorClass);
861 861
     }
862 862
 
863 863
     /**
@@ -1032,13 +1032,13 @@  discard block
 block discarded – undo
1032 1032
 
1033 1033
         foreach ($this->getGenerator() as $key => $item) {
1034 1034
             if ($item instanceof self) {
1035
-                $result[$prefix . $key] = $item->appendToEachKey($prefix);
1035
+                $result[$prefix.$key] = $item->appendToEachKey($prefix);
1036 1036
             } elseif (\is_array($item)) {
1037
-                $result[$prefix . $key] = self::create($item, $this->iteratorClass, false)
1037
+                $result[$prefix.$key] = self::create($item, $this->iteratorClass, false)
1038 1038
                     ->appendToEachKey($prefix)
1039 1039
                     ->toArray();
1040 1040
             } else {
1041
-                $result[$prefix . $key] = $item;
1041
+                $result[$prefix.$key] = $item;
1042 1042
             }
1043 1043
         }
1044 1044
 
@@ -1069,7 +1069,7 @@  discard block
 block discarded – undo
1069 1069
             } elseif (\is_object($item) === true) {
1070 1070
                 $result[$key] = $item;
1071 1071
             } else {
1072
-                $result[$key] = $prefix . $item;
1072
+                $result[$key] = $prefix.$item;
1073 1073
             }
1074 1074
         }
1075 1075
 
@@ -1255,7 +1255,7 @@  discard block
 block discarded – undo
1255 1255
     public function chunk($size, $preserveKeys = false): self
1256 1256
     {
1257 1257
         if ($preserveKeys) {
1258
-            $generator = function () use ($size) {
1258
+            $generator = function() use ($size) {
1259 1259
                 $values = [];
1260 1260
                 $tmpCounter = 0;
1261 1261
                 foreach ($this->getGenerator() as $key => $value) {
@@ -1275,7 +1275,7 @@  discard block
 block discarded – undo
1275 1275
                 }
1276 1276
             };
1277 1277
         } else {
1278
-            $generator = function () use ($size) {
1278
+            $generator = function() use ($size) {
1279 1279
                 $values = [];
1280 1280
                 $tmpCounter = 0;
1281 1281
                 foreach ($this->getGenerator() as $key => $value) {
@@ -1319,7 +1319,7 @@  discard block
 block discarded – undo
1319 1319
     public function clean(): self
1320 1320
     {
1321 1321
         return $this->filter(
1322
-            static function ($value) {
1322
+            static function($value) {
1323 1323
                 return (bool) $value;
1324 1324
             }
1325 1325
         );
@@ -1657,9 +1657,9 @@  discard block
 block discarded – undo
1657 1657
 
1658 1658
         foreach ($items as $key => $value) {
1659 1659
             if (\is_array($value) && $value !== []) {
1660
-                $flatten[] = $this->flatten($delimiter, $prepend . $key . $delimiter, $value);
1660
+                $flatten[] = $this->flatten($delimiter, $prepend.$key.$delimiter, $value);
1661 1661
             } else {
1662
-                $flatten[] = [$prepend . $key => $value];
1662
+                $flatten[] = [$prepend.$key => $value];
1663 1663
             }
1664 1664
         }
1665 1665
 
@@ -1837,7 +1837,7 @@  discard block
 block discarded – undo
1837 1837
          */
1838 1838
         \array_walk(
1839 1839
             $array,
1840
-            static function (&$val) {
1840
+            static function(&$val) {
1841 1841
                 if ((string) $val === $val) {
1842 1842
                     $val = \trim($val);
1843 1843
                 }
@@ -2059,7 +2059,7 @@  discard block
 block discarded – undo
2059 2059
             $array = $array[0];
2060 2060
         }
2061 2061
 
2062
-        $generator = function () use ($array): \Generator {
2062
+        $generator = function() use ($array): \Generator {
2063 2063
             foreach ($this->getGenerator() as $key => $value) {
2064 2064
                 if (\in_array($value, $array, true) === false) {
2065 2065
                     yield $key => $value;
@@ -2094,7 +2094,7 @@  discard block
 block discarded – undo
2094 2094
             $array = $array[0];
2095 2095
         }
2096 2096
 
2097
-        $generator = function () use ($array): \Generator {
2097
+        $generator = function() use ($array): \Generator {
2098 2098
             foreach ($this->getGenerator() as $key => $value) {
2099 2099
                 if (\array_key_exists($key, $array) === false) {
2100 2100
                     yield $key => $value;
@@ -2397,7 +2397,7 @@  discard block
 block discarded – undo
2397 2397
         }
2398 2398
 
2399 2399
         if ($flag === \ARRAY_FILTER_USE_KEY) {
2400
-            $generator = function () use ($closure) {
2400
+            $generator = function() use ($closure) {
2401 2401
                 foreach ($this->getGenerator() as $key => $value) {
2402 2402
                     if ($closure($key) === true) {
2403 2403
                         yield $key => $value;
@@ -2405,7 +2405,7 @@  discard block
 block discarded – undo
2405 2405
                 }
2406 2406
             };
2407 2407
         } elseif ($flag === \ARRAY_FILTER_USE_BOTH) {
2408
-            $generator = function () use ($closure) {
2408
+            $generator = function() use ($closure) {
2409 2409
                 foreach ($this->getGenerator() as $key => $value) {
2410 2410
                     if ($closure($value, $key) === true) {
2411 2411
                         yield $key => $value;
@@ -2413,7 +2413,7 @@  discard block
 block discarded – undo
2413 2413
                 }
2414 2414
             };
2415 2415
         } else {
2416
-            $generator = function () use ($closure) {
2416
+            $generator = function() use ($closure) {
2417 2417
                 foreach ($this->getGenerator() as $key => $value) {
2418 2418
                     if ($closure($value) === true) {
2419 2419
                         yield $key => $value;
@@ -2469,40 +2469,40 @@  discard block
 block discarded – undo
2469 2469
         }
2470 2470
 
2471 2471
         $ops = [
2472
-            'eq' => static function ($item, $prop, $value): bool {
2472
+            'eq' => static function($item, $prop, $value): bool {
2473 2473
                 return $item[$prop] === $value;
2474 2474
             },
2475
-            'gt' => static function ($item, $prop, $value): bool {
2475
+            'gt' => static function($item, $prop, $value): bool {
2476 2476
                 return $item[$prop] > $value;
2477 2477
             },
2478
-            'ge' => static function ($item, $prop, $value): bool {
2478
+            'ge' => static function($item, $prop, $value): bool {
2479 2479
                 return $item[$prop] >= $value;
2480 2480
             },
2481
-            'gte' => static function ($item, $prop, $value): bool {
2481
+            'gte' => static function($item, $prop, $value): bool {
2482 2482
                 return $item[$prop] >= $value;
2483 2483
             },
2484
-            'lt' => static function ($item, $prop, $value): bool {
2484
+            'lt' => static function($item, $prop, $value): bool {
2485 2485
                 return $item[$prop] < $value;
2486 2486
             },
2487
-            'le' => static function ($item, $prop, $value): bool {
2487
+            'le' => static function($item, $prop, $value): bool {
2488 2488
                 return $item[$prop] <= $value;
2489 2489
             },
2490
-            'lte' => static function ($item, $prop, $value): bool {
2490
+            'lte' => static function($item, $prop, $value): bool {
2491 2491
                 return $item[$prop] <= $value;
2492 2492
             },
2493
-            'ne' => static function ($item, $prop, $value): bool {
2493
+            'ne' => static function($item, $prop, $value): bool {
2494 2494
                 return $item[$prop] !== $value;
2495 2495
             },
2496
-            'contains' => static function ($item, $prop, $value): bool {
2496
+            'contains' => static function($item, $prop, $value): bool {
2497 2497
                 return \in_array($item[$prop], (array) $value, true);
2498 2498
             },
2499
-            'notContains' => static function ($item, $prop, $value): bool {
2499
+            'notContains' => static function($item, $prop, $value): bool {
2500 2500
                 return !\in_array($item[$prop], (array) $value, true);
2501 2501
             },
2502
-            'newer' => static function ($item, $prop, $value): bool {
2502
+            'newer' => static function($item, $prop, $value): bool {
2503 2503
                 return \strtotime($item[$prop]) > \strtotime($value);
2504 2504
             },
2505
-            'older' => static function ($item, $prop, $value): bool {
2505
+            'older' => static function($item, $prop, $value): bool {
2506 2506
                 return \strtotime($item[$prop]) < \strtotime($value);
2507 2507
             },
2508 2508
         ];
@@ -2510,7 +2510,7 @@  discard block
 block discarded – undo
2510 2510
         $result = \array_values(
2511 2511
             \array_filter(
2512 2512
                 $this->toArray(false, true),
2513
-                static function ($item) use (
2513
+                static function($item) use (
2514 2514
                     $property,
2515 2515
                     $value,
2516 2516
                     $ops,
@@ -2725,7 +2725,7 @@  discard block
 block discarded – undo
2725 2725
      */
2726 2726
     public function flip(): self
2727 2727
     {
2728
-        $generator = function (): \Generator {
2728
+        $generator = function(): \Generator {
2729 2729
             foreach ($this->getGenerator() as $key => $value) {
2730 2730
                 yield (string) $value => $key;
2731 2731
             }
@@ -2986,9 +2986,9 @@  discard block
 block discarded – undo
2986 2986
         $jsonObject = \json_decode($json, false);
2987 2987
 
2988 2988
         $mapper = new \Arrayy\Mapper\Json();
2989
-        $mapper->undefinedPropertyHandler = static function ($object, $key, $jsonValue) use ($class) {
2989
+        $mapper->undefinedPropertyHandler = static function($object, $key, $jsonValue) use ($class) {
2990 2990
             if ($class->checkPropertiesMismatchInConstructor) {
2991
-                throw new \TypeError('Property mismatch - input: ' . \print_r(['key' => $key, 'jsonValue' => $jsonValue], true) . ' for object: ' . \get_class($object));
2991
+                throw new \TypeError('Property mismatch - input: '.\print_r(['key' => $key, 'jsonValue' => $jsonValue], true).' for object: '.\get_class($object));
2992 2992
             }
2993 2993
         };
2994 2994
 
@@ -3053,13 +3053,13 @@  discard block
 block discarded – undo
3053 3053
     public function getColumn($columnKey = null, $indexKey = null): self
3054 3054
     {
3055 3055
         if ($columnKey === null && $indexKey === null) {
3056
-            $generator = function () {
3056
+            $generator = function() {
3057 3057
                 foreach ($this->getGenerator() as $key => $value) {
3058 3058
                     yield $value;
3059 3059
                 }
3060 3060
             };
3061 3061
         } else {
3062
-            $generator = function () use ($columnKey, $indexKey) {
3062
+            $generator = function() use ($columnKey, $indexKey) {
3063 3063
                 foreach ($this->getGenerator() as $key => $value) {
3064 3064
                     // reset
3065 3065
                     $newKey = null;
@@ -3359,7 +3359,7 @@  discard block
 block discarded – undo
3359 3359
 
3360 3360
         if ($UN_FOUND === null) {
3361 3361
             // Generate unique string to use as marker.
3362
-            $UN_FOUND = 'arrayy--' . \uniqid('arrayy', true);
3362
+            $UN_FOUND = 'arrayy--'.\uniqid('arrayy', true);
3363 3363
         }
3364 3364
 
3365 3365
         if (\is_array($key)) {
@@ -3409,7 +3409,7 @@  discard block
 block discarded – undo
3409 3409
      */
3410 3410
     public function implode(string $glue = '', string $prefix = ''): string
3411 3411
     {
3412
-        return $prefix . $this->implode_recursive($glue, $this->toArray(), false);
3412
+        return $prefix.$this->implode_recursive($glue, $this->toArray(), false);
3413 3413
     }
3414 3414
 
3415 3415
     /**
@@ -3518,7 +3518,7 @@  discard block
 block discarded – undo
3518 3518
                 \array_uintersect(
3519 3519
                     $this->toArray(),
3520 3520
                     $search,
3521
-                    static function ($a, $b) {
3521
+                    static function($a, $b) {
3522 3522
                         return $a === $b ? 0 : -1;
3523 3523
                     }
3524 3524
                 ),
@@ -3862,13 +3862,13 @@  discard block
 block discarded – undo
3862 3862
         // non recursive
3863 3863
 
3864 3864
         if ($search_values === null) {
3865
-            $arrayFunction = function (): \Generator {
3865
+            $arrayFunction = function(): \Generator {
3866 3866
                 foreach ($this->getGenerator() as $key => $value) {
3867 3867
                     yield $key;
3868 3868
                 }
3869 3869
             };
3870 3870
         } else {
3871
-            $arrayFunction = function () use ($search_values, $strict): \Generator {
3871
+            $arrayFunction = function() use ($search_values, $strict): \Generator {
3872 3872
                 $is_array_tmp = \is_array($search_values);
3873 3873
 
3874 3874
                 /** @noinspection PhpParameterByRefIsNotUsedAsReferenceInspection */
@@ -4112,7 +4112,7 @@  discard block
 block discarded – undo
4112 4112
         $useArguments = \func_num_args() > 2;
4113 4113
 
4114 4114
         return static::create(
4115
-            function () use ($useArguments, $callable, $useKeyAsSecondParameter, $arguments) {
4115
+            function() use ($useArguments, $callable, $useKeyAsSecondParameter, $arguments) {
4116 4116
                 foreach ($this->getGenerator() as $key => $value) {
4117 4117
                     if ($useArguments) {
4118 4118
                         if ($useKeyAsSecondParameter) {
@@ -4599,7 +4599,7 @@  discard block
 block discarded – undo
4599 4599
      */
4600 4600
     public function nth(int $step, int $offset = 0): self
4601 4601
     {
4602
-        $arrayFunction = function () use ($step, $offset): \Generator {
4602
+        $arrayFunction = function() use ($step, $offset): \Generator {
4603 4603
             $position = 0;
4604 4604
             foreach ($this->getGenerator() as $key => $value) {
4605 4605
                 if ($position++ % $step !== $offset) {
@@ -4633,7 +4633,7 @@  discard block
 block discarded – undo
4633 4633
     {
4634 4634
         $keys = \array_flip($keys);
4635 4635
 
4636
-        $generator = function () use ($keys): \Generator {
4636
+        $generator = function() use ($keys): \Generator {
4637 4637
             foreach ($this->getGenerator() as $key => $value) {
4638 4638
                 if (isset($keys[$key])) {
4639 4639
                     yield $key => $value;
@@ -4763,7 +4763,7 @@  discard block
 block discarded – undo
4763 4763
      */
4764 4764
     public function prependImmutable($value, $key = null)
4765 4765
     {
4766
-        $generator = function () use ($key, $value): \Generator {
4766
+        $generator = function() use ($key, $value): \Generator {
4767 4767
             if ($this->properties !== []) {
4768 4768
                 $this->checkType($key, $value);
4769 4769
             }
@@ -4814,7 +4814,7 @@  discard block
 block discarded – undo
4814 4814
                 )->prependToEachKey($suffix)
4815 4815
                     ->toArray();
4816 4816
             } else {
4817
-                $result[$key . $suffix] = $item;
4817
+                $result[$key.$suffix] = $item;
4818 4818
             }
4819 4819
         }
4820 4820
 
@@ -4854,7 +4854,7 @@  discard block
 block discarded – undo
4854 4854
             } elseif (\is_object($item) === true) {
4855 4855
                 $result[$key] = $item;
4856 4856
             } else {
4857
-                $result[$key] = $item . $suffix;
4857
+                $result[$key] = $item.$suffix;
4858 4858
             }
4859 4859
         }
4860 4860
 
@@ -5640,7 +5640,7 @@  discard block
 block discarded – undo
5640 5640
          * @psalm-suppress MissingClosureParamType
5641 5641
          */
5642 5642
         return $this->each(
5643
-            static function ($value) use ($search, $replacement) {
5643
+            static function($value) use ($search, $replacement) {
5644 5644
                 return \str_replace($search, $replacement, $value);
5645 5645
             }
5646 5646
         );
@@ -6324,7 +6324,7 @@  discard block
 block discarded – undo
6324 6324
              * @psalm-suppress MissingClosureParamType
6325 6325
              */
6326 6326
             $results = $arrayy->each(
6327
-                static function ($value) use ($sorter) {
6327
+                static function($value) use ($sorter) {
6328 6328
                     if (\is_callable($sorter) === true) {
6329 6329
                         return $sorter($value);
6330 6330
                     }
@@ -6397,7 +6397,7 @@  discard block
 block discarded – undo
6397 6397
     public function split(int $numberOfPieces = 2, bool $keepKeys = false): self
6398 6398
     {
6399 6399
         if ($keepKeys) {
6400
-            $generator = function () use ($numberOfPieces) {
6400
+            $generator = function() use ($numberOfPieces) {
6401 6401
                 $carry = [];
6402 6402
                 $i = 1;
6403 6403
                 foreach ($this->getGenerator() as $key => $value) {
@@ -6420,7 +6420,7 @@  discard block
 block discarded – undo
6420 6420
                 }
6421 6421
             };
6422 6422
         } else {
6423
-            $generator = function () use ($numberOfPieces) {
6423
+            $generator = function() use ($numberOfPieces) {
6424 6424
                 $carry = [];
6425 6425
                 $i = 1;
6426 6426
                 foreach ($this->getGenerator() as $key => $value) {
@@ -6467,7 +6467,7 @@  discard block
 block discarded – undo
6467 6467
     public function stripEmpty(): self
6468 6468
     {
6469 6469
         return $this->filter(
6470
-            static function ($item) {
6470
+            static function($item) {
6471 6471
                 if ($item === null) {
6472 6472
                     return false;
6473 6473
                 }
@@ -6670,7 +6670,7 @@  discard block
 block discarded – undo
6670 6670
          * @psalm-suppress MissingClosureParamType
6671 6671
          */
6672 6672
         $this->array = $this->reduce(
6673
-            static function ($resultArray, $value) {
6673
+            static function($resultArray, $value) {
6674 6674
                 if (!\in_array($value, $resultArray, true)) {
6675 6675
                     $resultArray[] = $value;
6676 6676
                 }
@@ -6709,7 +6709,7 @@  discard block
 block discarded – undo
6709 6709
          */
6710 6710
         $this->array = \array_reduce(
6711 6711
             \array_keys($array),
6712
-            static function ($resultArray, $key) use ($array) {
6712
+            static function($resultArray, $key) use ($array) {
6713 6713
                 if (!\in_array($array[$key], $resultArray, true)) {
6714 6714
                     $resultArray[$key] = $array[$key];
6715 6715
                 }
@@ -6804,7 +6804,7 @@  discard block
 block discarded – undo
6804 6804
     public function values(): self
6805 6805
     {
6806 6806
         return static::create(
6807
-            function () {
6807
+            function() {
6808 6808
                 /** @noinspection YieldFromCanBeUsedInspection */
6809 6809
                 foreach ($this->getGenerator() as $value) {
6810 6810
                     yield $value;
@@ -6880,7 +6880,7 @@  discard block
 block discarded – undo
6880 6880
     public function where(string $keyOrPropertyOrMethod, $value): self
6881 6881
     {
6882 6882
         return $this->filter(
6883
-            function ($item) use ($keyOrPropertyOrMethod, $value) {
6883
+            function($item) use ($keyOrPropertyOrMethod, $value) {
6884 6884
                 $accessorValue = $this->extractValue(
6885 6885
                     $item,
6886 6886
                     $keyOrPropertyOrMethod
@@ -7170,7 +7170,7 @@  discard block
 block discarded – undo
7170 7170
     protected function getPropertiesFromPhpDoc()
7171 7171
     {
7172 7172
         static $PROPERTY_CACHE = [];
7173
-        $cacheKey = 'Class::' . static::class;
7173
+        $cacheKey = 'Class::'.static::class;
7174 7174
 
7175 7175
         if (isset($PROPERTY_CACHE[$cacheKey])) {
7176 7176
             return $PROPERTY_CACHE[$cacheKey];
@@ -7476,7 +7476,7 @@  discard block
 block discarded – undo
7476 7476
         if ($array === null) {
7477 7477
             $array = [];
7478 7478
         } elseif (!\is_array($array)) {
7479
-            throw new \RuntimeException('Can not set value at this path "' . $key . '" because (' . \gettype($array) . ')"' . \print_r($array, true) . '" is not an array.');
7479
+            throw new \RuntimeException('Can not set value at this path "'.$key.'" because ('.\gettype($array).')"'.\print_r($array, true).'" is not an array.');
7480 7480
         }
7481 7481
 
7482 7482
         $array[$key] = $value;
@@ -7548,7 +7548,7 @@  discard block
 block discarded – undo
7548 7548
                 &&
7549 7549
                 \count(\array_diff_key($properties, $data)) > 0
7550 7550
             ) {
7551
-                throw new \TypeError('Property mismatch - input: ' . \print_r(\array_keys($data), true) . ' | expected: ' . \print_r(\array_keys($properties), true));
7551
+                throw new \TypeError('Property mismatch - input: '.\print_r(\array_keys($data), true).' | expected: '.\print_r(\array_keys($properties), true));
7552 7552
             }
7553 7553
 
7554 7554
             foreach ($data as $key => &$valueInner) {
@@ -7665,7 +7665,7 @@  discard block
 block discarded – undo
7665 7665
              *
7666 7666
              * @return void
7667 7667
              */
7668
-            static function (&$item) {
7668
+            static function(&$item) {
7669 7669
                 if ($item instanceof self) {
7670 7670
                     $item = $item->getArray();
7671 7671
                 }
@@ -7690,7 +7690,7 @@  discard block
 block discarded – undo
7690 7690
             &&
7691 7691
             $this->checkPropertiesMismatch === true
7692 7692
         ) {
7693
-            throw new \TypeError('The key "' . $key . '" does not exists as "@property" phpdoc. (' . \get_class($this) . ').');
7693
+            throw new \TypeError('The key "'.$key.'" does not exists as "@property" phpdoc. ('.\get_class($this).').');
7694 7694
         }
7695 7695
 
7696 7696
         if (isset($this->properties[self::ARRAYY_HELPER_TYPES_FOR_ALL_PROPERTIES])) {
Please login to merge, or discard this patch.