@@ -73,13 +73,13 @@ |
||
| 73 | 73 | public function __construct(\Closure $func, \Iterator $iterable, $reverse = false) |
| 74 | 74 | { |
| 75 | 75 | if ($reverse) { |
| 76 | - $cmp = function ($a, $b) use ($func) { |
|
| 76 | + $cmp = function($a, $b) use ($func) { |
|
| 77 | 77 | $orderA = $a['order']; |
| 78 | 78 | $orderB = $b['order']; |
| 79 | 79 | return $orderA == $orderB ? 0 : ($orderA < $orderB ? 1 : -1); |
| 80 | 80 | }; |
| 81 | 81 | } else { |
| 82 | - $cmp = function ($a, $b) use ($func) { |
|
| 82 | + $cmp = function($a, $b) use ($func) { |
|
| 83 | 83 | $orderA = $a['order']; |
| 84 | 84 | $orderB = $b['order']; |
| 85 | 85 | return $orderA == $orderB ? 0 : ($orderA < $orderB ? -1 : 1); |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | public function __construct(\Closure $valueFunc /* [\Closure $keyFunc], \Iterator $iterable1, [\Iterator $iterable2, [...]] */) |
| 80 | 80 | { |
| 81 | - parent::__construct(\MultipleIterator::MIT_NEED_ALL | \MultipleIterator::MIT_KEYS_NUMERIC); |
|
| 81 | + parent::__construct(\MultipleIterator::MIT_NEED_ALL|\MultipleIterator::MIT_KEYS_NUMERIC); |
|
| 82 | 82 | $args = func_get_args(); |
| 83 | 83 | $argsContainsKeyFunc = $args[1] instanceof \Closure; |
| 84 | 84 | $this->valueFunc = $args[0]; |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | if ($argsContainsKeyFunc) { |
| 87 | 87 | $this->keyFunc = $args[1]; |
| 88 | 88 | } else { |
| 89 | - $this->keyFunc = function () { |
|
| 89 | + $this->keyFunc = function() { |
|
| 90 | 90 | return $this->genericKeysToKey(func_get_args()); |
| 91 | 91 | }; |
| 92 | 92 | } |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | return join( |
| 125 | 125 | ':', |
| 126 | 126 | array_map( |
| 127 | - function ($key) { |
|
| 127 | + function($key) { |
|
| 128 | 128 | return (string)$key; |
| 129 | 129 | }, |
| 130 | 130 | $keys |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | { |
| 23 | 23 | if ($this instanceof \Iterator) { |
| 24 | 24 | $strategy = conversions\mixed_to_value_getter($strategy); |
| 25 | - $isValid = function ($value, $key) use ($strategy) { |
|
| 25 | + $isValid = function($value, $key) use ($strategy) { |
|
| 26 | 26 | $tempVarPhp54 = $strategy($value, $key); |
| 27 | 27 | return !empty($tempVarPhp54); |
| 28 | 28 | }; |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | $array = iterator_to_array($this); |
| 30 | 30 | array_walk( |
| 31 | 31 | $array, |
| 32 | - function (&$value) { |
|
| 32 | + function(&$value) { |
|
| 33 | 33 | if ($value instanceof FiniteIterableInterface) { |
| 34 | 34 | $value = $value->toArray(); |
| 35 | 35 | } |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | |
| 18 | 18 | public function __construct() |
| 19 | 19 | { |
| 20 | - parent::__construct(\MultipleIterator::MIT_NEED_ALL | \MultipleIterator::MIT_KEYS_NUMERIC); |
|
| 20 | + parent::__construct(\MultipleIterator::MIT_NEED_ALL|\MultipleIterator::MIT_KEYS_NUMERIC); |
|
| 21 | 21 | foreach (func_get_args() as $iterable) { |
| 22 | 22 | if (!$iterable instanceof \Iterator) { |
| 23 | 23 | throw new \InvalidArgumentException(sprintf('Not all arguments are iterators')); |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | $iterable = iterable($iterable); |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - return $iterable->mapBy($strategy);} |
|
| 318 | + return $iterable->mapBy($strategy); } |
|
| 319 | 319 | |
| 320 | 320 | /** |
| 321 | 321 | * Make an iterator returning values from $iterable and keys from |
@@ -601,7 +601,7 @@ discard block |
||
| 601 | 601 | switch (sizeof($args)) { |
| 602 | 602 | case 2: |
| 603 | 603 | $strategy = Conversions::mixedToValueGetter($args[0]); |
| 604 | - $closure = function ($value, $key) use ($strategy) { |
|
| 604 | + $closure = function($value, $key) use ($strategy) { |
|
| 605 | 605 | $tempVarPhp54 = call_user_func($strategy, $value, $key); |
| 606 | 606 | return !empty($tempVarPhp54); |
| 607 | 607 | }; |
@@ -611,7 +611,7 @@ discard block |
||
| 611 | 611 | case 3: |
| 612 | 612 | $strategy = Conversions::mixedToValueGetter($args[0]); |
| 613 | 613 | $userClosure = $args[1]; |
| 614 | - $closure = function ($value, $key) use ($strategy, $userClosure) { |
|
| 614 | + $closure = function($value, $key) use ($strategy, $userClosure) { |
|
| 615 | 615 | return call_user_func($userClosure, call_user_func($strategy, $value, $key)); |
| 616 | 616 | }; |
| 617 | 617 | $iterable = Conversions::mixedToIterator($args[2]); |
@@ -79,7 +79,7 @@ |
||
| 79 | 79 | $haystack = Itertools\iterable($haystack)->values(); |
| 80 | 80 | } |
| 81 | 81 | $strategy = conversions\mixed_to_value_getter($strategy); |
| 82 | - return function ($value, $key = null) use ($haystack, $strategy, $strict) { |
|
| 82 | + return function($value, $key = null) use ($haystack, $strategy, $strict) { |
|
| 83 | 83 | return !in_array($strategy($value, $key), $haystack, $strict); |
| 84 | 84 | }; |
| 85 | 85 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | public static function lstrip($chars = " \t\n\r\0\x0B") |
| 17 | 17 | { |
| 18 | - return function ($value) use ($chars) { |
|
| 18 | + return function($value) use ($chars) { |
|
| 19 | 19 | return ltrim($value, $chars); |
| 20 | 20 | }; |
| 21 | 21 | } |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | */ |
| 29 | 29 | public static function rstrip($chars = " \t\n\r\0\x0B") |
| 30 | 30 | { |
| 31 | - return function ($value) use ($chars) { |
|
| 31 | + return function($value) use ($chars) { |
|
| 32 | 32 | return rtrim($value, $chars); |
| 33 | 33 | }; |
| 34 | 34 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | public static function strip($chars = " \t\n\r\0\x0B") |
| 43 | 43 | { |
| 44 | - return function ($value) use ($chars) { |
|
| 44 | + return function($value) use ($chars) { |
|
| 45 | 45 | return trim($value, $chars); |
| 46 | 46 | }; |
| 47 | 47 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | public static function length() |
| 55 | 55 | { |
| 56 | - return function ($value) { |
|
| 56 | + return function($value) { |
|
| 57 | 57 | if (is_null($value)) { |
| 58 | 58 | return 0; |
| 59 | 59 | } |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | public static function key() |
| 73 | 73 | { |
| 74 | - return function ($value, $key) { |
|
| 74 | + return function($value, $key) { |
|
| 75 | 75 | return $key; |
| 76 | 76 | }; |
| 77 | 77 | } |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | public static function lower() |
| 85 | 85 | { |
| 86 | - return function ($value) { |
|
| 86 | + return function($value) { |
|
| 87 | 87 | return strtolower($value); |
| 88 | 88 | }; |
| 89 | 89 | } |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | public static function upper() |
| 97 | 97 | { |
| 98 | - return function ($value) { |
|
| 98 | + return function($value) { |
|
| 99 | 99 | return strtoupper($value); |
| 100 | 100 | }; |
| 101 | 101 | } |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | */ |
| 108 | 108 | public static function string() |
| 109 | 109 | { |
| 110 | - return function ($value) { |
|
| 110 | + return function($value) { |
|
| 111 | 111 | return (string)$value; |
| 112 | 112 | }; |
| 113 | 113 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | public static function jsonEncode($options = 0, $depth = 512) |
| 123 | 123 | { |
| 124 | - return function ($value) use ($options, $depth) { |
|
| 124 | + return function($value) use ($options, $depth) { |
|
| 125 | 125 | return \json_encode($value, $options, $depth); |
| 126 | 126 | }; |
| 127 | 127 | } |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | */ |
| 137 | 137 | public static function jsonDecode($associative = false, $options = 0, $depth = 512) |
| 138 | 138 | { |
| 139 | - return function ($value) use ($associative, $options, $depth) { |
|
| 139 | + return function($value) use ($associative, $options, $depth) { |
|
| 140 | 140 | return \json_decode($value, $associative, $depth, $options); |
| 141 | 141 | }; |
| 142 | 142 | } |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | $mappings = array_map('\Zicht\Itertools\util\Conversions::mixedToValueGetter', (array)$mappings); |
| 178 | 178 | $strategy = Conversions::mixedToValueGetter($strategy); |
| 179 | 179 | |
| 180 | - return function ($value, $key) use ($mappings, $strategy, $discardNull, $discardEmptyContainer, $castToObject) { |
|
| 180 | + return function($value, $key) use ($mappings, $strategy, $discardNull, $discardEmptyContainer, $castToObject) { |
|
| 181 | 181 | $value = $strategy($value); |
| 182 | 182 | $res = []; |
| 183 | 183 | foreach ($mappings as $strategyKey => $strategy) { |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | if ($discardNull || $discardEmptyContainer) { |
| 187 | 187 | $res = array_filter( |
| 188 | 188 | $res, |
| 189 | - function ($value) use ($discardNull, $discardEmptyContainer) { |
|
| 189 | + function($value) use ($discardNull, $discardEmptyContainer) { |
|
| 190 | 190 | if (null === $value) { |
| 191 | 191 | return !$discardNull; |
| 192 | 192 | } |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | $max = getrandmax(); |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - return function () use ($min, $max) { |
|
| 219 | + return function() use ($min, $max) { |
|
| 220 | 220 | return rand($min, $max); |
| 221 | 221 | }; |
| 222 | 222 | } |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | public static function type($strategy = null) |
| 231 | 231 | { |
| 232 | 232 | $strategy = Conversions::mixedToValueGetter($strategy); |
| 233 | - return function ($value) use ($strategy) { |
|
| 233 | + return function($value) use ($strategy) { |
|
| 234 | 234 | $value = $strategy($value); |
| 235 | 235 | return is_object($value) ? get_class($value) : gettype($value); |
| 236 | 236 | }; |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | $mapping = Conversions::mixedToValueGetter($mapping); |
| 260 | 260 | $strategy = Conversions::mixedToValueGetter($strategy); |
| 261 | 261 | $cache = []; |
| 262 | - return function ($value, $key = null) use ($mapping, $strategy, &$cache) { |
|
| 262 | + return function($value, $key = null) use ($mapping, $strategy, &$cache) { |
|
| 263 | 263 | $cacheKey = \json_encode($strategy($value, $key)); |
| 264 | 264 | if (!array_key_exists($cacheKey, $cache)) { |
| 265 | 265 | $cache[$cacheKey] = $mapping($value, $key); |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | */ |
| 277 | 277 | public static function constant($value) |
| 278 | 278 | { |
| 279 | - return function () use ($value) { |
|
| 279 | + return function() use ($value) { |
|
| 280 | 280 | return $value; |
| 281 | 281 | }; |
| 282 | 282 | } |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | public static function mixedToClosure($closure) |
| 72 | 72 | { |
| 73 | 73 | if (is_null($closure)) { |
| 74 | - return function ($value) { |
|
| 74 | + return function($value) { |
|
| 75 | 75 | return $value; |
| 76 | 76 | }; |
| 77 | 77 | } |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | // A \Closure is always callable, but a callable is not always a \Closure. |
| 81 | 81 | // Checking within this if statement is a slight optimization, preventing an unnecessary function wrap |
| 82 | 82 | if (is_callable($closure)) { |
| 83 | - $closure = function () use ($closure) { |
|
| 83 | + $closure = function() use ($closure) { |
|
| 84 | 84 | return call_user_func_array($closure, func_get_args()); |
| 85 | 85 | }; |
| 86 | 86 | } else { |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | { |
| 112 | 112 | if (is_string($strategy)) { |
| 113 | 113 | $keyParts = explode('.', $strategy); |
| 114 | - $strategy = function ($value) use ($keyParts) { |
|
| 114 | + $strategy = function($value) use ($keyParts) { |
|
| 115 | 115 | foreach ($keyParts as $keyPart) { |
| 116 | 116 | if (is_array($value) && array_key_exists($keyPart, $value)) { |
| 117 | 117 | $value = $value[$keyPart]; |