Completed
Push — master ( 16b7ec...4be620 )
by Lars
01:35
created
src/Arrayy.php 1 patch
Spacing   +61 added lines, -61 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
             }
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
                  */
705 705
                 $this->callAtPath(
706 706
                     $containerPath,
707
-                    static function ($container) use ($lastOffset, &$offsetExists) {
707
+                    static function($container) use ($lastOffset, &$offsetExists) {
708 708
                         $offsetExists = \array_key_exists($lastOffset, $container);
709 709
                     }
710 710
                 );
@@ -807,7 +807,7 @@  discard block
 block discarded – undo
807 807
                  */
808 808
                 $this->callAtPath(
809 809
                     \implode($this->pathSeparator, $path),
810
-                    static function (&$offset) use ($pathToUnset) {
810
+                    static function(&$offset) use ($pathToUnset) {
811 811
                         if (\is_array($offset)) {
812 812
                             unset($offset[$pathToUnset]);
813 813
                         } else {
@@ -861,7 +861,7 @@  discard block
 block discarded – undo
861 861
         }
862 862
 
863 863
         if (\strpos($iteratorClass, '\\') === 0) {
864
-            $iteratorClass = '\\' . $iteratorClass;
864
+            $iteratorClass = '\\'.$iteratorClass;
865 865
             if (\class_exists($iteratorClass)) {
866 866
                 /**
867 867
                  * @psalm-suppress PropertyTypeCoercion
@@ -872,7 +872,7 @@  discard block
 block discarded – undo
872 872
             }
873 873
         }
874 874
 
875
-        throw new \InvalidArgumentException('The iterator class does not exist: ' . $iteratorClass);
875
+        throw new \InvalidArgumentException('The iterator class does not exist: '.$iteratorClass);
876 876
     }
877 877
 
878 878
     /**
@@ -1047,13 +1047,13 @@  discard block
 block discarded – undo
1047 1047
 
1048 1048
         foreach ($this->getGenerator() as $key => $item) {
1049 1049
             if ($item instanceof self) {
1050
-                $result[$prefix . $key] = $item->appendToEachKey($prefix);
1050
+                $result[$prefix.$key] = $item->appendToEachKey($prefix);
1051 1051
             } elseif (\is_array($item)) {
1052
-                $result[$prefix . $key] = self::create($item, $this->iteratorClass, false)
1052
+                $result[$prefix.$key] = self::create($item, $this->iteratorClass, false)
1053 1053
                     ->appendToEachKey($prefix)
1054 1054
                     ->toArray();
1055 1055
             } else {
1056
-                $result[$prefix . $key] = $item;
1056
+                $result[$prefix.$key] = $item;
1057 1057
             }
1058 1058
         }
1059 1059
 
@@ -1084,7 +1084,7 @@  discard block
 block discarded – undo
1084 1084
             } elseif (\is_object($item) === true) {
1085 1085
                 $result[$key] = $item;
1086 1086
             } else {
1087
-                $result[$key] = $prefix . $item;
1087
+                $result[$key] = $prefix.$item;
1088 1088
             }
1089 1089
         }
1090 1090
 
@@ -1270,7 +1270,7 @@  discard block
 block discarded – undo
1270 1270
     public function chunk($size, $preserveKeys = false): self
1271 1271
     {
1272 1272
         if ($preserveKeys) {
1273
-            $generator = function () use ($size) {
1273
+            $generator = function() use ($size) {
1274 1274
                 $values = [];
1275 1275
                 $tmpCounter = 0;
1276 1276
                 foreach ($this->getGenerator() as $key => $value) {
@@ -1290,7 +1290,7 @@  discard block
 block discarded – undo
1290 1290
                 }
1291 1291
             };
1292 1292
         } else {
1293
-            $generator = function () use ($size) {
1293
+            $generator = function() use ($size) {
1294 1294
                 $values = [];
1295 1295
                 $tmpCounter = 0;
1296 1296
                 foreach ($this->getGenerator() as $key => $value) {
@@ -1334,7 +1334,7 @@  discard block
 block discarded – undo
1334 1334
     public function clean(): self
1335 1335
     {
1336 1336
         return $this->filter(
1337
-            static function ($value) {
1337
+            static function($value) {
1338 1338
                 return (bool) $value;
1339 1339
             }
1340 1340
         );
@@ -1676,9 +1676,9 @@  discard block
 block discarded – undo
1676 1676
 
1677 1677
         foreach ($items as $key => $value) {
1678 1678
             if (\is_array($value) && $value !== []) {
1679
-                $flatten[] = $this->flatten($delimiter, $prepend . $key . $delimiter, $value);
1679
+                $flatten[] = $this->flatten($delimiter, $prepend.$key.$delimiter, $value);
1680 1680
             } else {
1681
-                $flatten[] = [$prepend . $key => $value];
1681
+                $flatten[] = [$prepend.$key => $value];
1682 1682
             }
1683 1683
         }
1684 1684
 
@@ -1856,7 +1856,7 @@  discard block
 block discarded – undo
1856 1856
          */
1857 1857
         \array_walk(
1858 1858
             $array,
1859
-            static function (&$val) {
1859
+            static function(&$val) {
1860 1860
                 if ((string) $val === $val) {
1861 1861
                     $val = \trim($val);
1862 1862
                 }
@@ -2388,7 +2388,7 @@  discard block
 block discarded – undo
2388 2388
         }
2389 2389
 
2390 2390
         if ($flag === \ARRAY_FILTER_USE_KEY) {
2391
-            $generator = function () use ($closure) {
2391
+            $generator = function() use ($closure) {
2392 2392
                 foreach ($this->getGenerator() as $key => $value) {
2393 2393
                     if ($closure($key) === true) {
2394 2394
                         yield $key => $value;
@@ -2396,7 +2396,7 @@  discard block
 block discarded – undo
2396 2396
                 }
2397 2397
             };
2398 2398
         } elseif ($flag === \ARRAY_FILTER_USE_BOTH) {
2399
-            $generator = function () use ($closure) {
2399
+            $generator = function() use ($closure) {
2400 2400
                 foreach ($this->getGenerator() as $key => $value) {
2401 2401
                     if ($closure($value, $key) === true) {
2402 2402
                         yield $key => $value;
@@ -2404,7 +2404,7 @@  discard block
 block discarded – undo
2404 2404
                 }
2405 2405
             };
2406 2406
         } else {
2407
-            $generator = function () use ($closure) {
2407
+            $generator = function() use ($closure) {
2408 2408
                 foreach ($this->getGenerator() as $key => $value) {
2409 2409
                     if ($closure($value) === true) {
2410 2410
                         yield $key => $value;
@@ -2460,40 +2460,40 @@  discard block
 block discarded – undo
2460 2460
         }
2461 2461
 
2462 2462
         $ops = [
2463
-            'eq' => static function ($item, $prop, $value): bool {
2463
+            'eq' => static function($item, $prop, $value): bool {
2464 2464
                 return $item[$prop] === $value;
2465 2465
             },
2466
-            'gt' => static function ($item, $prop, $value): bool {
2466
+            'gt' => static function($item, $prop, $value): bool {
2467 2467
                 return $item[$prop] > $value;
2468 2468
             },
2469
-            'ge' => static function ($item, $prop, $value): bool {
2469
+            'ge' => static function($item, $prop, $value): bool {
2470 2470
                 return $item[$prop] >= $value;
2471 2471
             },
2472
-            'gte' => static function ($item, $prop, $value): bool {
2472
+            'gte' => static function($item, $prop, $value): bool {
2473 2473
                 return $item[$prop] >= $value;
2474 2474
             },
2475
-            'lt' => static function ($item, $prop, $value): bool {
2475
+            'lt' => static function($item, $prop, $value): bool {
2476 2476
                 return $item[$prop] < $value;
2477 2477
             },
2478
-            'le' => static function ($item, $prop, $value): bool {
2478
+            'le' => static function($item, $prop, $value): bool {
2479 2479
                 return $item[$prop] <= $value;
2480 2480
             },
2481
-            'lte' => static function ($item, $prop, $value): bool {
2481
+            'lte' => static function($item, $prop, $value): bool {
2482 2482
                 return $item[$prop] <= $value;
2483 2483
             },
2484
-            'ne' => static function ($item, $prop, $value): bool {
2484
+            'ne' => static function($item, $prop, $value): bool {
2485 2485
                 return $item[$prop] !== $value;
2486 2486
             },
2487
-            'contains' => static function ($item, $prop, $value): bool {
2487
+            'contains' => static function($item, $prop, $value): bool {
2488 2488
                 return \in_array($item[$prop], (array) $value, true);
2489 2489
             },
2490
-            'notContains' => static function ($item, $prop, $value): bool {
2490
+            'notContains' => static function($item, $prop, $value): bool {
2491 2491
                 return !\in_array($item[$prop], (array) $value, true);
2492 2492
             },
2493
-            'newer' => static function ($item, $prop, $value): bool {
2493
+            'newer' => static function($item, $prop, $value): bool {
2494 2494
                 return \strtotime($item[$prop]) > \strtotime($value);
2495 2495
             },
2496
-            'older' => static function ($item, $prop, $value): bool {
2496
+            'older' => static function($item, $prop, $value): bool {
2497 2497
                 return \strtotime($item[$prop]) < \strtotime($value);
2498 2498
             },
2499 2499
         ];
@@ -2501,7 +2501,7 @@  discard block
 block discarded – undo
2501 2501
         $result = \array_values(
2502 2502
             \array_filter(
2503 2503
                 $this->toArray(false, true),
2504
-                static function ($item) use (
2504
+                static function($item) use (
2505 2505
                     $property,
2506 2506
                     $value,
2507 2507
                     $ops,
@@ -2716,7 +2716,7 @@  discard block
 block discarded – undo
2716 2716
      */
2717 2717
     public function flip(): self
2718 2718
     {
2719
-        $generator = function (): \Generator {
2719
+        $generator = function(): \Generator {
2720 2720
             foreach ($this->getGenerator() as $key => $value) {
2721 2721
                 yield (string) $value => $key;
2722 2722
             }
@@ -2977,9 +2977,9 @@  discard block
 block discarded – undo
2977 2977
         $jsonObject = \json_decode($json, false);
2978 2978
 
2979 2979
         $mapper = new \Arrayy\Mapper\Json();
2980
-        $mapper->undefinedPropertyHandler = static function ($object, $key, $jsonValue) use ($class) {
2980
+        $mapper->undefinedPropertyHandler = static function($object, $key, $jsonValue) use ($class) {
2981 2981
             if ($class->checkPropertiesMismatchInConstructor) {
2982
-                throw new \TypeError('Property mismatch - input: ' . \print_r(['key' => $key, 'jsonValue' => $jsonValue], true) . ' for object: ' . \get_class($object));
2982
+                throw new \TypeError('Property mismatch - input: '.\print_r(['key' => $key, 'jsonValue' => $jsonValue], true).' for object: '.\get_class($object));
2983 2983
             }
2984 2984
         };
2985 2985
 
@@ -3044,13 +3044,13 @@  discard block
 block discarded – undo
3044 3044
     public function getColumn($columnKey = null, $indexKey = null): self
3045 3045
     {
3046 3046
         if ($columnKey === null && $indexKey === null) {
3047
-            $generator = function () {
3047
+            $generator = function() {
3048 3048
                 foreach ($this->getGenerator() as $key => $value) {
3049 3049
                     yield $value;
3050 3050
                 }
3051 3051
             };
3052 3052
         } else {
3053
-            $generator = function () use ($columnKey, $indexKey) {
3053
+            $generator = function() use ($columnKey, $indexKey) {
3054 3054
                 foreach ($this->getGenerator() as $key => $value) {
3055 3055
                     // reset
3056 3056
                     $newKey = null;
@@ -3350,7 +3350,7 @@  discard block
 block discarded – undo
3350 3350
 
3351 3351
         if ($UN_FOUND === null) {
3352 3352
             // Generate unique string to use as marker.
3353
-            $UN_FOUND = 'arrayy--' . \uniqid('arrayy', true);
3353
+            $UN_FOUND = 'arrayy--'.\uniqid('arrayy', true);
3354 3354
         }
3355 3355
 
3356 3356
         if (\is_array($key)) {
@@ -3400,7 +3400,7 @@  discard block
 block discarded – undo
3400 3400
      */
3401 3401
     public function implode(string $glue = '', string $prefix = ''): string
3402 3402
     {
3403
-        return $prefix . $this->implode_recursive($glue, $this->toArray(), false);
3403
+        return $prefix.$this->implode_recursive($glue, $this->toArray(), false);
3404 3404
     }
3405 3405
 
3406 3406
     /**
@@ -3509,7 +3509,7 @@  discard block
 block discarded – undo
3509 3509
                 \array_uintersect(
3510 3510
                     $this->toArray(),
3511 3511
                     $search,
3512
-                    static function ($a, $b) {
3512
+                    static function($a, $b) {
3513 3513
                         return $a === $b ? 0 : -1;
3514 3514
                     }
3515 3515
                 ),
@@ -3845,13 +3845,13 @@  discard block
 block discarded – undo
3845 3845
         // non recursive
3846 3846
 
3847 3847
         if ($search_values === null) {
3848
-            $arrayFunction = function (): \Generator {
3848
+            $arrayFunction = function(): \Generator {
3849 3849
                 foreach ($this->getGenerator() as $key => $value) {
3850 3850
                     yield $key;
3851 3851
                 }
3852 3852
             };
3853 3853
         } else {
3854
-            $arrayFunction = function () use ($search_values, $strict): \Generator {
3854
+            $arrayFunction = function() use ($search_values, $strict): \Generator {
3855 3855
                 $is_array_tmp = \is_array($search_values);
3856 3856
 
3857 3857
                 /** @noinspection PhpParameterByRefIsNotUsedAsReferenceInspection */
@@ -4095,7 +4095,7 @@  discard block
 block discarded – undo
4095 4095
         $useArguments = \func_num_args() > 2;
4096 4096
 
4097 4097
         return static::create(
4098
-            function () use ($useArguments, $callable, $useKeyAsSecondParameter, $arguments) {
4098
+            function() use ($useArguments, $callable, $useKeyAsSecondParameter, $arguments) {
4099 4099
                 foreach ($this->getGenerator() as $key => $value) {
4100 4100
                     if ($useArguments) {
4101 4101
                         if ($useKeyAsSecondParameter) {
@@ -4582,7 +4582,7 @@  discard block
 block discarded – undo
4582 4582
      */
4583 4583
     public function nth(int $step, int $offset = 0): self
4584 4584
     {
4585
-        $arrayFunction = function () use ($step, $offset): \Generator {
4585
+        $arrayFunction = function() use ($step, $offset): \Generator {
4586 4586
             $position = 0;
4587 4587
             foreach ($this->getGenerator() as $key => $value) {
4588 4588
                 if ($position++ % $step !== $offset) {
@@ -4616,7 +4616,7 @@  discard block
 block discarded – undo
4616 4616
     {
4617 4617
         $keys = \array_flip($keys);
4618 4618
 
4619
-        $generator = function () use ($keys): \Generator {
4619
+        $generator = function() use ($keys): \Generator {
4620 4620
             foreach ($this->getGenerator() as $key => $value) {
4621 4621
                 if (isset($keys[$key])) {
4622 4622
                     yield $key => $value;
@@ -4746,7 +4746,7 @@  discard block
 block discarded – undo
4746 4746
      */
4747 4747
     public function prependImmutable($value, $key = null)
4748 4748
     {
4749
-        $generator = function () use ($key, $value): \Generator {
4749
+        $generator = function() use ($key, $value): \Generator {
4750 4750
             if ($this->properties !== []) {
4751 4751
                 $this->checkType($key, $value);
4752 4752
             }
@@ -4797,7 +4797,7 @@  discard block
 block discarded – undo
4797 4797
                 )->prependToEachKey($suffix)
4798 4798
                     ->toArray();
4799 4799
             } else {
4800
-                $result[$key . $suffix] = $item;
4800
+                $result[$key.$suffix] = $item;
4801 4801
             }
4802 4802
         }
4803 4803
 
@@ -4837,7 +4837,7 @@  discard block
 block discarded – undo
4837 4837
             } elseif (\is_object($item) === true) {
4838 4838
                 $result[$key] = $item;
4839 4839
             } else {
4840
-                $result[$key] = $item . $suffix;
4840
+                $result[$key] = $item.$suffix;
4841 4841
             }
4842 4842
         }
4843 4843
 
@@ -5623,7 +5623,7 @@  discard block
 block discarded – undo
5623 5623
          * @psalm-suppress MissingClosureParamType
5624 5624
          */
5625 5625
         return $this->each(
5626
-            static function ($value) use ($search, $replacement) {
5626
+            static function($value) use ($search, $replacement) {
5627 5627
                 return \str_replace($search, $replacement, $value);
5628 5628
             }
5629 5629
         );
@@ -6307,7 +6307,7 @@  discard block
 block discarded – undo
6307 6307
              * @psalm-suppress MissingClosureParamType
6308 6308
              */
6309 6309
             $results = $arrayy->each(
6310
-                static function ($value) use ($sorter) {
6310
+                static function($value) use ($sorter) {
6311 6311
                     if (\is_callable($sorter) === true) {
6312 6312
                         return $sorter($value);
6313 6313
                     }
@@ -6380,7 +6380,7 @@  discard block
 block discarded – undo
6380 6380
     public function split(int $numberOfPieces = 2, bool $keepKeys = false): self
6381 6381
     {
6382 6382
         if ($keepKeys) {
6383
-            $generator = function () use ($numberOfPieces) {
6383
+            $generator = function() use ($numberOfPieces) {
6384 6384
                 $carry = [];
6385 6385
                 $i = 1;
6386 6386
                 foreach ($this->getGenerator() as $key => $value) {
@@ -6403,7 +6403,7 @@  discard block
 block discarded – undo
6403 6403
                 }
6404 6404
             };
6405 6405
         } else {
6406
-            $generator = function () use ($numberOfPieces) {
6406
+            $generator = function() use ($numberOfPieces) {
6407 6407
                 $carry = [];
6408 6408
                 $i = 1;
6409 6409
                 foreach ($this->getGenerator() as $key => $value) {
@@ -6450,7 +6450,7 @@  discard block
 block discarded – undo
6450 6450
     public function stripEmpty(): self
6451 6451
     {
6452 6452
         return $this->filter(
6453
-            static function ($item) {
6453
+            static function($item) {
6454 6454
                 if ($item === null) {
6455 6455
                     return false;
6456 6456
                 }
@@ -6653,7 +6653,7 @@  discard block
 block discarded – undo
6653 6653
          * @psalm-suppress MissingClosureParamType
6654 6654
          */
6655 6655
         $this->array = $this->reduce(
6656
-            static function ($resultArray, $value) {
6656
+            static function($resultArray, $value) {
6657 6657
                 if (!\in_array($value, $resultArray, true)) {
6658 6658
                     $resultArray[] = $value;
6659 6659
                 }
@@ -6692,7 +6692,7 @@  discard block
 block discarded – undo
6692 6692
          */
6693 6693
         $this->array = \array_reduce(
6694 6694
             \array_keys($array),
6695
-            static function ($resultArray, $key) use ($array) {
6695
+            static function($resultArray, $key) use ($array) {
6696 6696
                 if (!\in_array($array[$key], $resultArray, true)) {
6697 6697
                     $resultArray[$key] = $array[$key];
6698 6698
                 }
@@ -6777,7 +6777,7 @@  discard block
 block discarded – undo
6777 6777
     public function values(): self
6778 6778
     {
6779 6779
         return static::create(
6780
-            function () {
6780
+            function() {
6781 6781
                 /** @noinspection YieldFromCanBeUsedInspection */
6782 6782
                 foreach ($this->getGenerator() as $value) {
6783 6783
                     yield $value;
@@ -6853,7 +6853,7 @@  discard block
 block discarded – undo
6853 6853
     public function where(string $keyOrPropertyOrMethod, $value): self
6854 6854
     {
6855 6855
         return $this->filter(
6856
-            function ($item) use ($keyOrPropertyOrMethod, $value) {
6856
+            function($item) use ($keyOrPropertyOrMethod, $value) {
6857 6857
                 $accessorValue = $this->extractValue(
6858 6858
                     $item,
6859 6859
                     $keyOrPropertyOrMethod
@@ -7143,7 +7143,7 @@  discard block
 block discarded – undo
7143 7143
     protected function getPropertiesFromPhpDoc()
7144 7144
     {
7145 7145
         static $PROPERTY_CACHE = [];
7146
-        $cacheKey = 'Class::' . static::class;
7146
+        $cacheKey = 'Class::'.static::class;
7147 7147
 
7148 7148
         if (isset($PROPERTY_CACHE[$cacheKey])) {
7149 7149
             return $PROPERTY_CACHE[$cacheKey];
@@ -7449,7 +7449,7 @@  discard block
 block discarded – undo
7449 7449
         if ($array === null) {
7450 7450
             $array = [];
7451 7451
         } elseif (!\is_array($array)) {
7452
-            throw new \RuntimeException('Can not set value at this path "' . $key . '" because (' . \gettype($array) . ')"' . \print_r($array, true) . '" is not an array.');
7452
+            throw new \RuntimeException('Can not set value at this path "'.$key.'" because ('.\gettype($array).')"'.\print_r($array, true).'" is not an array.');
7453 7453
         }
7454 7454
 
7455 7455
         $array[$key] = $value;
@@ -7521,7 +7521,7 @@  discard block
 block discarded – undo
7521 7521
                 &&
7522 7522
                 \count(\array_diff_key($properties, $data)) > 0
7523 7523
             ) {
7524
-                throw new \TypeError('Property mismatch - input: ' . \print_r(\array_keys($data), true) . ' | expected: ' . \print_r(\array_keys($properties), true));
7524
+                throw new \TypeError('Property mismatch - input: '.\print_r(\array_keys($data), true).' | expected: '.\print_r(\array_keys($properties), true));
7525 7525
             }
7526 7526
 
7527 7527
             foreach ($data as $key => &$valueInner) {
@@ -7638,7 +7638,7 @@  discard block
 block discarded – undo
7638 7638
              *
7639 7639
              * @return void
7640 7640
              */
7641
-            static function (&$item) {
7641
+            static function(&$item) {
7642 7642
                 if ($item instanceof self) {
7643 7643
                     $item = $item->getArray();
7644 7644
                 }
@@ -7663,7 +7663,7 @@  discard block
 block discarded – undo
7663 7663
             &&
7664 7664
             $this->checkPropertiesMismatch === true
7665 7665
         ) {
7666
-            throw new \TypeError('The key "' . $key . '" does not exists as "@property" phpdoc. (' . \get_class($this) . ').');
7666
+            throw new \TypeError('The key "'.$key.'" does not exists as "@property" phpdoc. ('.\get_class($this).').');
7667 7667
         }
7668 7668
 
7669 7669
         if (isset($this->properties[self::ARRAYY_HELPER_TYPES_FOR_ALL_PROPERTIES])) {
Please login to merge, or discard this patch.