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: - = esc(get_class($prevException)), esc($prevException->getCode() ? ' #' . $prevException->getCode() : '') ?> + = esc($prevException::class), esc($prevException->getCode() ? ' #' . $prevException->getCode() : '') ?> = nl2br(esc($prevException->getMessage())) ?> - getMessage())) ?>" + getMessage())) ?>" rel="noreferrer" target="_blank">search → = esc(clean_path($prevException->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/Debug/Exceptions.php b/system/Debug/Exceptions.php index 2ae5890c6acb..dfb5b81bd7bd 100644 --- a/system/Debug/Exceptions.php +++ b/system/Debug/Exceptions.php @@ -130,7 +130,7 @@ public function exceptionHandler(Throwable $exception) $uri = $this->request->getPath() === '' ? '/' : $this->request->getPath(); $routeInfo = '[Method: ' . $this->request->getMethod() . ', Route: ' . $uri . ']'; - log_message('critical', get_class($exception) . ": {message}\n{routeInfo}\nin {exFile} on line {exLine}.\n{trace}", [ + log_message('critical', $exception::class . ": {message}\n{routeInfo}\nin {exFile} on line {exLine}.\n{trace}", [ 'message' => $exception->getMessage(), 'routeInfo' => $routeInfo, 'exFile' => clean_path($exception->getFile()), // {file} refers to THIS file @@ -144,7 +144,7 @@ public function exceptionHandler(Throwable $exception) while ($prevException = $last->getPrevious()) { $last = $prevException; - log_message('critical', '[Caused by] ' . get_class($prevException) . ": {message}\nin {exFile} on line {exLine}.\n{trace}", [ + log_message('critical', '[Caused by] ' . $prevException::class . ": {message}\nin {exFile} on line {exLine}.\n{trace}", [ 'message' => $prevException->getMessage(), 'exFile' => clean_path($prevException->getFile()), // {file} refers to THIS file 'exLine' => $prevException->getLine(), // {line} refers to THIS line 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/Router/Router.php b/system/Router/Router.php index e7b0c087c07d..54005c812cd9 100644 --- a/system/Router/Router.php +++ b/system/Router/Router.php @@ -30,7 +30,7 @@ class Router implements RouterInterface /** * List of allowed HTTP methods (and CLI for command line use). */ - public const HTTP_METHODS = [ + final public const HTTP_METHODS = [ Method::GET, Method::HEAD, Method::POST, 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); }