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;
);
}
+ /**
+ * @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(
);
}
- Hooks::run( 'PasswordPoliciesForUser', array( $user, &$effectivePolicy, $purpose ) );
+ Hooks::run( 'PasswordPoliciesForUser', [ $user, &$effectivePolicy, $purpose ] );
return $effectivePolicy;
}
* @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] ) ) {