From: Derick Alangi Date: Sat, 27 Apr 2019 06:40:47 +0000 (+0100) Subject: GlobalFunctions: Remove usage of `wfArrayFilter` & `wfArrayFilterByKey` X-Git-Tag: 1.34.0-rc.0~1862^2 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dmembres/modifier.php?a=commitdiff_plain;h=3d2750b89fc7eb66c2b3d403cbd7e48293053081;p=lhc%2Fweb%2Fwiklou.git GlobalFunctions: Remove usage of `wfArrayFilter` & `wfArrayFilterByKey` These functions were hard deprecated in 1.32 and usage no longer exist and seems to have been completely removed from all repos. See below; Usage ===== https://codesearch.wmflabs.org/search/?q=%5B%5E%3E%5D(wfArrayFilterByKey%5C(%7CwfArrayFilter%5C()&i=nope&files=&repos= Bug: T42485 Change-Id: I28092eeb8dec058c5dba2fb63f3602249c137b31 --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 2497b0f86d..118a61788c 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -140,32 +140,6 @@ function wfArrayDiff2_cmp( $a, $b ) { } } -/** - * @deprecated since 1.32, use array_filter() with ARRAY_FILTER_USE_BOTH directly - * - * @param array $arr - * @param callable $callback Will be called with the array value and key (in that order) and - * should return a bool which will determine whether the array element is kept. - * @return array - */ -function wfArrayFilter( array $arr, callable $callback ) { - wfDeprecated( __FUNCTION__, '1.32' ); - return array_filter( $arr, $callback, ARRAY_FILTER_USE_BOTH ); -} - -/** - * @deprecated since 1.32, use array_filter() with ARRAY_FILTER_USE_KEY directly - * - * @param array $arr - * @param callable $callback Will be called with the array key and should return a bool which - * will determine whether the array element is kept. - * @return array - */ -function wfArrayFilterByKey( array $arr, callable $callback ) { - wfDeprecated( __FUNCTION__, '1.32' ); - return array_filter( $arr, $callback, ARRAY_FILTER_USE_KEY ); -} - /** * Appends to second array if $value differs from that in $default * diff --git a/tests/phpunit/includes/GlobalFunctions/wfArrayFilterTest.php b/tests/phpunit/includes/GlobalFunctions/wfArrayFilterTest.php deleted file mode 100644 index bc930be45d..0000000000 --- a/tests/phpunit/includes/GlobalFunctions/wfArrayFilterTest.php +++ /dev/null @@ -1,44 +0,0 @@ -hideDeprecated( 'wfArrayFilter' ); - $arr = [ 'a' => 1, 'b' => 2, 'c' => 3 ]; - $filtered = wfArrayFilter( $arr, function ( $val, $key ) { - return $key !== 'b'; - } ); - $this->assertSame( [ 'a' => 1, 'c' => 3 ], $filtered ); - - $arr = [ 'a' => 1, 'b' => 2, 'c' => 3 ]; - $filtered = wfArrayFilter( $arr, function ( $val, $key ) { - return $val !== 2; - } ); - $this->assertSame( [ 'a' => 1, 'c' => 3 ], $filtered ); - - $arr = [ 'a', 'b', 'c' ]; - $filtered = wfArrayFilter( $arr, function ( $val, $key ) { - return $key !== 0; - } ); - $this->assertSame( [ 1 => 'b', 2 => 'c' ], $filtered ); - } - - public function testWfArrayFilterByKey() { - $this->hideDeprecated( 'wfArrayFilterByKey' ); - $arr = [ 'a' => 1, 'b' => 2, 'c' => 3 ]; - $filtered = wfArrayFilterByKey( $arr, function ( $key ) { - return $key !== 'b'; - } ); - $this->assertSame( [ 'a' => 1, 'c' => 3 ], $filtered ); - - $arr = [ 'a', 'b', 'c' ]; - $filtered = wfArrayFilterByKey( $arr, function ( $key ) { - return $key !== 0; - } ); - $this->assertSame( [ 1 => 'b', 2 => 'c' ], $filtered ); - } -}