@@ -42,7 +42,7 @@ |
||
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | if (!isset(static::$methodArgs[$name])) { |
| 45 | - throw new \BadMethodCallException($name . ' is not a valid method'); |
|
| 45 | + throw new \BadMethodCallException($name.' is not a valid method'); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | $numArgs = \count($arguments); |
@@ -90,9 +90,9 @@ discard block |
||
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | if ($type instanceof \phpDocumentor\Reflection\Types\Array_) { |
| 93 | - $valueTypeTmp = $type->getValueType() . ''; |
|
| 93 | + $valueTypeTmp = $type->getValueType().''; |
|
| 94 | 94 | if ($valueTypeTmp !== 'mixed') { |
| 95 | - return $valueTypeTmp . '[]'; |
|
| 95 | + return $valueTypeTmp.'[]'; |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | return 'array'; |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | return 'resource'; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - return $type . ''; |
|
| 141 | + return $type.''; |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | /** |
@@ -150,6 +150,6 @@ discard block |
||
| 150 | 150 | */ |
| 151 | 151 | public function throwException($expectedTypes, $value, $type): \Throwable |
| 152 | 152 | { |
| 153 | - throw new \TypeError("Invalid type: expected \"{$this->property_name}\" to be of type {{$expectedTypes}}, instead got value \"" . $this->valueToString($value) . '" (' . \print_r($value, true) . ") with type {{$type}}."); |
|
| 153 | + throw new \TypeError("Invalid type: expected \"{$this->property_name}\" to be of type {{$expectedTypes}}, instead got value \"".$this->valueToString($value).'" ('.\print_r($value, true).") with type {{$type}}."); |
|
| 154 | 154 | } |
| 155 | 155 | } |
@@ -111,11 +111,11 @@ |
||
| 111 | 111 | |
| 112 | 112 | // resource |
| 113 | 113 | if (\is_resource($value)) { |
| 114 | - return \get_resource_type($value) . ' resource #' . (int) $value; |
|
| 114 | + return \get_resource_type($value).' resource #'.(int) $value; |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | if (\is_object($value)) { |
| 118 | - return \get_class($value) . ' Object'; |
|
| 118 | + return \get_class($value).' Object'; |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | return ''; |
@@ -82,32 +82,32 @@ |
||
| 82 | 82 | \gettype($value) === (self::$typeMapping[$type] ?? $type) |
| 83 | 83 | || |
| 84 | 84 | ( |
| 85 | - $type === 'scalar' |
|
| 85 | + $type === 'scalar' |
|
| 86 | 86 | && |
| 87 | 87 | \is_scalar($value) |
| 88 | - ) |
|
| 88 | + ) |
|
| 89 | 89 | || |
| 90 | 90 | ( |
| 91 | - $type === 'callable' |
|
| 91 | + $type === 'callable' |
|
| 92 | 92 | && |
| 93 | 93 | \is_callable($value) |
| 94 | - ) |
|
| 94 | + ) |
|
| 95 | 95 | || |
| 96 | 96 | ( |
| 97 | - $type === 'numeric' |
|
| 97 | + $type === 'numeric' |
|
| 98 | 98 | && |
| 99 | 99 | ( |
| 100 | - \is_float($value) |
|
| 100 | + \is_float($value) |
|
| 101 | 101 | || |
| 102 | 102 | \is_int($value) |
| 103 | - ) |
|
| 104 | - ) |
|
| 103 | + ) |
|
| 104 | + ) |
|
| 105 | 105 | || |
| 106 | 106 | ( |
| 107 | - $type === 'resource' |
|
| 107 | + $type === 'resource' |
|
| 108 | 108 | && |
| 109 | 109 | \is_resource($value) |
| 110 | - ); |
|
| 110 | + ); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /** |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | */ |
| 27 | 27 | public function throwException($expectedTypes, $value, $type): \Throwable |
| 28 | 28 | { |
| 29 | - throw new \TypeError("Invalid type: expected to be of type {{$expectedTypes}}, instead got value `" . \print_r($value, true) . "` with type {{$type}}."); |
|
| 29 | + throw new \TypeError("Invalid type: expected to be of type {{$expectedTypes}}, instead got value `".\print_r($value, true)."` with type {{$type}}."); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -290,9 +290,9 @@ |
||
| 290 | 290 | $return = static::create(); |
| 291 | 291 | $jsonObject = \json_decode($json, false); |
| 292 | 292 | $mapper = new \Arrayy\Mapper\Json(); |
| 293 | - $mapper->undefinedPropertyHandler = static function ($object, $key, $jsonValue) use ($return) { |
|
| 293 | + $mapper->undefinedPropertyHandler = static function($object, $key, $jsonValue) use ($return) { |
|
| 294 | 294 | if ($return->checkForMissingPropertiesInConstructor) { |
| 295 | - throw new \TypeError('Property mismatch - input: ' . \print_r(['key' => $key, 'jsonValue' => $jsonValue], true) . ' for object: ' . \get_class($object)); |
|
| 295 | + throw new \TypeError('Property mismatch - input: '.\print_r(['key' => $key, 'jsonValue' => $jsonValue], true).' for object: '.\get_class($object)); |
|
| 296 | 296 | } |
| 297 | 297 | }; |
| 298 | 298 | |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | if (!\is_object($object)) { |
| 67 | 67 | throw new \InvalidArgumentException( |
| 68 | - 'JsonMapper::map() requires second argument to be an object, ' . \gettype($object) . ' given.' |
|
| 68 | + 'JsonMapper::map() requires second argument to be an object, '.\gettype($object).' given.' |
|
| 69 | 69 | ); |
| 70 | 70 | } |
| 71 | 71 | |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | $type = $this->removeNullable($type); |
| 115 | 115 | } elseif ($jsonValue === null) { |
| 116 | 116 | throw new \InvalidArgumentException( |
| 117 | - 'JSON property "' . $key . '" in class "' . $strClassName . '" must not be NULL' |
|
| 117 | + 'JSON property "'.$key.'" in class "'.$strClassName.'" must not be NULL' |
|
| 118 | 118 | ); |
| 119 | 119 | } |
| 120 | 120 | |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | if ($this->isSimpleType($type)) { |
| 142 | 142 | if ($type === 'string' && \is_object($jsonValue)) { |
| 143 | 143 | throw new \InvalidArgumentException( |
| 144 | - 'JSON property "' . $key . '" in class "' . $strClassName . '" is an object and cannot be converted to a string' |
|
| 144 | + 'JSON property "'.$key.'" in class "'.$strClassName.'" is an object and cannot be converted to a string' |
|
| 145 | 145 | ); |
| 146 | 146 | } |
| 147 | 147 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | if ($type === '') { |
| 164 | 164 | throw new \InvalidArgumentException( |
| 165 | - 'Empty type at property "' . $strClassName . '::$' . $key . '"' |
|
| 165 | + 'Empty type at property "'.$strClassName.'::$'.$key.'"' |
|
| 166 | 166 | ); |
| 167 | 167 | } |
| 168 | 168 | |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | $this->isScalarType(\gettype($jsonValue)) |
| 197 | 197 | ) { |
| 198 | 198 | throw new \InvalidArgumentException( |
| 199 | - 'JSON property "' . $key . '" must be an array, ' . \gettype($jsonValue) . ' given' |
|
| 199 | + 'JSON property "'.$key.'" must be an array, '.\gettype($jsonValue).' given' |
|
| 200 | 200 | ); |
| 201 | 201 | } |
| 202 | 202 | |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | } |
| 274 | 274 | } elseif ($this->isScalarType($class)) { |
| 275 | 275 | throw new \InvalidArgumentException( |
| 276 | - 'JSON property "' . ($parent_key ?: '?') . '" is an array of type "' . $class . '" but contained a value of type "' . \gettype($jsonValue) . '"' |
|
| 276 | + 'JSON property "'.($parent_key ?: '?').'" is an array of type "'.$class.'" but contained a value of type "'.\gettype($jsonValue).'"' |
|
| 277 | 277 | ); |
| 278 | 278 | } elseif (\is_a($class, \ArrayObject::class, true)) { |
| 279 | 279 | /** @noinspection PhpSillyAssignmentInspection - phpstan helper */ |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | //create a full qualified namespace |
| 332 | - return '\\' . $strNs . '\\' . $type; |
|
| 332 | + return '\\'.$strNs.'\\'.$type; |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | /** |
@@ -633,7 +633,7 @@ discard block |
||
| 633 | 633 | */ |
| 634 | 634 | private function isNullable($type): bool |
| 635 | 635 | { |
| 636 | - return \stripos('|' . $type . '|', '|null|') !== false; |
|
| 636 | + return \stripos('|'.$type.'|', '|null|') !== false; |
|
| 637 | 637 | } |
| 638 | 638 | |
| 639 | 639 | /** |
@@ -650,7 +650,7 @@ discard block |
||
| 650 | 650 | } |
| 651 | 651 | |
| 652 | 652 | return \substr( |
| 653 | - \str_ireplace('|null|', '|', '|' . $type . '|'), |
|
| 653 | + \str_ireplace('|null|', '|', '|'.$type.'|'), |
|
| 654 | 654 | 1, |
| 655 | 655 | -1 |
| 656 | 656 | ); |
@@ -1,11 +1,11 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -require __DIR__ . '/../vendor/autoload.php'; |
|
| 4 | -require __DIR__ . '/vendor/autoload.php'; |
|
| 3 | +require __DIR__.'/../vendor/autoload.php'; |
|
| 4 | +require __DIR__.'/vendor/autoload.php'; |
|
| 5 | 5 | |
| 6 | 6 | $readmeText = (new \voku\PhpReadmeHelper\GenerateApi())->generate( |
| 7 | - __DIR__ . '/../src/Arrayy.php', |
|
| 8 | - __DIR__ . '/docs/base.md' |
|
| 7 | + __DIR__.'/../src/Arrayy.php', |
|
| 8 | + __DIR__.'/docs/base.md' |
|
| 9 | 9 | ); |
| 10 | 10 | |
| 11 | -file_put_contents(__DIR__ . '/../README.md', $readmeText); |
|
| 11 | +file_put_contents(__DIR__.'/../README.md', $readmeText); |
|
@@ -1542,11 +1542,11 @@ |
||
| 1542 | 1542 | ), |
| 1543 | 1543 | \COUNT_NORMAL |
| 1544 | 1544 | ) |
| 1545 | - === |
|
| 1546 | - \count( |
|
| 1547 | - $needles, |
|
| 1548 | - \COUNT_NORMAL |
|
| 1549 | - ); |
|
| 1545 | + === |
|
| 1546 | + \count( |
|
| 1547 | + $needles, |
|
| 1548 | + \COUNT_NORMAL |
|
| 1549 | + ); |
|
| 1550 | 1550 | } |
| 1551 | 1551 | |
| 1552 | 1552 | /** |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | /** |
| 329 | 329 | * @phpstan-return \Generator<TKey,T> $generator |
| 330 | 330 | */ |
| 331 | - $generator = function () use ($key, $value): \Generator { |
|
| 331 | + $generator = function() use ($key, $value): \Generator { |
|
| 332 | 332 | if ($this->properties !== []) { |
| 333 | 333 | $this->checkType($key, $value); |
| 334 | 334 | } |
@@ -516,7 +516,7 @@ discard block |
||
| 516 | 516 | |
| 517 | 517 | /** @phpstan-var \Arrayy\ArrayyRewindableGenerator<TKey,T> */ |
| 518 | 518 | $generatorTmp = new ArrayyRewindableExtendedGenerator( |
| 519 | - static function () use ($generator): \Generator { |
|
| 519 | + static function() use ($generator): \Generator { |
|
| 520 | 520 | yield from $generator; |
| 521 | 521 | }, |
| 522 | 522 | null, |
@@ -724,7 +724,7 @@ discard block |
||
| 724 | 724 | */ |
| 725 | 725 | $this->callAtPath( |
| 726 | 726 | $containerPath, |
| 727 | - static function ($container) use ($lastOffset, &$offsetExists) { |
|
| 727 | + static function($container) use ($lastOffset, &$offsetExists) { |
|
| 728 | 728 | $offsetExists = \array_key_exists($lastOffset, $container); |
| 729 | 729 | } |
| 730 | 730 | ); |
@@ -829,7 +829,7 @@ discard block |
||
| 829 | 829 | */ |
| 830 | 830 | $this->callAtPath( |
| 831 | 831 | \implode($this->pathSeparator, $path), |
| 832 | - static function (&$offset) use ($pathToUnset) { |
|
| 832 | + static function(&$offset) use ($pathToUnset) { |
|
| 833 | 833 | if (\is_array($offset)) { |
| 834 | 834 | unset($offset[$pathToUnset]); |
| 835 | 835 | } else { |
@@ -884,7 +884,7 @@ discard block |
||
| 884 | 884 | |
| 885 | 885 | if (\strpos($iteratorClass, '\\') === 0) { |
| 886 | 886 | /** @var class-string<\Arrayy\ArrayyIterator<TKey,T>> $iteratorClass */ |
| 887 | - $iteratorClass = '\\' . $iteratorClass; |
|
| 887 | + $iteratorClass = '\\'.$iteratorClass; |
|
| 888 | 888 | if (\class_exists($iteratorClass)) { |
| 889 | 889 | /** |
| 890 | 890 | * @psalm-suppress PropertyTypeCoercion |
@@ -895,7 +895,7 @@ discard block |
||
| 895 | 895 | } |
| 896 | 896 | } |
| 897 | 897 | |
| 898 | - throw new \InvalidArgumentException('The iterator class does not exist: ' . $iteratorClass); |
|
| 898 | + throw new \InvalidArgumentException('The iterator class does not exist: '.$iteratorClass); |
|
| 899 | 899 | } |
| 900 | 900 | |
| 901 | 901 | /** |
@@ -1074,13 +1074,13 @@ discard block |
||
| 1074 | 1074 | |
| 1075 | 1075 | foreach ($this->getGenerator() as $key => $item) { |
| 1076 | 1076 | if ($item instanceof self) { |
| 1077 | - $result[$prefix . $key] = $item->appendToEachKey($prefix); |
|
| 1077 | + $result[$prefix.$key] = $item->appendToEachKey($prefix); |
|
| 1078 | 1078 | } elseif (\is_array($item)) { |
| 1079 | - $result[$prefix . $key] = self::create($item, $this->iteratorClass, false) |
|
| 1079 | + $result[$prefix.$key] = self::create($item, $this->iteratorClass, false) |
|
| 1080 | 1080 | ->appendToEachKey($prefix) |
| 1081 | 1081 | ->toArray(); |
| 1082 | 1082 | } else { |
| 1083 | - $result[$prefix . $key] = $item; |
|
| 1083 | + $result[$prefix.$key] = $item; |
|
| 1084 | 1084 | } |
| 1085 | 1085 | } |
| 1086 | 1086 | |
@@ -1115,7 +1115,7 @@ discard block |
||
| 1115 | 1115 | } elseif (\is_object($item) === true) { |
| 1116 | 1116 | $result[$key] = $item; |
| 1117 | 1117 | } else { |
| 1118 | - $result[$key] = $prefix . $item; |
|
| 1118 | + $result[$key] = $prefix.$item; |
|
| 1119 | 1119 | } |
| 1120 | 1120 | } |
| 1121 | 1121 | |
@@ -1302,7 +1302,7 @@ discard block |
||
| 1302 | 1302 | public function chunk($size, $preserveKeys = false): self |
| 1303 | 1303 | { |
| 1304 | 1304 | if ($preserveKeys) { |
| 1305 | - $generator = function () use ($size) { |
|
| 1305 | + $generator = function() use ($size) { |
|
| 1306 | 1306 | $values = []; |
| 1307 | 1307 | $tmpCounter = 0; |
| 1308 | 1308 | foreach ($this->getGenerator() as $key => $value) { |
@@ -1322,7 +1322,7 @@ discard block |
||
| 1322 | 1322 | } |
| 1323 | 1323 | }; |
| 1324 | 1324 | } else { |
| 1325 | - $generator = function () use ($size) { |
|
| 1325 | + $generator = function() use ($size) { |
|
| 1326 | 1326 | $values = []; |
| 1327 | 1327 | $tmpCounter = 0; |
| 1328 | 1328 | foreach ($this->getGenerator() as $value) { |
@@ -1366,7 +1366,7 @@ discard block |
||
| 1366 | 1366 | public function clean(): self |
| 1367 | 1367 | { |
| 1368 | 1368 | return $this->filter( |
| 1369 | - static function ($value) { |
|
| 1369 | + static function($value) { |
|
| 1370 | 1370 | return (bool) $value; |
| 1371 | 1371 | } |
| 1372 | 1372 | ); |
@@ -1707,9 +1707,9 @@ discard block |
||
| 1707 | 1707 | |
| 1708 | 1708 | foreach ($items as $key => $value) { |
| 1709 | 1709 | if (\is_array($value) && $value !== []) { |
| 1710 | - $flatten[] = $this->flatten($delimiter, $prepend . $key . $delimiter, $value); |
|
| 1710 | + $flatten[] = $this->flatten($delimiter, $prepend.$key.$delimiter, $value); |
|
| 1711 | 1711 | } else { |
| 1712 | - $flatten[] = [$prepend . $key => $value]; |
|
| 1712 | + $flatten[] = [$prepend.$key => $value]; |
|
| 1713 | 1713 | } |
| 1714 | 1714 | } |
| 1715 | 1715 | |
@@ -1894,7 +1894,7 @@ discard block |
||
| 1894 | 1894 | */ |
| 1895 | 1895 | \array_walk( |
| 1896 | 1896 | $array, |
| 1897 | - static function (&$val) { |
|
| 1897 | + static function(&$val) { |
|
| 1898 | 1898 | if ((string) $val === $val) { |
| 1899 | 1899 | $val = \trim($val); |
| 1900 | 1900 | } |
@@ -2132,7 +2132,7 @@ discard block |
||
| 2132 | 2132 | $array = $array[0]; |
| 2133 | 2133 | } |
| 2134 | 2134 | |
| 2135 | - $generator = function () use ($array): \Generator { |
|
| 2135 | + $generator = function() use ($array): \Generator { |
|
| 2136 | 2136 | foreach ($this->getGenerator() as $key => $value) { |
| 2137 | 2137 | if (\in_array($value, $array, true) === false) { |
| 2138 | 2138 | yield $key => $value; |
@@ -2167,7 +2167,7 @@ discard block |
||
| 2167 | 2167 | $array = $array[0]; |
| 2168 | 2168 | } |
| 2169 | 2169 | |
| 2170 | - $generator = function () use ($array): \Generator { |
|
| 2170 | + $generator = function() use ($array): \Generator { |
|
| 2171 | 2171 | foreach ($this->getGenerator() as $key => $value) { |
| 2172 | 2172 | if (\array_key_exists($key, $array) === false) { |
| 2173 | 2173 | yield $key => $value; |
@@ -2202,7 +2202,7 @@ discard block |
||
| 2202 | 2202 | $array = $array[0]; |
| 2203 | 2203 | } |
| 2204 | 2204 | |
| 2205 | - $generator = function () use ($array): \Generator { |
|
| 2205 | + $generator = function() use ($array): \Generator { |
|
| 2206 | 2206 | foreach ($this->getGenerator() as $key => $value) { |
| 2207 | 2207 | $isset = isset($array[$key]); |
| 2208 | 2208 | |
@@ -2511,7 +2511,7 @@ discard block |
||
| 2511 | 2511 | } |
| 2512 | 2512 | |
| 2513 | 2513 | if ($flag === \ARRAY_FILTER_USE_KEY) { |
| 2514 | - $generator = function () use ($closure) { |
|
| 2514 | + $generator = function() use ($closure) { |
|
| 2515 | 2515 | foreach ($this->getGenerator() as $key => $value) { |
| 2516 | 2516 | if ($closure($key) === true) { |
| 2517 | 2517 | yield $key => $value; |
@@ -2523,7 +2523,7 @@ discard block |
||
| 2523 | 2523 | /** @phpstan-var \Closure(T=,TKey=):bool $closure */ |
| 2524 | 2524 | $closure = $closure; |
| 2525 | 2525 | |
| 2526 | - $generator = function () use ($closure) { |
|
| 2526 | + $generator = function() use ($closure) { |
|
| 2527 | 2527 | foreach ($this->getGenerator() as $key => $value) { |
| 2528 | 2528 | if ($closure($value, $key) === true) { |
| 2529 | 2529 | yield $key => $value; |
@@ -2531,7 +2531,7 @@ discard block |
||
| 2531 | 2531 | } |
| 2532 | 2532 | }; |
| 2533 | 2533 | } else { |
| 2534 | - $generator = function () use ($closure) { |
|
| 2534 | + $generator = function() use ($closure) { |
|
| 2535 | 2535 | foreach ($this->getGenerator() as $key => $value) { |
| 2536 | 2536 | if ($closure($value) === true) { |
| 2537 | 2537 | yield $key => $value; |
@@ -2587,40 +2587,40 @@ discard block |
||
| 2587 | 2587 | } |
| 2588 | 2588 | |
| 2589 | 2589 | $ops = [ |
| 2590 | - 'eq' => static function ($item, $prop, $value): bool { |
|
| 2590 | + 'eq' => static function($item, $prop, $value): bool { |
|
| 2591 | 2591 | return $item[$prop] === $value; |
| 2592 | 2592 | }, |
| 2593 | - 'gt' => static function ($item, $prop, $value): bool { |
|
| 2593 | + 'gt' => static function($item, $prop, $value): bool { |
|
| 2594 | 2594 | return $item[$prop] > $value; |
| 2595 | 2595 | }, |
| 2596 | - 'ge' => static function ($item, $prop, $value): bool { |
|
| 2596 | + 'ge' => static function($item, $prop, $value): bool { |
|
| 2597 | 2597 | return $item[$prop] >= $value; |
| 2598 | 2598 | }, |
| 2599 | - 'gte' => static function ($item, $prop, $value): bool { |
|
| 2599 | + 'gte' => static function($item, $prop, $value): bool { |
|
| 2600 | 2600 | return $item[$prop] >= $value; |
| 2601 | 2601 | }, |
| 2602 | - 'lt' => static function ($item, $prop, $value): bool { |
|
| 2602 | + 'lt' => static function($item, $prop, $value): bool { |
|
| 2603 | 2603 | return $item[$prop] < $value; |
| 2604 | 2604 | }, |
| 2605 | - 'le' => static function ($item, $prop, $value): bool { |
|
| 2605 | + 'le' => static function($item, $prop, $value): bool { |
|
| 2606 | 2606 | return $item[$prop] <= $value; |
| 2607 | 2607 | }, |
| 2608 | - 'lte' => static function ($item, $prop, $value): bool { |
|
| 2608 | + 'lte' => static function($item, $prop, $value): bool { |
|
| 2609 | 2609 | return $item[$prop] <= $value; |
| 2610 | 2610 | }, |
| 2611 | - 'ne' => static function ($item, $prop, $value): bool { |
|
| 2611 | + 'ne' => static function($item, $prop, $value): bool { |
|
| 2612 | 2612 | return $item[$prop] !== $value; |
| 2613 | 2613 | }, |
| 2614 | - 'contains' => static function ($item, $prop, $value): bool { |
|
| 2614 | + 'contains' => static function($item, $prop, $value): bool { |
|
| 2615 | 2615 | return \in_array($item[$prop], (array) $value, true); |
| 2616 | 2616 | }, |
| 2617 | - 'notContains' => static function ($item, $prop, $value): bool { |
|
| 2617 | + 'notContains' => static function($item, $prop, $value): bool { |
|
| 2618 | 2618 | return !\in_array($item[$prop], (array) $value, true); |
| 2619 | 2619 | }, |
| 2620 | - 'newer' => static function ($item, $prop, $value): bool { |
|
| 2620 | + 'newer' => static function($item, $prop, $value): bool { |
|
| 2621 | 2621 | return \strtotime($item[$prop]) > \strtotime($value); |
| 2622 | 2622 | }, |
| 2623 | - 'older' => static function ($item, $prop, $value): bool { |
|
| 2623 | + 'older' => static function($item, $prop, $value): bool { |
|
| 2624 | 2624 | return \strtotime($item[$prop]) < \strtotime($value); |
| 2625 | 2625 | }, |
| 2626 | 2626 | ]; |
@@ -2628,7 +2628,7 @@ discard block |
||
| 2628 | 2628 | $result = \array_values( |
| 2629 | 2629 | \array_filter( |
| 2630 | 2630 | $this->toArray(false, true), |
| 2631 | - static function ($item) use ( |
|
| 2631 | + static function($item) use ( |
|
| 2632 | 2632 | $property, |
| 2633 | 2633 | $value, |
| 2634 | 2634 | $ops, |
@@ -2855,7 +2855,7 @@ discard block |
||
| 2855 | 2855 | */ |
| 2856 | 2856 | public function flip(): self |
| 2857 | 2857 | { |
| 2858 | - $generator = function (): \Generator { |
|
| 2858 | + $generator = function(): \Generator { |
|
| 2859 | 2859 | foreach ($this->getGenerator() as $key => $value) { |
| 2860 | 2860 | yield (string) $value => $key; |
| 2861 | 2861 | } |
@@ -3129,9 +3129,9 @@ discard block |
||
| 3129 | 3129 | $jsonObject = \json_decode($json, false); |
| 3130 | 3130 | |
| 3131 | 3131 | $mapper = new \Arrayy\Mapper\Json(); |
| 3132 | - $mapper->undefinedPropertyHandler = static function ($object, $key, $jsonValue) use ($class) { |
|
| 3132 | + $mapper->undefinedPropertyHandler = static function($object, $key, $jsonValue) use ($class) { |
|
| 3133 | 3133 | if ($class->checkPropertiesMismatchInConstructor) { |
| 3134 | - throw new \TypeError('Property mismatch - input: ' . \print_r(['key' => $key, 'jsonValue' => $jsonValue], true) . ' for object: ' . \get_class($object)); |
|
| 3134 | + throw new \TypeError('Property mismatch - input: '.\print_r(['key' => $key, 'jsonValue' => $jsonValue], true).' for object: '.\get_class($object)); |
|
| 3135 | 3135 | } |
| 3136 | 3136 | }; |
| 3137 | 3137 | |
@@ -3196,13 +3196,13 @@ discard block |
||
| 3196 | 3196 | public function getColumn($columnKey = null, $indexKey = null): self |
| 3197 | 3197 | { |
| 3198 | 3198 | if ($columnKey === null && $indexKey === null) { |
| 3199 | - $generator = function () { |
|
| 3199 | + $generator = function() { |
|
| 3200 | 3200 | foreach ($this->getGenerator() as $value) { |
| 3201 | 3201 | yield $value; |
| 3202 | 3202 | } |
| 3203 | 3203 | }; |
| 3204 | 3204 | } else { |
| 3205 | - $generator = function () use ($columnKey, $indexKey) { |
|
| 3205 | + $generator = function() use ($columnKey, $indexKey) { |
|
| 3206 | 3206 | foreach ($this->getGenerator() as $value) { |
| 3207 | 3207 | // reset |
| 3208 | 3208 | $newKey = null; |
@@ -3505,7 +3505,7 @@ discard block |
||
| 3505 | 3505 | |
| 3506 | 3506 | if ($UN_FOUND === null) { |
| 3507 | 3507 | // Generate unique string to use as marker. |
| 3508 | - $UN_FOUND = 'arrayy--' . \uniqid('arrayy', true); |
|
| 3508 | + $UN_FOUND = 'arrayy--'.\uniqid('arrayy', true); |
|
| 3509 | 3509 | } |
| 3510 | 3510 | |
| 3511 | 3511 | if (\is_array($key)) { |
@@ -3557,7 +3557,7 @@ discard block |
||
| 3557 | 3557 | */ |
| 3558 | 3558 | public function implode(string $glue = '', string $prefix = ''): string |
| 3559 | 3559 | { |
| 3560 | - return $prefix . $this->implode_recursive($glue, $this->toArray(), false); |
|
| 3560 | + return $prefix.$this->implode_recursive($glue, $this->toArray(), false); |
|
| 3561 | 3561 | } |
| 3562 | 3562 | |
| 3563 | 3563 | /** |
@@ -3671,7 +3671,7 @@ discard block |
||
| 3671 | 3671 | \array_uintersect( |
| 3672 | 3672 | $this->toArray(), |
| 3673 | 3673 | $search, |
| 3674 | - static function ($a, $b) { |
|
| 3674 | + static function($a, $b) { |
|
| 3675 | 3675 | return $a === $b ? 0 : -1; |
| 3676 | 3676 | } |
| 3677 | 3677 | ), |
@@ -4022,13 +4022,13 @@ discard block |
||
| 4022 | 4022 | // non recursive |
| 4023 | 4023 | |
| 4024 | 4024 | if ($search_values === null) { |
| 4025 | - $arrayFunction = function (): \Generator { |
|
| 4025 | + $arrayFunction = function(): \Generator { |
|
| 4026 | 4026 | foreach ($this->getGenerator() as $key => $value) { |
| 4027 | 4027 | yield $key; |
| 4028 | 4028 | } |
| 4029 | 4029 | }; |
| 4030 | 4030 | } else { |
| 4031 | - $arrayFunction = function () use ($search_values, $strict): \Generator { |
|
| 4031 | + $arrayFunction = function() use ($search_values, $strict): \Generator { |
|
| 4032 | 4032 | $is_array_tmp = \is_array($search_values); |
| 4033 | 4033 | |
| 4034 | 4034 | /** @noinspection PhpParameterByRefIsNotUsedAsReferenceInspection */ |
@@ -4277,7 +4277,7 @@ discard block |
||
| 4277 | 4277 | $useArguments = \func_num_args() > 2; |
| 4278 | 4278 | |
| 4279 | 4279 | return static::create( |
| 4280 | - function () use ($useArguments, $callable, $useKeyAsSecondParameter, $arguments) { |
|
| 4280 | + function() use ($useArguments, $callable, $useKeyAsSecondParameter, $arguments) { |
|
| 4281 | 4281 | foreach ($this->getGenerator() as $key => $value) { |
| 4282 | 4282 | if ($useArguments) { |
| 4283 | 4283 | if ($useKeyAsSecondParameter) { |
@@ -4779,7 +4779,7 @@ discard block |
||
| 4779 | 4779 | */ |
| 4780 | 4780 | public function nth(int $step, int $offset = 0): self |
| 4781 | 4781 | { |
| 4782 | - $arrayFunction = function () use ($step, $offset): \Generator { |
|
| 4782 | + $arrayFunction = function() use ($step, $offset): \Generator { |
|
| 4783 | 4783 | $position = 0; |
| 4784 | 4784 | foreach ($this->getGenerator() as $key => $value) { |
| 4785 | 4785 | if ($position++ % $step !== $offset) { |
@@ -4813,7 +4813,7 @@ discard block |
||
| 4813 | 4813 | { |
| 4814 | 4814 | $keys = \array_flip($keys); |
| 4815 | 4815 | |
| 4816 | - $generator = function () use ($keys): \Generator { |
|
| 4816 | + $generator = function() use ($keys): \Generator { |
|
| 4817 | 4817 | foreach ($this->getGenerator() as $key => $value) { |
| 4818 | 4818 | if (isset($keys[$key])) { |
| 4819 | 4819 | yield $key => $value; |
@@ -4950,7 +4950,7 @@ discard block |
||
| 4950 | 4950 | */ |
| 4951 | 4951 | public function prependImmutable($value, $key = null) |
| 4952 | 4952 | { |
| 4953 | - $generator = function () use ($key, $value): \Generator { |
|
| 4953 | + $generator = function() use ($key, $value): \Generator { |
|
| 4954 | 4954 | if ($this->properties !== []) { |
| 4955 | 4955 | $this->checkType($key, $value); |
| 4956 | 4956 | } |
@@ -5000,7 +5000,7 @@ discard block |
||
| 5000 | 5000 | )->prependToEachKey($suffix) |
| 5001 | 5001 | ->toArray(); |
| 5002 | 5002 | } else { |
| 5003 | - $result[$key . $suffix] = $item; |
|
| 5003 | + $result[$key.$suffix] = $item; |
|
| 5004 | 5004 | } |
| 5005 | 5005 | } |
| 5006 | 5006 | |
@@ -5040,7 +5040,7 @@ discard block |
||
| 5040 | 5040 | } elseif (\is_object($item) === true) { |
| 5041 | 5041 | $result[$key] = $item; |
| 5042 | 5042 | } else { |
| 5043 | - $result[$key] = $item . $suffix; |
|
| 5043 | + $result[$key] = $item.$suffix; |
|
| 5044 | 5044 | } |
| 5045 | 5045 | } |
| 5046 | 5046 | |
@@ -5849,7 +5849,7 @@ discard block |
||
| 5849 | 5849 | */ |
| 5850 | 5850 | public function replaceValues($search, $replacement = ''): self |
| 5851 | 5851 | { |
| 5852 | - $callable = static function ($value) use ($search, $replacement) { |
|
| 5852 | + $callable = static function($value) use ($search, $replacement) { |
|
| 5853 | 5853 | return \str_replace($search, $replacement, $value); |
| 5854 | 5854 | }; |
| 5855 | 5855 | |
@@ -6545,7 +6545,7 @@ discard block |
||
| 6545 | 6545 | * @psalm-suppress MissingClosureParamType |
| 6546 | 6546 | */ |
| 6547 | 6547 | $results = $arrayy->each( |
| 6548 | - static function ($value) use ($sorter) { |
|
| 6548 | + static function($value) use ($sorter) { |
|
| 6549 | 6549 | if (\is_callable($sorter) === true) { |
| 6550 | 6550 | return $sorter($value); |
| 6551 | 6551 | } |
@@ -6618,7 +6618,7 @@ discard block |
||
| 6618 | 6618 | public function split(int $numberOfPieces = 2, bool $keepKeys = false): self |
| 6619 | 6619 | { |
| 6620 | 6620 | if ($keepKeys) { |
| 6621 | - $generator = function () use ($numberOfPieces) { |
|
| 6621 | + $generator = function() use ($numberOfPieces) { |
|
| 6622 | 6622 | $carry = []; |
| 6623 | 6623 | $i = 1; |
| 6624 | 6624 | foreach ($this->getGenerator() as $key => $value) { |
@@ -6641,7 +6641,7 @@ discard block |
||
| 6641 | 6641 | } |
| 6642 | 6642 | }; |
| 6643 | 6643 | } else { |
| 6644 | - $generator = function () use ($numberOfPieces) { |
|
| 6644 | + $generator = function() use ($numberOfPieces) { |
|
| 6645 | 6645 | $carry = []; |
| 6646 | 6646 | $i = 1; |
| 6647 | 6647 | foreach ($this->getGenerator() as $value) { |
@@ -6688,7 +6688,7 @@ discard block |
||
| 6688 | 6688 | public function stripEmpty(): self |
| 6689 | 6689 | { |
| 6690 | 6690 | return $this->filter( |
| 6691 | - static function ($item) { |
|
| 6691 | + static function($item) { |
|
| 6692 | 6692 | if ($item === null) { |
| 6693 | 6693 | return false; |
| 6694 | 6694 | } |
@@ -6892,7 +6892,7 @@ discard block |
||
| 6892 | 6892 | // INFO: \array_unique() can't handle e.g. "stdClass"-values in an array |
| 6893 | 6893 | |
| 6894 | 6894 | $this->array = $this->reduce( |
| 6895 | - static function ($resultArray, $value, $key) { |
|
| 6895 | + static function($resultArray, $value, $key) { |
|
| 6896 | 6896 | if (!\in_array($value, $resultArray, true)) { |
| 6897 | 6897 | $resultArray[] = $value; |
| 6898 | 6898 | } |
@@ -6931,7 +6931,7 @@ discard block |
||
| 6931 | 6931 | */ |
| 6932 | 6932 | $this->array = \array_reduce( |
| 6933 | 6933 | \array_keys($array), |
| 6934 | - static function ($resultArray, $key) use ($array) { |
|
| 6934 | + static function($resultArray, $key) use ($array) { |
|
| 6935 | 6935 | if (!\in_array($array[$key], $resultArray, true)) { |
| 6936 | 6936 | $resultArray[$key] = $array[$key]; |
| 6937 | 6937 | } |
@@ -7028,7 +7028,7 @@ discard block |
||
| 7028 | 7028 | public function values(): self |
| 7029 | 7029 | { |
| 7030 | 7030 | return static::create( |
| 7031 | - function () { |
|
| 7031 | + function() { |
|
| 7032 | 7032 | foreach ($this->getGenerator() as $value) { |
| 7033 | 7033 | yield $value; |
| 7034 | 7034 | } |
@@ -7112,7 +7112,7 @@ discard block |
||
| 7112 | 7112 | public function where(string $keyOrPropertyOrMethod, $value): self |
| 7113 | 7113 | { |
| 7114 | 7114 | return $this->filter( |
| 7115 | - function ($item) use ($keyOrPropertyOrMethod, $value) { |
|
| 7115 | + function($item) use ($keyOrPropertyOrMethod, $value) { |
|
| 7116 | 7116 | $accessorValue = $this->extractValue( |
| 7117 | 7117 | $item, |
| 7118 | 7118 | $keyOrPropertyOrMethod |
@@ -7407,7 +7407,7 @@ discard block |
||
| 7407 | 7407 | protected function getPropertiesFromPhpDoc() |
| 7408 | 7408 | { |
| 7409 | 7409 | static $PROPERTY_CACHE = []; |
| 7410 | - $cacheKey = 'Class::' . static::class; |
|
| 7410 | + $cacheKey = 'Class::'.static::class; |
|
| 7411 | 7411 | |
| 7412 | 7412 | if (isset($PROPERTY_CACHE[$cacheKey])) { |
| 7413 | 7413 | return $PROPERTY_CACHE[$cacheKey]; |
@@ -7717,7 +7717,7 @@ discard block |
||
| 7717 | 7717 | if ($array === null) { |
| 7718 | 7718 | $array = []; |
| 7719 | 7719 | } elseif (!\is_array($array)) { |
| 7720 | - throw new \RuntimeException('Can not set value at this path "' . $key . '" because (' . \gettype($array) . ')"' . \print_r($array, true) . '" is not an array.'); |
|
| 7720 | + throw new \RuntimeException('Can not set value at this path "'.$key.'" because ('.\gettype($array).')"'.\print_r($array, true).'" is not an array.'); |
|
| 7721 | 7721 | } |
| 7722 | 7722 | |
| 7723 | 7723 | $array[$key] = $value; |
@@ -7789,7 +7789,7 @@ discard block |
||
| 7789 | 7789 | && |
| 7790 | 7790 | \count(\array_diff_key($properties, $data)) > 0 |
| 7791 | 7791 | ) { |
| 7792 | - throw new \TypeError('Property mismatch - input: ' . \print_r(\array_keys($data), true) . ' | expected: ' . \print_r(\array_keys($properties), true)); |
|
| 7792 | + throw new \TypeError('Property mismatch - input: '.\print_r(\array_keys($data), true).' | expected: '.\print_r(\array_keys($properties), true)); |
|
| 7793 | 7793 | } |
| 7794 | 7794 | |
| 7795 | 7795 | foreach ($data as $key => &$valueInner) { |
@@ -7906,7 +7906,7 @@ discard block |
||
| 7906 | 7906 | * |
| 7907 | 7907 | * @return void |
| 7908 | 7908 | */ |
| 7909 | - static function (&$item) { |
|
| 7909 | + static function(&$item) { |
|
| 7910 | 7910 | if ($item instanceof self) { |
| 7911 | 7911 | $item = $item->getArray(); |
| 7912 | 7912 | } |
@@ -7931,7 +7931,7 @@ discard block |
||
| 7931 | 7931 | && |
| 7932 | 7932 | $this->checkPropertiesMismatch === true |
| 7933 | 7933 | ) { |
| 7934 | - throw new \TypeError('The key "' . $key . '" does not exists as "@property" phpdoc. (' . \get_class($this) . ').'); |
|
| 7934 | + throw new \TypeError('The key "'.$key.'" does not exists as "@property" phpdoc. ('.\get_class($this).').'); |
|
| 7935 | 7935 | } |
| 7936 | 7936 | |
| 7937 | 7937 | if (isset($this->properties[self::ARRAYY_HELPER_TYPES_FOR_ALL_PROPERTIES])) { |
@@ -2,7 +2,7 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Arrayy\tests; |
| 4 | 4 | |
| 5 | -require_once __DIR__ . '/../vendor/autoload.php'; |
|
| 5 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
| 6 | 6 | |
| 7 | 7 | /** |
| 8 | 8 | * @property string $type |