}
}
-/**
- * @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
*
+++ /dev/null
-<?php
-
-/**
- * @group GlobalFunctions
- * @covers ::wfArrayFilter
- * @covers ::wfArrayFilterByKey
- */
-class WfArrayFilterTest extends MediaWikiTestCase {
- public function testWfArrayFilter() {
- $this->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 );
- }
-}