Use english messages for background use of Status::getWikiText
[lhc/web/wiklou.git] / includes / password / UserPasswordPolicy.php
index 80dc669..5584f6f 100644 (file)
@@ -56,7 +56,7 @@ class UserPasswordPolicy {
                foreach ( $checks as $statement => $check ) {
                        if ( !is_callable( $check ) ) {
                                throw new InvalidArgumentException(
-                                       'Policy check functions must be callable'
+                                       "Policy check functions must be callable. '$statement' isn't callable."
                                );
                        }
                        $this->policyCheckFunctions[$statement] = $check;
@@ -105,11 +105,18 @@ class UserPasswordPolicy {
                );
        }
 
+       /**
+        * @param User $user
+        * @param string $password
+        * @param array $policies
+        * @param array $policyCheckFunctions
+        * @return Status
+        */
        private function checkPolicies( User $user, $password, $policies, $policyCheckFunctions ) {
                $status = Status::newGood();
                foreach ( $policies as $policy => $value ) {
                        if ( !isset( $policyCheckFunctions[$policy] ) ) {
-                               throw new DomainException( 'Invalid password policy config' );
+                               throw new DomainException( "Invalid password policy config. No check defined for '$policy'." );
                        }
                        $status->merge(
                                call_user_func(
@@ -140,7 +147,7 @@ class UserPasswordPolicy {
                        );
                }
 
-               Hooks::run( 'PasswordPoliciesForUser', array( $user, &$effectivePolicy, $purpose ) );
+               Hooks::run( 'PasswordPoliciesForUser', [ $user, &$effectivePolicy, $purpose ] );
 
                return $effectivePolicy;
        }
@@ -177,7 +184,7 @@ class UserPasswordPolicy {
         * @return array containing the more restrictive values of $p1 and $p2
         */
        public static function maxOfPolicies( array $p1, array $p2 ) {
-               $ret = array();
+               $ret = [];
                $keys = array_merge( array_keys( $p1 ), array_keys( $p2 ) );
                foreach ( $keys as $key ) {
                        if ( !isset( $p1[$key] ) ) {