X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fexception%2FPermissionsError.php;h=e31374c2c7e470bfa6be63f71546f7e242667b50;hp=6ad2e37f10746ab0927af454c54e802a239223ab;hb=ce079cf6ad79ca8d3360817f809b219d166f9153;hpb=fb7b3eebeb8de47eb42e8d6ccf204106a2d6d9e4 diff --git a/includes/exception/PermissionsError.php b/includes/exception/PermissionsError.php index 6ad2e37f10..e31374c2c7 100644 --- a/includes/exception/PermissionsError.php +++ b/includes/exception/PermissionsError.php @@ -28,9 +28,20 @@ class PermissionsError extends ErrorPageError { public $permission, $errors; + /** + * @param string|null $permission A permission name or null if unknown + * @param array $errors Error message keys or [key, param...] arrays; must not be empty if + * $permission is null + * @throws \InvalidArgumentException + */ public function __construct( $permission, $errors = [] ) { global $wgLang; + if ( $permission === null && !$errors ) { + throw new \InvalidArgumentException( __METHOD__ . + ': $permission and $errors cannot both be empty' ); + } + $this->permission = $permission; if ( !count( $errors ) ) {