diff --git a/src/Security/Passwords.php b/src/Security/Passwords.php index cb695e85..b9917dba 100644 --- a/src/Security/Passwords.php +++ b/src/Security/Passwords.php @@ -46,10 +46,7 @@ public function hash(string $password): string throw new Nette\InvalidArgumentException('Password can not be empty.'); } - $hash = isset($this) - ? @password_hash($password, $this->algo, $this->options) // @ is escalated to exception - : @password_hash($password, PASSWORD_BCRYPT, func_get_args()[1] ?? []); // back compatibility with v2.x - + $hash = @password_hash($password, $this->algo, $this->options); // @ is escalated to exception if (!$hash) { throw new Nette\InvalidStateException('Computed hash is invalid. ' . error_get_last()['message']); } @@ -71,8 +68,6 @@ public function verify(string $password, string $hash): bool */ public function needsRehash(string $hash): bool { - return isset($this) - ? password_needs_rehash($hash, $this->algo, $this->options) - : password_needs_rehash($hash, PASSWORD_BCRYPT, func_get_args()[1] ?? []); // back compatibility with v2.x + return password_needs_rehash($hash, $this->algo, $this->options); } } diff --git a/tests/Security/Passwords.static.phpt b/tests/Security/Passwords.static.phpt deleted file mode 100644 index c50c9b57..00000000 --- a/tests/Security/Passwords.static.phpt +++ /dev/null @@ -1,31 +0,0 @@ - 5])) // @ is not static -); - - -Assert::true(@Passwords::verify('dg', '$2y$05$123456789012345678901uTj3G.8OMqoqrOMca1z/iBLqLNaWe6DK')); // @ is not static -Assert::false(@Passwords::verify('dgx', '$2y$05$123456789012345678901uTj3G.8OMqoqrOMca1z/iBLqLNaWe6DK')); // @ is not static - - -Assert::true(@Passwords::needsRehash('$2y$05$123456789012345678901uTj3G.8OMqoqrOMca1z/iBLqLNaWe6DK')); // @ is not static