MediawikiUI: Introduce mw-ui-icon-large
[lhc/web/wiklou.git] / includes / GlobalFunctions.php
index f7978c5..70784ba 100644 (file)
@@ -203,6 +203,38 @@ function wfArrayDiff2_cmp( $a, $b ) {
        }
 }
 
+/**
+ * Like array_filter with ARRAY_FILTER_USE_BOTH, but works pre-5.6.
+ *
+ * @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 ) {
+       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 ) );
+}
+
+/**
+ * Like array_filter with ARRAY_FILTER_USE_KEY, but works pre-5.6.
+ *
+ * @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 ) {
+       return wfArrayFilter( $arr, function ( $val, $key ) use ( $callback ) {
+               return call_user_func( $callback, $key );
+       } );
+}
+
 /**
  * Appends to second array if $value differs from that in $default
  *
@@ -3429,6 +3461,7 @@ function wfGetMessageCacheStorage() {
 /**
  * Get the cache object used by the parser cache
  *
+ * @deprecated since 1.30, use MediaWikiServices::getParserCache()->getCacheStorage()
  * @return BagOStuff
  */
 function wfGetParserCacheStorage() {
@@ -3584,6 +3617,7 @@ function wfCanIPUseHTTPS( $ip ) {
  * @since 1.25
  */
 function wfIsInfinity( $str ) {
+       // These are hardcoded elsewhere in MediaWiki (e.g. mediawiki.special.block.js).
        $infinityValues = [ 'infinite', 'indefinite', 'infinity', 'never' ];
        return in_array( $str, $infinityValues );
 }