Explicit variable definition, tweak documentation
[lhc/web/wiklou.git] / includes / api / ApiBase.php
index 18dfb98..df7ca1b 100644 (file)
@@ -532,8 +532,8 @@ abstract class ApiBase {
                array_shift( $required );
 
                $intersection = array_intersect( array_keys( array_filter( $params,
-                               create_function( '$x', 'return !is_null($x) && $x !== false;' )
-                       ) ), $required );
+                               array( $this, "parameterNotEmpty" ) ) ), $required );
+
                if ( count( $intersection ) > 1 ) {
                        $this->dieUsage( 'The parameters ' . implode( ', ', $intersection ) . ' can not be used together', 'invalidparammix' );
                } elseif ( count( $intersection ) == 0 ) {
@@ -541,6 +541,16 @@ abstract class ApiBase {
                }
        }
 
+       /**
+        * Callback function used in requireOnlyOneParameter to check whether reequired parameters are set
+        *
+        * @param  $x object Parameter to check is not null/false
+        * @return bool
+        */
+       private function parameterNotEmpty( $x ) {
+               return !is_null( $x ) && $x !== false;
+       }
+
        /**
         * @deprecated use MWNamespace::getValidNamespaces()
         */