MediaWiki  master
PasswordDef.php
Go to the documentation of this file.
1 <?php
2 
4 
6 
16 class PasswordDef extends StringDef {
17 
18  public function normalizeSettings( array $settings ) {
19  $settings[ParamValidator::PARAM_SENSITIVE] = true;
20  return parent::normalizeSettings( $settings );
21  }
22 
23  public function checkSettings( string $name, $settings, array $options, array $ret ) : array {
24  $ret = parent::checkSettings( $name, $settings, $options, $ret );
25 
26  if ( ( $settings[ParamValidator::PARAM_SENSITIVE] ?? true ) !== true &&
27  !isset( $ret['issues'][ParamValidator::PARAM_SENSITIVE] )
28  ) {
29  $ret['issues'][ParamValidator::PARAM_SENSITIVE] =
30  'Cannot set PARAM_SENSITIVE to false for password-type parameters';
31  }
32 
33  return $ret;
34  }
35 
36 }
Wikimedia\ParamValidator\TypeDef\PasswordDef\checkSettings
checkSettings(string $name, $settings, array $options, array $ret)
Validate a parameter settings array.
Definition: PasswordDef.php:23
Wikimedia\ParamValidator\ParamValidator\PARAM_SENSITIVE
const PARAM_SENSITIVE
(bool) Indicate that the parameter's value should not be logged.
Definition: ParamValidator.php:153
Wikimedia\ParamValidator\TypeDef\StringDef
Type definition for string types.
Definition: StringDef.php:24
Wikimedia\ParamValidator\TypeDef\PasswordDef\normalizeSettings
normalizeSettings(array $settings)
Normalize a settings array Stable to override.
Definition: PasswordDef.php:18
Wikimedia\ParamValidator\TypeDef\PasswordDef
Type definition for "password" types.
Definition: PasswordDef.php:16
Wikimedia\ParamValidator\TypeDef
Definition: BooleanDef.php:3
Wikimedia\ParamValidator\ParamValidator
Service for formatting and validating API parameters.
Definition: ParamValidator.php:42