[Password] mark password functions pure

This commit is contained in:
azjezz 2020-10-17 04:12:26 +01:00
parent edb2c8c501
commit 3c96b7624e
5 changed files with 10 additions and 0 deletions

View File

@ -8,6 +8,8 @@ namespace Psl\Password;
* Return a complete list of all registered password hashing algorithms.
*
* @psalm-return list<string>
*
* @psalm-pure
*/
function algorithms(): array
{

View File

@ -18,6 +18,8 @@ use function password_get_info;
* algorithm: string,
* options: array{cost: int}|array{memory_cost: int, time_cost: int, threads: int}
* }
*
* @psalm-pure
*/
function get_information(string $hash): array
{

View File

@ -26,6 +26,8 @@ use const PASSWORD_BCRYPT;
* @see ARGON2I_ALGORITHM for the argon2i, and argon2id supported options.
*
* @throws Psl\Exception\InvariantViolationException The given algorithm is unsupported.
*
* @psalm-pure
*/
function hash(string $password, string $algorithm = DEFAULT_ALGORITHM, array $options = []): string
{

View File

@ -19,6 +19,8 @@ use function password_needs_rehash;
* This function is safe against timing attacks.
*
* @psalm-param array{cost?: int}|array{memory_cost?: int, time_cost?: int, threads?: int} $options
*
* @psalm-pure
*/
function needs_rehash(string $hash, string $algorithm = DEFAULT_ALGORITHM, array $options = []): bool
{

View File

@ -8,6 +8,8 @@ use function password_verify;
/**
* Checks if the given hash matches the given options.
*
* @psalm-pure
*/
function verify(string $password, string $hash): bool
{