Skip to content

Commit

Permalink
PHP 8.4 deprecates implicitly nullable parameter types.
Browse files Browse the repository at this point in the history
This commit fixes the issue by adding nullable types to the method signatures.
https://github.com/php/php-src/blob/php-8.4.0RC1/UPGRADING#L497

4. Deprecated Functionality

- Core:
  . Implicitly nullable parameter types are now deprecated.
    RFC: https://wiki.php.net/rfc/deprecate-implicitly-nullable-types
  • Loading branch information
selfsimilar committed Sep 27, 2024
1 parent 9990835 commit 0d0082f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/HasTranslations.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function getTranslationWithoutFallback(string $key, string $locale): mixe
return $this->getTranslation($key, $locale, false);
}

public function getTranslations(string $key = null, array $allowedLocales = null): array
public function getTranslations(?string $key = null, ?array $allowedLocales = null): array
{
if ($key !== null) {
$this->guardAgainstNonTranslatableAttribute($key);
Expand Down Expand Up @@ -223,7 +223,7 @@ public function isTranslatableAttribute(string $key): bool
return in_array($key, $this->getTranslatableAttributes());
}

public function hasTranslation(string $key, string $locale = null): bool
public function hasTranslation(string $key, ?string $locale = null): bool
{
$locale = $locale ?: $this->getLocale();

Expand Down Expand Up @@ -279,7 +279,7 @@ protected function normalizeLocale(string $key, string $locale, bool $useFallbac
return $locale;
}

protected function filterTranslations(mixed $value = null, string $locale = null, array $allowedLocales = null): bool
protected function filterTranslations(mixed $value = null, ?string $locale = null, ?array $allowedLocales = null): bool
{
if ($value === null) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/Translatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Translatable
public function fallback(
?string $fallbackLocale = null,
?bool $fallbackAny = false,
$missingKeyCallback = null
?Closure $missingKeyCallback = null
): self {
$this->fallbackLocale = $fallbackLocale;
$this->fallbackAny = $fallbackAny;
Expand Down

0 comments on commit 0d0082f

Please sign in to comment.