From 317477ee700dd438545251cd1f6fbc9e6c01017a Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 12 Aug 2024 17:20:17 +0900 Subject: [PATCH] refactor: fix method names with incorrect case --- phpstan-baseline.php | 18 ------------------ src/Authentication/Passwords.php | 2 +- .../Passwords/ValidationRules.php | 4 ++-- src/Filters/TokenAuth.php | 4 ++-- 4 files changed, 5 insertions(+), 23 deletions(-) diff --git a/phpstan-baseline.php b/phpstan-baseline.php index 2f8e213f3..5b2c7aa1b 100644 --- a/phpstan-baseline.php +++ b/phpstan-baseline.php @@ -135,24 +135,12 @@ 'count' => 1, 'path' => __DIR__ . '/src/Authentication/Authenticators/Session.php', ]; -$ignoreErrors[] = [ - // identifier: method.nameCase - 'message' => '#^Call to method CodeIgniter\\\\Shield\\\\Result\\:\\:isOK\\(\\) with incorrect case\\: isOk$#', - 'count' => 1, - 'path' => __DIR__ . '/src/Authentication/Passwords.php', -]; $ignoreErrors[] = [ // identifier: empty.notAllowed 'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#', 'count' => 4, 'path' => __DIR__ . '/src/Authentication/Passwords/NothingPersonalValidator.php', ]; -$ignoreErrors[] = [ - // identifier: method.nameCase - 'message' => '#^Call to method CodeIgniter\\\\Shield\\\\Result\\:\\:isOK\\(\\) with incorrect case\\: isOk$#', - 'count' => 2, - 'path' => __DIR__ . '/src/Authentication/Passwords/ValidationRules.php', -]; $ignoreErrors[] = [ // identifier: booleanAnd.rightNotBoolean 'message' => '#^Only booleans are allowed in &&, CodeIgniter\\\\Shield\\\\Entities\\\\User\\|null given on the right side\\.$#', @@ -316,12 +304,6 @@ 'count' => 1, 'path' => __DIR__ . '/src/Filters/AuthRates.php', ]; -$ignoreErrors[] = [ - // identifier: method.nameCase - 'message' => '#^Call to method CodeIgniter\\\\HTTP\\\\ResponseInterface\\:\\:setJSON\\(\\) with incorrect case\\: setJson$#', - 'count' => 2, - 'path' => __DIR__ . '/src/Filters/TokenAuth.php', -]; $ignoreErrors[] = [ // identifier: empty.notAllowed 'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#', diff --git a/src/Authentication/Passwords.php b/src/Authentication/Passwords.php index 6de08c8fa..5ddca0302 100644 --- a/src/Authentication/Passwords.php +++ b/src/Authentication/Passwords.php @@ -124,7 +124,7 @@ public function check(string $password, ?User $user = null): Result $class = new $className($this->config); $result = $class->check($password, $user); - if (! $result->isOk()) { + if (! $result->isOK()) { return $result; } } diff --git a/src/Authentication/Passwords/ValidationRules.php b/src/Authentication/Passwords/ValidationRules.php index 58ebf9b90..e37b9f62a 100644 --- a/src/Authentication/Passwords/ValidationRules.php +++ b/src/Authentication/Passwords/ValidationRules.php @@ -54,7 +54,7 @@ public function strong_password(string $value, ?string &$error1 = null, array $d $result = $checker->check($value, $user); - if (! $result->isOk()) { + if (! $result->isOK()) { if ($data === []) { $error1 = $result->reason(); } else { @@ -62,7 +62,7 @@ public function strong_password(string $value, ?string &$error1 = null, array $d } } - return $result->isOk(); + return $result->isOK(); } /** diff --git a/src/Filters/TokenAuth.php b/src/Filters/TokenAuth.php index b882e20d8..149874fd3 100644 --- a/src/Filters/TokenAuth.php +++ b/src/Filters/TokenAuth.php @@ -58,7 +58,7 @@ public function before(RequestInterface $request, $arguments = null) if (! $result->isOK() || (! empty($arguments) && $result->extraInfo()->tokenCant($arguments[0]))) { return service('response') ->setStatusCode(Response::HTTP_UNAUTHORIZED) - ->setJson(['message' => lang('Auth.badToken')]); + ->setJSON(['message' => lang('Auth.badToken')]); } if (setting('Auth.recordActiveDate')) { @@ -72,7 +72,7 @@ public function before(RequestInterface $request, $arguments = null) return service('response') ->setStatusCode(Response::HTTP_FORBIDDEN) - ->setJson(['message' => lang('Auth.activationBlocked')]); + ->setJSON(['message' => lang('Auth.activationBlocked')]); } }