diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2018-01-16 20:28:22 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2018-01-16 22:01:19 +0100 |
commit | 0e0db3765887930682aadc6bc8ec7df5ffd187f6 (patch) | |
tree | f11f9ebd73638273d281cb6d635ba6069edefd9f /lib/public/Security | |
parent | 2b70c708abc667c3e3c4fd9a97626012bf1ded25 (diff) | |
download | nextcloud-server-0e0db3765887930682aadc6bc8ec7df5ffd187f6.tar.gz nextcloud-server-0e0db3765887930682aadc6bc8ec7df5ffd187f6.zip |
Make OCP\Security stricter
* Add typehints
* Add return types
* Opcode opts from phpstorm
* Made strict
* Fixed tests: No need to test bogus values anymore strict typing fixes
this
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/public/Security')
-rw-r--r-- | lib/public/Security/ICrypto.php | 5 | ||||
-rw-r--r-- | lib/public/Security/IHasher.php | 5 | ||||
-rw-r--r-- | lib/public/Security/StringUtils.php | 3 |
3 files changed, 8 insertions, 5 deletions
diff --git a/lib/public/Security/ICrypto.php b/lib/public/Security/ICrypto.php index aa2b9eed2c0..ef5bd2bf7c9 100644 --- a/lib/public/Security/ICrypto.php +++ b/lib/public/Security/ICrypto.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); /** * @copyright Copyright (c) 2016, ownCloud, Inc. * @@ -42,7 +43,7 @@ interface ICrypto { * @return string Calculated HMAC * @since 8.0.0 */ - public function calculateHMAC($message, $password = ''); + public function calculateHMAC(string $message, string $password = ''): string; /** * Encrypts a value and adds an HMAC (Encrypt-Then-MAC) @@ -51,7 +52,7 @@ interface ICrypto { * @return string Authenticated ciphertext * @since 8.0.0 */ - public function encrypt($plaintext, $password = ''); + public function encrypt(string $plaintext, string $password = ''): string; /** * Decrypts a value and verifies the HMAC (Encrypt-Then-Mac) diff --git a/lib/public/Security/IHasher.php b/lib/public/Security/IHasher.php index 11159cbc010..5942814802a 100644 --- a/lib/public/Security/IHasher.php +++ b/lib/public/Security/IHasher.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); /** * @copyright Copyright (c) 2016, ownCloud, Inc. * @@ -53,7 +54,7 @@ interface IHasher { * @return string Hash of the message with appended version parameter * @since 8.0.0 */ - public function hash($message); + public function hash(string $message): string; /** * @param string $message Message to verify @@ -62,5 +63,5 @@ interface IHasher { * @return bool Whether $hash is a valid hash of $message * @since 8.0.0 */ - public function verify($message, $hash, &$newHash = null); + public function verify(string $message, string $hash, &$newHash = null): bool ; } diff --git a/lib/public/Security/StringUtils.php b/lib/public/Security/StringUtils.php index 04b5028cbd2..4ee1f47e836 100644 --- a/lib/public/Security/StringUtils.php +++ b/lib/public/Security/StringUtils.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); /** * @copyright Copyright (c) 2016, ownCloud, Inc. * @@ -42,7 +43,7 @@ class StringUtils { * @since 8.0.0 * @deprecated 9.0.0 Use hash_equals */ - public static function equals($expected, $input) { + public static function equals(string $expected, string $input): bool { return hash_equals($expected, $input); } } |