diff options
author | Max Semenik <maxsem.wiki@gmail.com> | 2019-11-09 20:59:25 -0800 |
---|---|---|
committer | Jforrester <jforrester@wikimedia.org> | 2019-11-19 15:01:09 +0000 |
commit | b86088857ac541f4e205773706f8e48b914b3727 (patch) | |
tree | d97da8bdbd2085563e9f514b93d3d946f64f3fa5 /includes/password/BcryptPassword.php | |
parent | 68b763d6eda413e2aed5d5d6370a883ac70a7957 (diff) | |
download | mediawikicore-b86088857ac541f4e205773706f8e48b914b3727.tar.gz mediawikicore-b86088857ac541f4e205773706f8e48b914b3727.zip |
Use strict types in includes/password
This is a well isolated area of code, without functions that are
likely to receive PHP's trademark "garbage in, garbage out" data
as parameters. Capitalize on this and require strict types there.
Change-Id: I9f1c172e737018d058ddc1700d8234832b58efa6
Diffstat (limited to 'includes/password/BcryptPassword.php')
-rw-r--r-- | includes/password/BcryptPassword.php | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/includes/password/BcryptPassword.php b/includes/password/BcryptPassword.php index 4ba34effe553..2b1fcb7ed4b9 100644 --- a/includes/password/BcryptPassword.php +++ b/includes/password/BcryptPassword.php @@ -20,6 +20,8 @@ * @file */ +declare( strict_types = 1 ); + /** * A Bcrypt-hashed password * @@ -29,17 +31,17 @@ * @since 1.24 */ class BcryptPassword extends ParameterizedPassword { - protected function getDefaultParams() { + protected function getDefaultParams() : array { return [ 'rounds' => $this->config['cost'], ]; } - protected function getDelimiter() { + protected function getDelimiter() : string { return '$'; } - protected function parseHash( $hash ) { + protected function parseHash( ?string $hash ) : void { parent::parseHash( $hash ); $this->params['rounds'] = (int)$this->params['rounds']; @@ -51,7 +53,7 @@ class BcryptPassword extends ParameterizedPassword { * @throws PasswordError If bcrypt has an unknown error * @throws MWException If bcrypt is not supported by PHP */ - public function crypt( $password ) { + public function crypt( string $password ) : void { if ( !defined( 'CRYPT_BLOWFISH' ) ) { throw new MWException( 'Bcrypt is not supported.' ); } |