From 3c2f9954b56f2a01ac31d695c9eec72850ee17de Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 14 Nov 2023 14:24:53 +0900 Subject: [PATCH] refactor: run rector --- app/Views/errors/cli/error_exception.php | 2 +- app/Views/errors/html/error_exception.php | 4 ++-- system/CLI/InputOutput.php | 2 +- .../Utilities/Routes/SampleURIGenerator.php | 2 +- system/Filters/Filters.php | 2 +- system/Filters/PageCache.php | 2 +- system/HTTP/Method.php | 18 +++++++++--------- system/Validation/Rules.php | 2 +- system/Validation/StrictRules/Rules.php | 6 +++--- 9 files changed, 20 insertions(+), 20 deletions(-) diff --git a/app/Views/errors/cli/error_exception.php b/app/Views/errors/cli/error_exception.php index 49bcd89131fb..e908b426381d 100644 --- a/app/Views/errors/cli/error_exception.php +++ b/app/Views/errors/cli/error_exception.php @@ -14,7 +14,7 @@ $last = $prevException; CLI::write(' Caused by:'); - CLI::write(' [' . get_class($prevException) . ']', 'red'); + CLI::write(' [' . $prevException::class . ']', 'red'); CLI::write(' ' . $prevException->getMessage()); CLI::write(' at ' . CLI::color(clean_path($prevException->getFile()) . ':' . $prevException->getLine(), 'green')); CLI::newLine(); diff --git a/app/Views/errors/html/error_exception.php b/app/Views/errors/html/error_exception.php index 2e5571e97e4b..7f4717d4f291 100644 --- a/app/Views/errors/html/error_exception.php +++ b/app/Views/errors/html/error_exception.php @@ -55,10 +55,10 @@
     Caused by:
-    getCode() ? ' #' . $prevException->getCode() : '') ?>
+    getCode() ? ' #' . $prevException->getCode() : '') ?>
 
     getMessage())) ?>
-    getMessage())) ?>"
+    getMessage())) ?>"
        rel="noreferrer" target="_blank">search →
     getFile()) . ':' . $prevException->getLine()) ?>
     
diff --git a/system/CLI/InputOutput.php b/system/CLI/InputOutput.php index 5b6c1da02f4d..b69c19e2eee1 100644 --- a/system/CLI/InputOutput.php +++ b/system/CLI/InputOutput.php @@ -21,7 +21,7 @@ class InputOutput /** * Is the readline library on the system? */ - private bool $readlineSupport; + private readonly bool $readlineSupport; public function __construct() { diff --git a/system/Commands/Utilities/Routes/SampleURIGenerator.php b/system/Commands/Utilities/Routes/SampleURIGenerator.php index 4c4cf0c9112e..c0832a382eff 100644 --- a/system/Commands/Utilities/Routes/SampleURIGenerator.php +++ b/system/Commands/Utilities/Routes/SampleURIGenerator.php @@ -52,7 +52,7 @@ public function get(string $routeKey): string { $sampleUri = $routeKey; - if (strpos($routeKey, '{locale}') !== false) { + if (str_contains($routeKey, '{locale}')) { $sampleUri = str_replace( '{locale}', config(App::class)->defaultLocale, diff --git a/system/Filters/Filters.php b/system/Filters/Filters.php index 6816e72ab482..acfc9970c522 100644 --- a/system/Filters/Filters.php +++ b/system/Filters/Filters.php @@ -230,7 +230,7 @@ private function runAfter(array $filterClasses): ResponseInterface $class = new $className(); if (! $class instanceof FilterInterface) { - throw FilterException::forIncorrectInterface(get_class($class)); + throw FilterException::forIncorrectInterface($class::class); } $result = $class->after( diff --git a/system/Filters/PageCache.php b/system/Filters/PageCache.php index d6fa407f5a0d..c3bb2af90dd6 100644 --- a/system/Filters/PageCache.php +++ b/system/Filters/PageCache.php @@ -25,7 +25,7 @@ */ class PageCache implements FilterInterface { - private ResponseCache $pageCache; + private readonly ResponseCache $pageCache; public function __construct() { diff --git a/system/HTTP/Method.php b/system/HTTP/Method.php index 7aae162b3cba..6ad3847cc2f7 100644 --- a/system/HTTP/Method.php +++ b/system/HTTP/Method.php @@ -19,59 +19,59 @@ class Method /** * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/CONNECT */ - public const CONNECT = 'CONNECT'; + final public const CONNECT = 'CONNECT'; /** * Idempotent * * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/DELETE */ - public const DELETE = 'DELETE'; + final public const DELETE = 'DELETE'; /** * Safe, Idempotent, Cacheable * * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET */ - public const GET = 'GET'; + final public const GET = 'GET'; /** * Safe, Idempotent, Cacheable * * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD */ - public const HEAD = 'HEAD'; + final public const HEAD = 'HEAD'; /** * Safe, Idempotent * * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/OPTIONS */ - public const OPTIONS = 'OPTIONS'; + final public const OPTIONS = 'OPTIONS'; /** * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH */ - public const PATCH = 'PATCH'; + final public const PATCH = 'PATCH'; /** * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST */ - public const POST = 'POST'; + final public const POST = 'POST'; /** * Idempotent * * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT */ - public const PUT = 'PUT'; + final public const PUT = 'PUT'; /** * Safe, Idempotent * * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/TRACE */ - public const TRACE = 'TRACE'; + final public const TRACE = 'TRACE'; /** * Returns all HTTP methods. diff --git a/system/Validation/Rules.php b/system/Validation/Rules.php index 00a4480676f4..d0c609e84699 100644 --- a/system/Validation/Rules.php +++ b/system/Validation/Rules.php @@ -444,7 +444,7 @@ public function field_exists( ?string $error = null, ?string $field = null ): bool { - if (strpos($field, '.') !== false) { + if (str_contains($field, '.')) { return ArrayHelper::dotKeyExists($field, $data); } diff --git a/system/Validation/StrictRules/Rules.php b/system/Validation/StrictRules/Rules.php index 712200321764..abb0a6033c1f 100644 --- a/system/Validation/StrictRules/Rules.php +++ b/system/Validation/StrictRules/Rules.php @@ -44,7 +44,7 @@ public function differs( ?string $error = null, ?string $field = null ): bool { - if (strpos($otherField, '.') !== false) { + if (str_contains($otherField, '.')) { return $str !== dot_array_search($otherField, $data); } @@ -275,7 +275,7 @@ public function matches( ?string $error = null, ?string $field = null ): bool { - if (strpos($otherField, '.') !== false) { + if (str_contains($otherField, '.')) { return $str === dot_array_search($otherField, $data); } @@ -420,7 +420,7 @@ public function field_exists( ?string $error = null, ?string $field = null ): bool { - if (strpos($field, '.') !== false) { + if (str_contains($field, '.')) { return ArrayHelper::dotKeyExists($field, $data); }