From 7dbf3c471293c09ff20bbffeb6557c556ba79b2a Mon Sep 17 00:00:00 2001 From: webimpress Date: Tue, 14 Feb 2017 21:13:42 +0000 Subject: [PATCH] Marked ArrayUtils::filter as deprecated This method was implemented only for compatibility with PHP <5.6. Library now supports only PHP 5.6+ so this method is no longer needed. Removed functionality for PHP <5.6 and marked function as deprecated since 3.2.0. Added suggestion to use native method `array_filter`. --- src/ArrayUtils.php | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/src/ArrayUtils.php b/src/ArrayUtils.php index 0e2b738cc..4edcacf11 100644 --- a/src/ArrayUtils.php +++ b/src/ArrayUtils.php @@ -292,12 +292,13 @@ public static function merge(array $a, array $b, $preserveNumericKeys = false) } /** - * Compatibility Method for array_filter on <5.6 systems + * @deprecated Since 3.2.0; use the native array_filter methods * * @param array $data * @param callable $callback * @param null|int $flag * @return array + * @throws Exception\InvalidArgumentException */ public static function filter(array $data, $callback, $flag = null) { @@ -308,28 +309,6 @@ public static function filter(array $data, $callback, $flag = null) )); } - if (version_compare(PHP_VERSION, '5.6.0') >= 0) { - return array_filter($data, $callback, $flag); - } - - $output = []; - foreach ($data as $key => $value) { - $params = [$value]; - - if ($flag === static::ARRAY_FILTER_USE_BOTH) { - $params[] = $key; - } - - if ($flag === static::ARRAY_FILTER_USE_KEY) { - $params = [$key]; - } - - $response = call_user_func_array($callback, $params); - if ($response) { - $output[$key] = $value; - } - } - - return $output; + return array_filter($data, $callback, $flag); } }