From dc532bd18464ef4c5b6a42ed24c0e3930b8404ed Mon Sep 17 00:00:00 2001 From: Daniel Stainback Date: Tue, 10 Dec 2024 10:50:03 -0500 Subject: [PATCH] PHP 8.4 updates --- composer.json | 4 ++-- src/Concerns/Cacheable.php | 4 ++-- src/Concerns/Messages.php | 4 ++-- src/Concerns/Ordering.php | 10 +++++----- src/Concerns/Scopes.php | 2 +- src/Concerns/Searching.php | 10 +++++----- src/Contracts/Repository.php | 4 ++-- src/Repository.php | 2 +- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/composer.json b/composer.json index f579227..c234518 100755 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^8.0", + "php": "^8.2", "illuminate/support": "^8.0|^9.0|^10.0|^11.0", "illuminate/database": "^8.0|^9.0|^10.0|^11.0", "illuminate/cache": "^8.0|^9.0|^10.0|^11.0" @@ -24,7 +24,7 @@ "require-dev": { "phpunit/phpunit": "^9.0", "mockery/mockery": "^1.4", - "phpstan/phpstan": "^1.6", + "phpstan/phpstan": "^2.0", "squizlabs/php_codesniffer": "^3.6" }, "autoload": { diff --git a/src/Concerns/Cacheable.php b/src/Concerns/Cacheable.php index 23071e3..f3b67d6 100644 --- a/src/Concerns/Cacheable.php +++ b/src/Concerns/Cacheable.php @@ -67,7 +67,7 @@ public function skippedCache(): bool * * @return string */ - public function getCacheKey(string $method, array $args = null, string $tag = ''): string + public function getCacheKey(string $method, array|null $args = null, string $tag = ''): string { // Sort through arguments foreach ($args as &$a) { @@ -98,7 +98,7 @@ public function getCacheKey(string $method, array $args = null, string $tag = '' * * @return mixed */ - public function cacheCallback(string $method, array $args, Closure $callback, int $time = null): mixed + public function cacheCallback(string $method, array $args, Closure $callback, int|null $time = null): mixed { // Cache disabled, just execute query & return result if ($this->skippedCache() === true) { diff --git a/src/Concerns/Messages.php b/src/Concerns/Messages.php index 1d6bcc3..b13a52d 100644 --- a/src/Concerns/Messages.php +++ b/src/Concerns/Messages.php @@ -41,7 +41,7 @@ public function hasMessage(string $key = 'message'): bool /** * {@inheritDoc} */ - public function getMessage(string $key = null, string $format = null, string $default = ''): string + public function getMessage(string|null $key = null, string|null $format = null, string $default = ''): string { return $this->getMessageBag()->first($key, $format) ?: $default; } @@ -67,7 +67,7 @@ public function hasErrors(): bool /** * {@inheritDoc} */ - public function getErrors(string $format = null): array + public function getErrors(string|null $format = null): array { return $this->getMessageBag()->get('error', $format); } diff --git a/src/Concerns/Ordering.php b/src/Concerns/Ordering.php index 60034ec..68a52f7 100644 --- a/src/Concerns/Ordering.php +++ b/src/Concerns/Ordering.php @@ -161,11 +161,11 @@ protected function applyOrderableScope(string $column, string $direction): stati * @return string */ public function addOrderByJoin( - Builder $query, - string $joining_table, - string $foreign_key, - string $related_key, - string $alias = null + Builder $query, + string $joining_table, + string $foreign_key, + string $related_key, + string|null $alias = null ): string { // We need to join to the intermediate table $local_table = $this->getModel()->getTable(); diff --git a/src/Concerns/Scopes.php b/src/Concerns/Scopes.php index a8a1e1e..38e6f11 100644 --- a/src/Concerns/Scopes.php +++ b/src/Concerns/Scopes.php @@ -92,7 +92,7 @@ public function getScopeQuery(): array * * @return static */ - public function addScopeQuery(Closure|Scope $scope, string $key = null): static + public function addScopeQuery(Closure|Scope $scope, string|null $key = null): static { if ($scope instanceof Scope && $scope->shouldSkip()) { return $this; diff --git a/src/Concerns/Searching.php b/src/Concerns/Searching.php index f373c05..a893c94 100644 --- a/src/Concerns/Searching.php +++ b/src/Concerns/Searching.php @@ -135,11 +135,11 @@ public function createSearchClause( * @return string */ public function addSearchJoin( - Builder $query, - string $joining_table, - string $foreign_key, - string $related_key, - string $alias = null + Builder $query, + string $joining_table, + string $foreign_key, + string $related_key, + string|null $alias = null ): string { // We need to join to the intermediate table $local_table = $this->getModel()->getTable(); diff --git a/src/Contracts/Repository.php b/src/Contracts/Repository.php index 3f843bb..1c2090b 100644 --- a/src/Contracts/Repository.php +++ b/src/Contracts/Repository.php @@ -120,7 +120,7 @@ public function count(array $columns = ['*']): int; * * @return array */ - public function pluck(string $value, string $key = null): array; + public function pluck(string $value, string|null $key = null): array; /** * Retrieve all data of repository, paginated @@ -205,7 +205,7 @@ public function hasMessage(string $key = 'message'): bool; * * @return string */ - public function getMessage(string $key = null, string $format = null, string $default = ''): string; + public function getMessage(string|null $key = null, string|null $format = null, string $default = ''): string; /** * Add an error to the message bag diff --git a/src/Repository.php b/src/Repository.php index 111535a..5db4920 100755 --- a/src/Repository.php +++ b/src/Repository.php @@ -219,7 +219,7 @@ public function count(array $columns = ['*']): int /** * {@inheritDoc} */ - public function pluck(string $value, string $key = null): array + public function pluck(string $value, string|null $key = null): array { $this->newQuery();