Completed
Push — master ( 2f04e2...e8a46f )
by Lars
01:39
created
src/Arrayy.php 1 patch
Spacing   +60 added lines, -60 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
 
@@ -1262,7 +1262,7 @@  discard block
 block discarded – undo
1262 1262
     public function chunk($size, $preserveKeys = false): self
1263 1263
     {
1264 1264
         if ($preserveKeys) {
1265
-            $generator = function () use ($size) {
1265
+            $generator = function() use ($size) {
1266 1266
                 $values = [];
1267 1267
                 $tmpCounter = 0;
1268 1268
                 foreach ($this->getGenerator() as $key => $value) {
@@ -1282,7 +1282,7 @@  discard block
 block discarded – undo
1282 1282
                 }
1283 1283
             };
1284 1284
         } else {
1285
-            $generator = function () use ($size) {
1285
+            $generator = function() use ($size) {
1286 1286
                 $values = [];
1287 1287
                 $tmpCounter = 0;
1288 1288
                 foreach ($this->getGenerator() as $key => $value) {
@@ -1326,7 +1326,7 @@  discard block
 block discarded – undo
1326 1326
     public function clean(): self
1327 1327
     {
1328 1328
         return $this->filter(
1329
-            static function ($value) {
1329
+            static function($value) {
1330 1330
                 return (bool) $value;
1331 1331
             }
1332 1332
         );
@@ -1668,9 +1668,9 @@  discard block
 block discarded – undo
1668 1668
 
1669 1669
         foreach ($items as $key => $value) {
1670 1670
             if (\is_array($value) && $value !== []) {
1671
-                $flatten[] = $this->flatten($delimiter, $prepend . $key . $delimiter, $value);
1671
+                $flatten[] = $this->flatten($delimiter, $prepend.$key.$delimiter, $value);
1672 1672
             } else {
1673
-                $flatten[] = [$prepend . $key => $value];
1673
+                $flatten[] = [$prepend.$key => $value];
1674 1674
             }
1675 1675
         }
1676 1676
 
@@ -1848,7 +1848,7 @@  discard block
 block discarded – undo
1848 1848
          */
1849 1849
         \array_walk(
1850 1850
             $array,
1851
-            static function (&$val) {
1851
+            static function(&$val) {
1852 1852
                 if ((string) $val === $val) {
1853 1853
                     $val = \trim($val);
1854 1854
                 }
@@ -2380,7 +2380,7 @@  discard block
 block discarded – undo
2380 2380
         }
2381 2381
 
2382 2382
         if ($flag === \ARRAY_FILTER_USE_KEY) {
2383
-            $generator = function () use ($closure) {
2383
+            $generator = function() use ($closure) {
2384 2384
                 foreach ($this->getGenerator() as $key => $value) {
2385 2385
                     if ($closure($key) === true) {
2386 2386
                         yield $key => $value;
@@ -2388,7 +2388,7 @@  discard block
 block discarded – undo
2388 2388
                 }
2389 2389
             };
2390 2390
         } elseif ($flag === \ARRAY_FILTER_USE_BOTH) {
2391
-            $generator = function () use ($closure) {
2391
+            $generator = function() use ($closure) {
2392 2392
                 foreach ($this->getGenerator() as $key => $value) {
2393 2393
                     if ($closure($value, $key) === true) {
2394 2394
                         yield $key => $value;
@@ -2396,7 +2396,7 @@  discard block
 block discarded – undo
2396 2396
                 }
2397 2397
             };
2398 2398
         } else {
2399
-            $generator = function () use ($closure) {
2399
+            $generator = function() use ($closure) {
2400 2400
                 foreach ($this->getGenerator() as $key => $value) {
2401 2401
                     if ($closure($value) === true) {
2402 2402
                         yield $key => $value;
@@ -2451,40 +2451,40 @@  discard block
 block discarded – undo
2451 2451
         }
2452 2452
 
2453 2453
         $ops = [
2454
-            'eq' => static function ($item, $prop, $value): bool {
2454
+            'eq' => static function($item, $prop, $value): bool {
2455 2455
                 return $item[$prop] === $value;
2456 2456
             },
2457
-            'gt' => static function ($item, $prop, $value): bool {
2457
+            'gt' => static function($item, $prop, $value): bool {
2458 2458
                 return $item[$prop] > $value;
2459 2459
             },
2460
-            'ge' => static function ($item, $prop, $value): bool {
2460
+            'ge' => static function($item, $prop, $value): bool {
2461 2461
                 return $item[$prop] >= $value;
2462 2462
             },
2463
-            'gte' => static function ($item, $prop, $value): bool {
2463
+            'gte' => static function($item, $prop, $value): bool {
2464 2464
                 return $item[$prop] >= $value;
2465 2465
             },
2466
-            'lt' => static function ($item, $prop, $value): bool {
2466
+            'lt' => static function($item, $prop, $value): bool {
2467 2467
                 return $item[$prop] < $value;
2468 2468
             },
2469
-            'le' => static function ($item, $prop, $value): bool {
2469
+            'le' => static function($item, $prop, $value): bool {
2470 2470
                 return $item[$prop] <= $value;
2471 2471
             },
2472
-            'lte' => static function ($item, $prop, $value): bool {
2472
+            'lte' => static function($item, $prop, $value): bool {
2473 2473
                 return $item[$prop] <= $value;
2474 2474
             },
2475
-            'ne' => static function ($item, $prop, $value): bool {
2475
+            'ne' => static function($item, $prop, $value): bool {
2476 2476
                 return $item[$prop] !== $value;
2477 2477
             },
2478
-            'contains' => static function ($item, $prop, $value): bool {
2478
+            'contains' => static function($item, $prop, $value): bool {
2479 2479
                 return \in_array($item[$prop], (array) $value, true);
2480 2480
             },
2481
-            'notContains' => static function ($item, $prop, $value): bool {
2481
+            'notContains' => static function($item, $prop, $value): bool {
2482 2482
                 return !\in_array($item[$prop], (array) $value, true);
2483 2483
             },
2484
-            'newer' => static function ($item, $prop, $value): bool {
2484
+            'newer' => static function($item, $prop, $value): bool {
2485 2485
                 return \strtotime($item[$prop]) > \strtotime($value);
2486 2486
             },
2487
-            'older' => static function ($item, $prop, $value): bool {
2487
+            'older' => static function($item, $prop, $value): bool {
2488 2488
                 return \strtotime($item[$prop]) < \strtotime($value);
2489 2489
             },
2490 2490
         ];
@@ -2492,7 +2492,7 @@  discard block
 block discarded – undo
2492 2492
         $result = \array_values(
2493 2493
             \array_filter(
2494 2494
                 $this->toArray(false, true),
2495
-                static function ($item) use (
2495
+                static function($item) use (
2496 2496
                     $property,
2497 2497
                     $value,
2498 2498
                     $ops,
@@ -2706,7 +2706,7 @@  discard block
 block discarded – undo
2706 2706
      */
2707 2707
     public function flip(): self
2708 2708
     {
2709
-        $generator = function (): \Generator {
2709
+        $generator = function(): \Generator {
2710 2710
             foreach ($this->getGenerator() as $key => $value) {
2711 2711
                 yield (string) $value => $key;
2712 2712
             }
@@ -2967,9 +2967,9 @@  discard block
 block discarded – undo
2967 2967
         $jsonObject = \json_decode($json, false);
2968 2968
 
2969 2969
         $mapper = new \Arrayy\Mapper\Json();
2970
-        $mapper->undefinedPropertyHandler = static function ($object, $key, $jsonValue) use ($class) {
2970
+        $mapper->undefinedPropertyHandler = static function($object, $key, $jsonValue) use ($class) {
2971 2971
             if ($class->checkPropertiesMismatchInConstructor) {
2972
-                throw new \TypeError('Property mismatch - input: ' . \print_r(['key' => $key, 'jsonValue' => $jsonValue], true) . ' for object: ' . \get_class($object));
2972
+                throw new \TypeError('Property mismatch - input: '.\print_r(['key' => $key, 'jsonValue' => $jsonValue], true).' for object: '.\get_class($object));
2973 2973
             }
2974 2974
         };
2975 2975
 
@@ -3034,13 +3034,13 @@  discard block
 block discarded – undo
3034 3034
     public function getColumn($columnKey = null, $indexKey = null): self
3035 3035
     {
3036 3036
         if ($columnKey === null && $indexKey === null) {
3037
-            $generator = function () {
3037
+            $generator = function() {
3038 3038
                 foreach ($this->getGenerator() as $key => $value) {
3039 3039
                     yield $value;
3040 3040
                 }
3041 3041
             };
3042 3042
         } else {
3043
-            $generator = function () use ($columnKey, $indexKey) {
3043
+            $generator = function() use ($columnKey, $indexKey) {
3044 3044
                 foreach ($this->getGenerator() as $key => $value) {
3045 3045
                     // reset
3046 3046
                     $newKey = null;
@@ -3390,7 +3390,7 @@  discard block
 block discarded – undo
3390 3390
      */
3391 3391
     public function implode(string $glue = '', string $prefix = ''): string
3392 3392
     {
3393
-        return $prefix . $this->implode_recursive($glue, $this->toArray(), false);
3393
+        return $prefix.$this->implode_recursive($glue, $this->toArray(), false);
3394 3394
     }
3395 3395
 
3396 3396
     /**
@@ -3499,7 +3499,7 @@  discard block
 block discarded – undo
3499 3499
                 \array_uintersect(
3500 3500
                     $this->toArray(),
3501 3501
                     $search,
3502
-                    static function ($a, $b) {
3502
+                    static function($a, $b) {
3503 3503
                         return $a === $b ? 0 : -1;
3504 3504
                     }
3505 3505
                 ),
@@ -3835,13 +3835,13 @@  discard block
 block discarded – undo
3835 3835
         // non recursive
3836 3836
 
3837 3837
         if ($search_values === null) {
3838
-            $arrayFunction = function (): \Generator {
3838
+            $arrayFunction = function(): \Generator {
3839 3839
                 foreach ($this->getGenerator() as $key => $value) {
3840 3840
                     yield $key;
3841 3841
                 }
3842 3842
             };
3843 3843
         } else {
3844
-            $arrayFunction = function () use ($search_values, $strict): \Generator {
3844
+            $arrayFunction = function() use ($search_values, $strict): \Generator {
3845 3845
                 $is_array_tmp = \is_array($search_values);
3846 3846
 
3847 3847
                 /** @noinspection PhpParameterByRefIsNotUsedAsReferenceInspection */
@@ -4081,7 +4081,7 @@  discard block
 block discarded – undo
4081 4081
         $useArguments = \func_num_args() > 2;
4082 4082
 
4083 4083
         return static::create(
4084
-            function () use ($useArguments, $callable, $useKeyAsSecondParameter, $arguments) {
4084
+            function() use ($useArguments, $callable, $useKeyAsSecondParameter, $arguments) {
4085 4085
                 foreach ($this->getGenerator() as $key => $value) {
4086 4086
                     if ($useArguments) {
4087 4087
                         if ($useKeyAsSecondParameter) {
@@ -4568,7 +4568,7 @@  discard block
 block discarded – undo
4568 4568
      */
4569 4569
     public function nth(int $step, int $offset = 0): self
4570 4570
     {
4571
-        $arrayFunction = function () use ($step, $offset): \Generator {
4571
+        $arrayFunction = function() use ($step, $offset): \Generator {
4572 4572
             $position = 0;
4573 4573
             foreach ($this->getGenerator() as $key => $value) {
4574 4574
                 if ($position++ % $step !== $offset) {
@@ -4602,7 +4602,7 @@  discard block
 block discarded – undo
4602 4602
     {
4603 4603
         $keys = \array_flip($keys);
4604 4604
 
4605
-        $generator = function () use ($keys): \Generator {
4605
+        $generator = function() use ($keys): \Generator {
4606 4606
             foreach ($this->getGenerator() as $key => $value) {
4607 4607
                 if (isset($keys[$key])) {
4608 4608
                     yield $key => $value;
@@ -4732,7 +4732,7 @@  discard block
 block discarded – undo
4732 4732
      */
4733 4733
     public function prependImmutable($value, $key = null)
4734 4734
     {
4735
-        $generator = function () use ($key, $value): \Generator {
4735
+        $generator = function() use ($key, $value): \Generator {
4736 4736
             if ($this->properties !== []) {
4737 4737
                 $this->checkType($key, $value);
4738 4738
             }
@@ -4783,7 +4783,7 @@  discard block
 block discarded – undo
4783 4783
                 )->prependToEachKey($suffix)
4784 4784
                     ->toArray();
4785 4785
             } else {
4786
-                $result[$key . $suffix] = $item;
4786
+                $result[$key.$suffix] = $item;
4787 4787
             }
4788 4788
         }
4789 4789
 
@@ -4823,7 +4823,7 @@  discard block
 block discarded – undo
4823 4823
             } elseif (\is_object($item) === true) {
4824 4824
                 $result[$key] = $item;
4825 4825
             } else {
4826
-                $result[$key] = $item . $suffix;
4826
+                $result[$key] = $item.$suffix;
4827 4827
             }
4828 4828
         }
4829 4829
 
@@ -5628,7 +5628,7 @@  discard block
 block discarded – undo
5628 5628
          * @psalm-suppress MissingClosureParamType
5629 5629
          */
5630 5630
         return $this->each(
5631
-            static function ($value) use ($search, $replacement) {
5631
+            static function($value) use ($search, $replacement) {
5632 5632
                 return \str_replace($search, $replacement, $value);
5633 5633
             }
5634 5634
         );
@@ -6312,7 +6312,7 @@  discard block
 block discarded – undo
6312 6312
              * @psalm-suppress MissingClosureParamType
6313 6313
              */
6314 6314
             $results = $arrayy->each(
6315
-                static function ($value) use ($sorter) {
6315
+                static function($value) use ($sorter) {
6316 6316
                     if (\is_callable($sorter) === true) {
6317 6317
                         return $sorter($value);
6318 6318
                     }
@@ -6385,7 +6385,7 @@  discard block
 block discarded – undo
6385 6385
     public function split(int $numberOfPieces = 2, bool $keepKeys = false): self
6386 6386
     {
6387 6387
         if ($keepKeys) {
6388
-            $generator = function () use ($numberOfPieces) {
6388
+            $generator = function() use ($numberOfPieces) {
6389 6389
                 $carry = [];
6390 6390
                 $i = 1;
6391 6391
                 foreach ($this->getGenerator() as $key => $value) {
@@ -6408,7 +6408,7 @@  discard block
 block discarded – undo
6408 6408
                 }
6409 6409
             };
6410 6410
         } else {
6411
-            $generator = function () use ($numberOfPieces) {
6411
+            $generator = function() use ($numberOfPieces) {
6412 6412
                 $carry = [];
6413 6413
                 $i = 1;
6414 6414
                 foreach ($this->getGenerator() as $key => $value) {
@@ -6455,7 +6455,7 @@  discard block
 block discarded – undo
6455 6455
     public function stripEmpty(): self
6456 6456
     {
6457 6457
         return $this->filter(
6458
-            static function ($item) {
6458
+            static function($item) {
6459 6459
                 if ($item === null) {
6460 6460
                     return false;
6461 6461
                 }
@@ -6659,7 +6659,7 @@  discard block
 block discarded – undo
6659 6659
          * @psalm-suppress MissingClosureParamType
6660 6660
          */
6661 6661
         $this->array = $this->reduce(
6662
-            static function ($resultArray, $value) {
6662
+            static function($resultArray, $value) {
6663 6663
                 if (!\in_array($value, $resultArray, true)) {
6664 6664
                     $resultArray[] = $value;
6665 6665
                 }
@@ -6698,7 +6698,7 @@  discard block
 block discarded – undo
6698 6698
          */
6699 6699
         $this->array = \array_reduce(
6700 6700
             \array_keys($array),
6701
-            static function ($resultArray, $key) use ($array) {
6701
+            static function($resultArray, $key) use ($array) {
6702 6702
                 if (!\in_array($array[$key], $resultArray, true)) {
6703 6703
                     $resultArray[$key] = $array[$key];
6704 6704
                 }
@@ -6783,7 +6783,7 @@  discard block
 block discarded – undo
6783 6783
     public function values(): self
6784 6784
     {
6785 6785
         return static::create(
6786
-            function () {
6786
+            function() {
6787 6787
                 /** @noinspection YieldFromCanBeUsedInspection */
6788 6788
                 foreach ($this->getGenerator() as $value) {
6789 6789
                     yield $value;
@@ -6860,7 +6860,7 @@  discard block
 block discarded – undo
6860 6860
     public function where(string $keyOrPropertyOrMethod, $value): self
6861 6861
     {
6862 6862
         return $this->filter(
6863
-            function ($item) use ($keyOrPropertyOrMethod, $value) {
6863
+            function($item) use ($keyOrPropertyOrMethod, $value) {
6864 6864
                 $accessorValue = $this->extractValue(
6865 6865
                     $item,
6866 6866
                     $keyOrPropertyOrMethod
@@ -7150,7 +7150,7 @@  discard block
 block discarded – undo
7150 7150
     protected function getPropertiesFromPhpDoc()
7151 7151
     {
7152 7152
         static $PROPERTY_CACHE = [];
7153
-        $cacheKey = 'Class::' . static::class;
7153
+        $cacheKey = 'Class::'.static::class;
7154 7154
 
7155 7155
         if (isset($PROPERTY_CACHE[$cacheKey])) {
7156 7156
             return $PROPERTY_CACHE[$cacheKey];
@@ -7456,7 +7456,7 @@  discard block
 block discarded – undo
7456 7456
         if ($array === null) {
7457 7457
             $array = [];
7458 7458
         } elseif (!\is_array($array)) {
7459
-            throw new \RuntimeException('Can not set value at this path "' . $key . '" because (' . \gettype($array) . ')"' . \print_r($array, true) . '" is not an array.');
7459
+            throw new \RuntimeException('Can not set value at this path "'.$key.'" because ('.\gettype($array).')"'.\print_r($array, true).'" is not an array.');
7460 7460
         }
7461 7461
 
7462 7462
         $array[$key] = $value;
@@ -7528,7 +7528,7 @@  discard block
 block discarded – undo
7528 7528
                 &&
7529 7529
                 \count(\array_diff_key($properties, $data)) > 0
7530 7530
             ) {
7531
-                throw new \TypeError('Property mismatch - input: ' . \print_r(\array_keys($data), true) . ' | expected: ' . \print_r(\array_keys($properties), true));
7531
+                throw new \TypeError('Property mismatch - input: '.\print_r(\array_keys($data), true).' | expected: '.\print_r(\array_keys($properties), true));
7532 7532
             }
7533 7533
 
7534 7534
             foreach ($data as $key => &$valueInner) {
@@ -7645,7 +7645,7 @@  discard block
 block discarded – undo
7645 7645
              *
7646 7646
              * @return void
7647 7647
              */
7648
-            static function (&$item) {
7648
+            static function(&$item) {
7649 7649
                 if ($item instanceof self) {
7650 7650
                     $item = $item->getArray();
7651 7651
                 }
@@ -7670,7 +7670,7 @@  discard block
 block discarded – undo
7670 7670
             &&
7671 7671
             $this->checkPropertiesMismatch === true
7672 7672
         ) {
7673
-            throw new \TypeError('The key "' . $key . '" does not exists as "@property" phpdoc. (' . \get_class($this) . ').');
7673
+            throw new \TypeError('The key "'.$key.'" does not exists as "@property" phpdoc. ('.\get_class($this).').');
7674 7674
         }
7675 7675
 
7676 7676
         if (isset($this->properties[self::ARRAYY_HELPER_TYPES_FOR_ALL_PROPERTIES])) {
Please login to merge, or discard this patch.