Skip to content

Commit

Permalink
refactor: run rector
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Nov 30, 2023
1 parent d6f977c commit 71124e7
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion app/Views/errors/cli/error_exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions app/Views/errors/html/error_exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@
<pre>
Caused by:
<?= esc(get_class($prevException)), esc($prevException->getCode() ? ' #' . $prevException->getCode() : '') ?>
<?= esc($prevException::class), esc($prevException->getCode() ? ' #' . $prevException->getCode() : '') ?>

<?= nl2br(esc($prevException->getMessage())) ?>
<a href="https://www.duckduckgo.com/?q=<?= urlencode(get_class($prevException) . ' ' . preg_replace('#\'.*\'|".*"#Us', '', $prevException->getMessage())) ?>"
<a href="https://www.duckduckgo.com/?q=<?= urlencode($prevException::class . ' ' . preg_replace('#\'.*\'|".*"#Us', '', $prevException->getMessage())) ?>"
rel="noreferrer" target="_blank">search &rarr;</a>
<?= esc(clean_path($prevException->getFile()) . ':' . $prevException->getLine()) ?>
</pre>
Expand Down
2 changes: 1 addition & 1 deletion system/CLI/InputOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class InputOutput
/**
* Is the readline library on the system?
*/
private bool $readlineSupport;
private readonly bool $readlineSupport;

public function __construct()
{
Expand Down
2 changes: 1 addition & 1 deletion system/Commands/Utilities/Routes/SampleURIGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions system/Debug/Exceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion system/Filters/Filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion system/Filters/PageCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/
class PageCache implements FilterInterface
{
private ResponseCache $pageCache;
private readonly ResponseCache $pageCache;

public function __construct()
{
Expand Down
18 changes: 9 additions & 9 deletions system/HTTP/Method.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion system/Router/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion system/Validation/Rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
6 changes: 3 additions & 3 deletions system/Validation/StrictRules/Rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 71124e7

Please sign in to comment.