N°8834 - Add compatibility with PHP 8.4 (#819)

* N°8834 - Add compatibility with PHP 8.4

* Rollback of scssphp/scssphp version upgrade due to compilation error
This commit is contained in:
Lenaick
2026-02-26 10:36:32 +01:00
committed by GitHub
parent d4821b7edc
commit fc967c06ce
961 changed files with 12298 additions and 7130 deletions

View File

@@ -16,5 +16,5 @@ namespace Symfony\Contracts\Translation;
*/
interface TranslatableInterface
{
public function trans(TranslatorInterface $translator, string $locale = null): string;
public function trans(TranslatorInterface $translator, ?string $locale = null): string;
}

View File

@@ -59,7 +59,7 @@ interface TranslatorInterface
*
* @throws \InvalidArgumentException If the locale contains invalid characters
*/
public function trans(string $id, array $parameters = [], string $domain = null, string $locale = null): string;
public function trans(string $id, array $parameters = [], ?string $domain = null, ?string $locale = null): string;
/**
* Returns the default locale.

View File

@@ -35,12 +35,18 @@ trait TranslatorTrait
return $this->locale ?: (class_exists(\Locale::class) ? \Locale::getDefault() : 'en');
}
public function trans(?string $id, array $parameters = [], string $domain = null, string $locale = null): string
public function trans(?string $id, array $parameters = [], ?string $domain = null, ?string $locale = null): string
{
if (null === $id || '' === $id) {
return '';
}
foreach ($parameters as $k => $v) {
if ($v instanceof TranslatableInterface) {
$parameters[$k] = $v->trans($this, $locale);
}
}
if (!isset($parameters['%count%']) || !is_numeric($parameters['%count%'])) {
return strtr($id, $parameters);
}
@@ -111,7 +117,7 @@ EOF;
return strtr($standardRules[0], $parameters);
}
$message = sprintf('Unable to choose a translation for "%s" with locale "%s" for value "%d". Double check that this translation has the correct plural options (e.g. "There is one apple|There are %%count%% apples").', $id, $locale, $number);
$message = \sprintf('Unable to choose a translation for "%s" with locale "%s" for value "%d". Double check that this translation has the correct plural options (e.g. "There is one apple|There are %%count%% apples").', $id, $locale, $number);
if (class_exists(InvalidArgumentException::class)) {
throw new InvalidArgumentException($message);

View File

@@ -27,7 +27,7 @@
"minimum-stability": "dev",
"extra": {
"branch-alias": {
"dev-main": "3.4-dev"
"dev-main": "3.6-dev"
},
"thanks": {
"name": "symfony/contracts",