From dbdafb1fa0131b7764b9ca63e5c38c38a68fdcfa Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Tue, 10 Oct 2023 06:59:45 +0700 Subject: [PATCH 1/4] [Rector] Apply StringifyStrNeedlesRector --- rector.php | 2 -- src/Authentication/Passwords/NothingPersonalValidator.php | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rector.php b/rector.php index 12a24007d..76a02ab28 100644 --- a/rector.php +++ b/rector.php @@ -31,7 +31,6 @@ use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector; use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector; use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector; -use Rector\Php73\Rector\FuncCall\StringifyStrNeedlesRector; use Rector\PHPUnit\AnnotationsToAttributes\Rector\Class_\AnnotationWithValueToAttributeRector; use Rector\PHPUnit\CodeQuality\Rector\Class_\YieldDataProviderRector; use Rector\PHPUnit\Set\PHPUnitSetList; @@ -82,7 +81,6 @@ __DIR__ . '/src/Views', JsonThrowOnErrorRector::class, - StringifyStrNeedlesRector::class, YieldDataProviderRector::class, // Note: requires php 8 diff --git a/src/Authentication/Passwords/NothingPersonalValidator.php b/src/Authentication/Passwords/NothingPersonalValidator.php index 92151e8b0..1a2d7eaf6 100644 --- a/src/Authentication/Passwords/NothingPersonalValidator.php +++ b/src/Authentication/Passwords/NothingPersonalValidator.php @@ -183,6 +183,8 @@ protected function isNotSimilar(string $password, ?User $user): bool * * Replaces all non-word characters and underscores in $str with a space. * Then it explodes that result using the space for a delimiter. + * + * @return array */ protected function strip_explode(string $str): array { From e0c53d7d28aaaebaef7e460cc63d64d8654a6d65 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Tue, 10 Oct 2023 07:00:47 +0700 Subject: [PATCH 2/4] Run Rector --- src/Authentication/Passwords/NothingPersonalValidator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Authentication/Passwords/NothingPersonalValidator.php b/src/Authentication/Passwords/NothingPersonalValidator.php index 1a2d7eaf6..14a8c587b 100644 --- a/src/Authentication/Passwords/NothingPersonalValidator.php +++ b/src/Authentication/Passwords/NothingPersonalValidator.php @@ -79,7 +79,7 @@ protected function isNotPersonal(string $password, ?User $user): bool if (! empty($domain)) { $emailParts[] = $domain; } - $needles = array_merge($needles, $emailParts); + $needles = [...$needles, ...$emailParts]; // Get any other "personal" fields defined in config $personalFields = $this->config->personalFields; From 1393c18418d715f9d3432b5bed60d1c7d1046a13 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Tue, 10 Oct 2023 08:43:55 +0700 Subject: [PATCH 3/4] Fix php 7.4 substr can return false --- src/Authentication/Passwords/PwnedValidator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Authentication/Passwords/PwnedValidator.php b/src/Authentication/Passwords/PwnedValidator.php index ef862b2b8..4023da3cc 100644 --- a/src/Authentication/Passwords/PwnedValidator.php +++ b/src/Authentication/Passwords/PwnedValidator.php @@ -35,7 +35,7 @@ public function check(string $password, ?User $user = null): Result { $hashedPword = strtoupper(sha1($password)); $rangeHash = substr($hashedPword, 0, 5); - $searchHash = substr($hashedPword, 5); + $searchHash = (string) substr($hashedPword, 5); try { $client = Services::curlrequest([ From 6fb9594fa668a89832486d8a01827c1b966c0db8 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Tue, 10 Oct 2023 08:45:29 +0700 Subject: [PATCH 4/4] Fix php 7.4 substr can return false --- src/Authentication/Passwords/PwnedValidator.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Authentication/Passwords/PwnedValidator.php b/src/Authentication/Passwords/PwnedValidator.php index 4023da3cc..a68e92e99 100644 --- a/src/Authentication/Passwords/PwnedValidator.php +++ b/src/Authentication/Passwords/PwnedValidator.php @@ -35,7 +35,8 @@ public function check(string $password, ?User $user = null): Result { $hashedPword = strtoupper(sha1($password)); $rangeHash = substr($hashedPword, 0, 5); - $searchHash = (string) substr($hashedPword, 5); + /** @var string $searchHash */ + $searchHash = substr($hashedPword, 5); try { $client = Services::curlrequest([