}
/**
- * Like array_filter with ARRAY_FILTER_USE_BOTH, but works pre-5.6.
+ * @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
* @return array
*/
function wfArrayFilter( array $arr, callable $callback ) {
- if ( defined( 'ARRAY_FILTER_USE_BOTH' ) ) {
- return array_filter( $arr, $callback, ARRAY_FILTER_USE_BOTH );
- }
- $filteredKeys = array_filter( array_keys( $arr ), function ( $key ) use ( $arr, $callback ) {
- return call_user_func( $callback, $arr[$key], $key );
- } );
- return array_intersect_key( $arr, array_fill_keys( $filteredKeys, true ) );
+ return array_filter( $arr, $callback, ARRAY_FILTER_USE_BOTH );
}
/**
- * Like array_filter with ARRAY_FILTER_USE_KEY, but works pre-5.6.
+ * @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
* @return array
*/
function wfArrayFilterByKey( array $arr, callable $callback ) {
- return wfArrayFilter( $arr, function ( $val, $key ) use ( $callback ) {
- return call_user_func( $callback, $key );
- } );
+ return array_filter( $arr, $callback, ARRAY_FILTER_USE_KEY );
}
/**
function wfExpandIRI( $url ) {
return preg_replace_callback(
'/((?:%[89A-F][0-9A-F])+)/i',
- 'wfExpandIRI_callback',
+ function ( array $matches ) {
+ return urldecode( $matches[1] );
+ },
wfExpandUrl( $url )
);
}
-/**
- * Private callback for wfExpandIRI
- * @param array $matches
- * @return string
- */
-function wfExpandIRI_callback( $matches ) {
- return urldecode( $matches[1] );
-}
-
/**
* Make URL indexes, appropriate for the el_index field of externallinks.
*
* As required by the callers, "<nowiki>" is not used.
*
* @param string $text Text to be escaped
+ * @param-taint $text escapes_html
* @return string
*/
function wfEscapeWikiText( $text ) {