@@ -955,25 +955,25 @@ discard block |
||
| 955 | 955 | { |
| 956 | 956 | if ($recursive === true) { |
| 957 | 957 | return \count( |
| 958 | - \array_intersect($needles, $this->keys(true)->getArray()), |
|
| 959 | - \COUNT_RECURSIVE |
|
| 960 | - ) |
|
| 961 | - === |
|
| 962 | - \count( |
|
| 963 | - $needles, |
|
| 964 | - \COUNT_RECURSIVE |
|
| 965 | - ); |
|
| 958 | + \array_intersect($needles, $this->keys(true)->getArray()), |
|
| 959 | + \COUNT_RECURSIVE |
|
| 960 | + ) |
|
| 961 | + === |
|
| 962 | + \count( |
|
| 963 | + $needles, |
|
| 964 | + \COUNT_RECURSIVE |
|
| 965 | + ); |
|
| 966 | 966 | } |
| 967 | 967 | |
| 968 | 968 | return \count( |
| 969 | - \array_intersect($needles, $this->keys()->getArray()), |
|
| 970 | - \COUNT_NORMAL |
|
| 971 | - ) |
|
| 972 | - === |
|
| 973 | - \count( |
|
| 974 | - $needles, |
|
| 975 | - \COUNT_NORMAL |
|
| 976 | - ); |
|
| 969 | + \array_intersect($needles, $this->keys()->getArray()), |
|
| 970 | + \COUNT_NORMAL |
|
| 971 | + ) |
|
| 972 | + === |
|
| 973 | + \count( |
|
| 974 | + $needles, |
|
| 975 | + \COUNT_NORMAL |
|
| 976 | + ); |
|
| 977 | 977 | } |
| 978 | 978 | |
| 979 | 979 | /** |
@@ -1028,8 +1028,8 @@ discard block |
||
| 1028 | 1028 | public function containsValues(array $needles): bool |
| 1029 | 1029 | { |
| 1030 | 1030 | return \count(\array_intersect($needles, $this->getArray()), \COUNT_NORMAL) |
| 1031 | - === |
|
| 1032 | - \count($needles, \COUNT_NORMAL); |
|
| 1031 | + === |
|
| 1032 | + \count($needles, \COUNT_NORMAL); |
|
| 1033 | 1033 | } |
| 1034 | 1034 | |
| 1035 | 1035 | /** |
@@ -2170,15 +2170,15 @@ discard block |
||
| 2170 | 2170 | |
| 2171 | 2171 | if ($recursive === true) { |
| 2172 | 2172 | return $this->array_keys_recursive($this->getArray()) |
| 2173 | - === |
|
| 2174 | - \range(0, \count($this->getArray(), \COUNT_RECURSIVE) - 1); |
|
| 2173 | + === |
|
| 2174 | + \range(0, \count($this->getArray(), \COUNT_RECURSIVE) - 1); |
|
| 2175 | 2175 | } |
| 2176 | 2176 | |
| 2177 | 2177 | // non recursive |
| 2178 | 2178 | |
| 2179 | 2179 | return \array_keys($this->getArray()) |
| 2180 | - === |
|
| 2181 | - \range(0, \count($this->getArray(), \COUNT_NORMAL) - 1); |
|
| 2180 | + === |
|
| 2181 | + \range(0, \count($this->getArray(), \COUNT_NORMAL) - 1); |
|
| 2182 | 2182 | } |
| 2183 | 2183 | |
| 2184 | 2184 | /** |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | && |
| 106 | 106 | \count(\array_diff_key($this->properties, $array)) > 0 |
| 107 | 107 | ) { |
| 108 | - throw new \InvalidArgumentException('Property mismatch - input: ' . \print_r(\array_keys($array), true) . ' | expected: ' . \print_r(\array_keys($this->properties), true)); |
|
| 108 | + throw new \InvalidArgumentException('Property mismatch - input: '.\print_r(\array_keys($array), true).' | expected: '.\print_r(\array_keys($this->properties), true)); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | foreach ($array as $key => &$value) { |
@@ -451,7 +451,7 @@ discard block |
||
| 451 | 451 | |
| 452 | 452 | $this->callAtPath( |
| 453 | 453 | $containerPath, |
| 454 | - static function ($container) use ($lastOffset, &$offsetExists) { |
|
| 454 | + static function($container) use ($lastOffset, &$offsetExists) { |
|
| 455 | 455 | $offsetExists = \array_key_exists($lastOffset, $container); |
| 456 | 456 | } |
| 457 | 457 | ); |
@@ -515,7 +515,7 @@ discard block |
||
| 515 | 515 | |
| 516 | 516 | $this->callAtPath( |
| 517 | 517 | \implode($this->pathSeparator, $path), |
| 518 | - static function (&$offset) use ($pathToUnset) { |
|
| 518 | + static function(&$offset) use ($pathToUnset) { |
|
| 519 | 519 | unset($offset[$pathToUnset]); |
| 520 | 520 | } |
| 521 | 521 | ); |
@@ -552,7 +552,7 @@ discard block |
||
| 552 | 552 | } |
| 553 | 553 | |
| 554 | 554 | if (\strpos($class, '\\') === 0) { |
| 555 | - $class = '\\' . $class; |
|
| 555 | + $class = '\\'.$class; |
|
| 556 | 556 | if (\class_exists($class)) { |
| 557 | 557 | $this->iteratorClass = $class; |
| 558 | 558 | |
@@ -560,7 +560,7 @@ discard block |
||
| 560 | 560 | } |
| 561 | 561 | } |
| 562 | 562 | |
| 563 | - throw new \InvalidArgumentException('The iterator class does not exist: ' . $class); |
|
| 563 | + throw new \InvalidArgumentException('The iterator class does not exist: '.$class); |
|
| 564 | 564 | } |
| 565 | 565 | |
| 566 | 566 | /** |
@@ -668,13 +668,13 @@ discard block |
||
| 668 | 668 | |
| 669 | 669 | foreach ($this->getGenerator() as $key => $item) { |
| 670 | 670 | if ($item instanceof self) { |
| 671 | - $result[$prefix . $key] = $item->appendToEachKey($prefix); |
|
| 671 | + $result[$prefix.$key] = $item->appendToEachKey($prefix); |
|
| 672 | 672 | } elseif (\is_array($item)) { |
| 673 | - $result[$prefix . $key] = self::create($item, $this->iteratorClass, false) |
|
| 673 | + $result[$prefix.$key] = self::create($item, $this->iteratorClass, false) |
|
| 674 | 674 | ->appendToEachKey($prefix) |
| 675 | 675 | ->toArray(); |
| 676 | 676 | } else { |
| 677 | - $result[$prefix . $key] = $item; |
|
| 677 | + $result[$prefix.$key] = $item; |
|
| 678 | 678 | } |
| 679 | 679 | } |
| 680 | 680 | |
@@ -702,7 +702,7 @@ discard block |
||
| 702 | 702 | } elseif (\is_object($item)) { |
| 703 | 703 | $result[$key] = $item; |
| 704 | 704 | } else { |
| 705 | - $result[$key] = $prefix . $item; |
|
| 705 | + $result[$key] = $prefix.$item; |
|
| 706 | 706 | } |
| 707 | 707 | } |
| 708 | 708 | |
@@ -853,7 +853,7 @@ discard block |
||
| 853 | 853 | public function clean(): self |
| 854 | 854 | { |
| 855 | 855 | return $this->filter( |
| 856 | - static function ($value) { |
|
| 856 | + static function($value) { |
|
| 857 | 857 | return (bool) $value; |
| 858 | 858 | } |
| 859 | 859 | ); |
@@ -906,7 +906,7 @@ discard block |
||
| 906 | 906 | return $this->in_array_recursive( |
| 907 | 907 | \mb_strtoupper((string) $value), |
| 908 | 908 | $this->walk( |
| 909 | - static function (&$val) { |
|
| 909 | + static function(&$val) { |
|
| 910 | 910 | /** @noinspection PhpComposerExtensionStubsInspection */ |
| 911 | 911 | $val = \mb_strtoupper((string) $val); |
| 912 | 912 | }, |
@@ -920,7 +920,7 @@ discard block |
||
| 920 | 920 | return \in_array( |
| 921 | 921 | \mb_strtoupper((string) $value), |
| 922 | 922 | $this->walk( |
| 923 | - static function (&$val) { |
|
| 923 | + static function(&$val) { |
|
| 924 | 924 | /** @noinspection PhpComposerExtensionStubsInspection */ |
| 925 | 925 | $val = \mb_strtoupper((string) $val); |
| 926 | 926 | }, |
@@ -1200,7 +1200,7 @@ discard block |
||
| 1200 | 1200 | // trim all string in the array |
| 1201 | 1201 | \array_walk( |
| 1202 | 1202 | $array, |
| 1203 | - static function (&$val) { |
|
| 1203 | + static function(&$val) { |
|
| 1204 | 1204 | if (\is_string($val)) { |
| 1205 | 1205 | $val = \trim($val); |
| 1206 | 1206 | } |
@@ -1528,40 +1528,40 @@ discard block |
||
| 1528 | 1528 | } |
| 1529 | 1529 | |
| 1530 | 1530 | $ops = [ |
| 1531 | - 'eq' => static function ($item, $prop, $value) { |
|
| 1531 | + 'eq' => static function($item, $prop, $value) { |
|
| 1532 | 1532 | return $item[$prop] === $value; |
| 1533 | 1533 | }, |
| 1534 | - 'gt' => static function ($item, $prop, $value) { |
|
| 1534 | + 'gt' => static function($item, $prop, $value) { |
|
| 1535 | 1535 | return $item[$prop] > $value; |
| 1536 | 1536 | }, |
| 1537 | - 'ge' => static function ($item, $prop, $value) { |
|
| 1537 | + 'ge' => static function($item, $prop, $value) { |
|
| 1538 | 1538 | return $item[$prop] >= $value; |
| 1539 | 1539 | }, |
| 1540 | - 'gte' => static function ($item, $prop, $value) { |
|
| 1540 | + 'gte' => static function($item, $prop, $value) { |
|
| 1541 | 1541 | return $item[$prop] >= $value; |
| 1542 | 1542 | }, |
| 1543 | - 'lt' => static function ($item, $prop, $value) { |
|
| 1543 | + 'lt' => static function($item, $prop, $value) { |
|
| 1544 | 1544 | return $item[$prop] < $value; |
| 1545 | 1545 | }, |
| 1546 | - 'le' => static function ($item, $prop, $value) { |
|
| 1546 | + 'le' => static function($item, $prop, $value) { |
|
| 1547 | 1547 | return $item[$prop] <= $value; |
| 1548 | 1548 | }, |
| 1549 | - 'lte' => static function ($item, $prop, $value) { |
|
| 1549 | + 'lte' => static function($item, $prop, $value) { |
|
| 1550 | 1550 | return $item[$prop] <= $value; |
| 1551 | 1551 | }, |
| 1552 | - 'ne' => static function ($item, $prop, $value) { |
|
| 1552 | + 'ne' => static function($item, $prop, $value) { |
|
| 1553 | 1553 | return $item[$prop] !== $value; |
| 1554 | 1554 | }, |
| 1555 | - 'contains' => static function ($item, $prop, $value) { |
|
| 1555 | + 'contains' => static function($item, $prop, $value) { |
|
| 1556 | 1556 | return \in_array($item[$prop], (array) $value, true); |
| 1557 | 1557 | }, |
| 1558 | - 'notContains' => static function ($item, $prop, $value) { |
|
| 1558 | + 'notContains' => static function($item, $prop, $value) { |
|
| 1559 | 1559 | return !\in_array($item[$prop], (array) $value, true); |
| 1560 | 1560 | }, |
| 1561 | - 'newer' => static function ($item, $prop, $value) { |
|
| 1561 | + 'newer' => static function($item, $prop, $value) { |
|
| 1562 | 1562 | return \strtotime($item[$prop]) > \strtotime($value); |
| 1563 | 1563 | }, |
| 1564 | - 'older' => static function ($item, $prop, $value) { |
|
| 1564 | + 'older' => static function($item, $prop, $value) { |
|
| 1565 | 1565 | return \strtotime($item[$prop]) < \strtotime($value); |
| 1566 | 1566 | }, |
| 1567 | 1567 | ]; |
@@ -1569,7 +1569,7 @@ discard block |
||
| 1569 | 1569 | $result = \array_values( |
| 1570 | 1570 | \array_filter( |
| 1571 | 1571 | $this->getArray(), |
| 1572 | - static function ($item) use ( |
|
| 1572 | + static function($item) use ( |
|
| 1573 | 1573 | $property, |
| 1574 | 1574 | $value, |
| 1575 | 1575 | $ops, |
@@ -2076,7 +2076,7 @@ discard block |
||
| 2076 | 2076 | \array_uintersect( |
| 2077 | 2077 | $this->array, |
| 2078 | 2078 | $search, |
| 2079 | - static function ($a, $b) { |
|
| 2079 | + static function($a, $b) { |
|
| 2080 | 2080 | return $a === $b ? 0 : -1; |
| 2081 | 2081 | } |
| 2082 | 2082 | ), |
@@ -2779,7 +2779,7 @@ discard block |
||
| 2779 | 2779 | )->prependToEachKey($suffix) |
| 2780 | 2780 | ->toArray(); |
| 2781 | 2781 | } else { |
| 2782 | - $result[$key . $suffix] = $item; |
|
| 2782 | + $result[$key.$suffix] = $item; |
|
| 2783 | 2783 | } |
| 2784 | 2784 | } |
| 2785 | 2785 | |
@@ -2816,7 +2816,7 @@ discard block |
||
| 2816 | 2816 | } elseif (\is_object($item)) { |
| 2817 | 2817 | $result[$key] = $item; |
| 2818 | 2818 | } else { |
| 2819 | - $result[$key] = $item . $suffix; |
|
| 2819 | + $result[$key] = $item.$suffix; |
|
| 2820 | 2820 | } |
| 2821 | 2821 | } |
| 2822 | 2822 | |
@@ -3347,7 +3347,7 @@ discard block |
||
| 3347 | 3347 | public function replaceValues($search, $replacement = ''): self |
| 3348 | 3348 | { |
| 3349 | 3349 | $array = $this->each( |
| 3350 | - static function ($value) use ($search, $replacement) { |
|
| 3350 | + static function($value) use ($search, $replacement) { |
|
| 3351 | 3351 | return \str_replace($search, $replacement, $value); |
| 3352 | 3352 | } |
| 3353 | 3353 | ); |
@@ -3751,7 +3751,7 @@ discard block |
||
| 3751 | 3751 | |
| 3752 | 3752 | $that = $this; |
| 3753 | 3753 | $results = $arrayy->each( |
| 3754 | - static function ($value) use ($sorter, $that) { |
|
| 3754 | + static function($value) use ($sorter, $that) { |
|
| 3755 | 3755 | return \is_callable($sorter) ? $sorter($value) : $that->get($sorter, null, $value); |
| 3756 | 3756 | } |
| 3757 | 3757 | ); |
@@ -3809,7 +3809,7 @@ discard block |
||
| 3809 | 3809 | public function stripEmpty(): self |
| 3810 | 3810 | { |
| 3811 | 3811 | return $this->filter( |
| 3812 | - static function ($item) { |
|
| 3812 | + static function($item) { |
|
| 3813 | 3813 | if ($item === null) { |
| 3814 | 3814 | return false; |
| 3815 | 3815 | } |
@@ -3889,7 +3889,7 @@ discard block |
||
| 3889 | 3889 | // INFO: \array_unique() can't handle e.g. "stdClass"-values in an array |
| 3890 | 3890 | |
| 3891 | 3891 | $this->array = $this->reduce( |
| 3892 | - static function ($resultArray, $value) { |
|
| 3892 | + static function($resultArray, $value) { |
|
| 3893 | 3893 | if (!\in_array($value, $resultArray, true)) { |
| 3894 | 3894 | $resultArray[] = $value; |
| 3895 | 3895 | } |
@@ -3918,7 +3918,7 @@ discard block |
||
| 3918 | 3918 | |
| 3919 | 3919 | $this->array = \array_reduce( |
| 3920 | 3920 | \array_keys($array), |
| 3921 | - static function ($resultArray, $key) use ($array) { |
|
| 3921 | + static function($resultArray, $key) use ($array) { |
|
| 3922 | 3922 | if (!\in_array($array[$key], $resultArray, true)) { |
| 3923 | 3923 | $resultArray[$key] = $array[$key]; |
| 3924 | 3924 | } |
@@ -4360,7 +4360,7 @@ discard block |
||
| 4360 | 4360 | $this->properties !== [] |
| 4361 | 4361 | ) { |
| 4362 | 4362 | if (isset($this->properties[$key]) === false) { |
| 4363 | - throw new \InvalidArgumentException('The key ' . $key . ' does not exists as @property in the class (' . \get_class($this) . ').'); |
|
| 4363 | + throw new \InvalidArgumentException('The key '.$key.' does not exists as @property in the class ('.\get_class($this).').'); |
|
| 4364 | 4364 | } |
| 4365 | 4365 | |
| 4366 | 4366 | $this->properties[$key]->checkType($value); |
@@ -4500,7 +4500,7 @@ discard block |
||
| 4500 | 4500 | private function getPropertiesFromPhpDoc(): array |
| 4501 | 4501 | { |
| 4502 | 4502 | static $PROPERTY_CACHE = []; |
| 4503 | - $cacheKey = 'Class::' . static::class; |
|
| 4503 | + $cacheKey = 'Class::'.static::class; |
|
| 4504 | 4504 | |
| 4505 | 4505 | if (isset($PROPERTY_CACHE[$cacheKey])) { |
| 4506 | 4506 | return $PROPERTY_CACHE[$cacheKey]; |
@@ -50,6 +50,7 @@ |
||
| 50 | 50 | * Merge current items and items of given collections into a new one. |
| 51 | 51 | * |
| 52 | 52 | * @param CollectionInterface ...$collections The collections to merge. |
| 53 | + * @param CollectionInterface[] $collections |
|
| 53 | 54 | * |
| 54 | 55 | * @throws \InvalidArgumentException if any of the given collections are not of the same type |
| 55 | 56 | * |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | { |
| 83 | 83 | if ($this->checkType($this->getType(), $value) === false) { |
| 84 | 84 | throw new \InvalidArgumentException( |
| 85 | - 'Value must be of type ' . $this->getType() . '; value is ' . $this->valueToString($value) |
|
| 85 | + 'Value must be of type '.$this->getType().'; value is '.$this->valueToString($value) |
|
| 86 | 86 | ); |
| 87 | 87 | } |
| 88 | 88 | |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | { |
| 103 | 103 | if ($this->checkType($this->getType(), $value) === false) { |
| 104 | 104 | throw new \InvalidArgumentException( |
| 105 | - 'Value must be of type ' . $this->getType() . '; value is ' . $this->valueToString($value) |
|
| 105 | + 'Value must be of type '.$this->getType().'; value is '.$this->valueToString($value) |
|
| 106 | 106 | ); |
| 107 | 107 | } |
| 108 | 108 | |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | { |
| 123 | 123 | if ($this->checkType($this->getType(), $value) === false) { |
| 124 | 124 | throw new \InvalidArgumentException( |
| 125 | - 'Value must be of type ' . $this->getType() . '; value is ' . $this->valueToString($value) |
|
| 125 | + 'Value must be of type '.$this->getType().'; value is '.$this->valueToString($value) |
|
| 126 | 126 | ); |
| 127 | 127 | } |
| 128 | 128 | |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | public function where(string $keyOrPropertyOrMethod, $value): CollectionInterface |
| 164 | 164 | { |
| 165 | 165 | return $this->filter( |
| 166 | - function ($item) use ($keyOrPropertyOrMethod, $value) { |
|
| 166 | + function($item) use ($keyOrPropertyOrMethod, $value) { |
|
| 167 | 167 | $accessorValue = $this->extractValue( |
| 168 | 168 | $item, |
| 169 | 169 | $keyOrPropertyOrMethod |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | { |
| 188 | 188 | if ($this->checkType($this->getType(), $value) === false) { |
| 189 | 189 | throw new \InvalidArgumentException( |
| 190 | - 'Value must be of type ' . $this->getType() . '; value is ' . $this->valueToString($value) |
|
| 190 | + 'Value must be of type '.$this->getType().'; value is '.$this->valueToString($value) |
|
| 191 | 191 | ); |
| 192 | 192 | } |
| 193 | 193 | |
@@ -296,10 +296,10 @@ discard block |
||
| 296 | 296 | |
| 297 | 297 | // resource |
| 298 | 298 | if (\is_resource($value)) { |
| 299 | - return \get_resource_type($value) . ' resource #' . (int) $value; |
|
| 299 | + return \get_resource_type($value).' resource #'.(int) $value; |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | // object |
| 303 | - return \get_class($value) . ' Object'; |
|
| 303 | + return \get_class($value).' Object'; |
|
| 304 | 304 | } |
| 305 | 305 | } |