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

@@ -31,7 +31,7 @@ final class BodyRenderer implements BodyRendererInterface
private HtmlToTextConverterInterface $converter;
private ?LocaleSwitcher $localeSwitcher = null;
public function __construct(Environment $twig, array $context = [], HtmlToTextConverterInterface $converter = null, LocaleSwitcher $localeSwitcher = null)
public function __construct(Environment $twig, array $context = [], ?HtmlToTextConverterInterface $converter = null, ?LocaleSwitcher $localeSwitcher = null)
{
$this->twig = $twig;
$this->context = $context;
@@ -45,7 +45,7 @@ final class BodyRenderer implements BodyRendererInterface
return;
}
if (null === $message->getTextTemplate() && null === $message->getHtmlTemplate()) {
if ($message->isRendered()) {
// email has already been rendered
return;
}
@@ -54,7 +54,7 @@ final class BodyRenderer implements BodyRendererInterface
$messageContext = $message->getContext();
if (isset($messageContext['email'])) {
throw new InvalidArgumentException(sprintf('A "%s" context cannot have an "email" entry as this is a reserved variable.', get_debug_type($message)));
throw new InvalidArgumentException(\sprintf('A "%s" context cannot have an "email" entry as this is a reserved variable.', get_debug_type($message)));
}
$vars = array_merge($this->context, $messageContext, [

View File

@@ -42,7 +42,7 @@ class NotificationEmail extends TemplatedEmail
];
private bool $rendered = false;
public function __construct(Headers $headers = null, AbstractPart $body = null)
public function __construct(?Headers $headers = null, ?AbstractPart $body = null)
{
$missingPackages = [];
if (!class_exists(CssInlinerExtension::class)) {
@@ -54,7 +54,7 @@ class NotificationEmail extends TemplatedEmail
}
if ($missingPackages) {
throw new \LogicException(sprintf('You cannot use "%s" if the "%s" Twig extension%s not available. Try running "%s".', static::class, implode('" and "', $missingPackages), \count($missingPackages) > 1 ? 's are' : ' is', 'composer require '.implode(' ', array_keys($missingPackages))));
throw new \LogicException(\sprintf('You cannot use "%s" if the "%s" Twig extension%s not available. Try running "%s".', static::class, implode('" and "', $missingPackages), \count($missingPackages) > 1 ? 's are' : ' is', 'composer require '.implode(' ', array_keys($missingPackages))));
}
parent::__construct($headers, $body);
@@ -63,7 +63,7 @@ class NotificationEmail extends TemplatedEmail
/**
* Creates a NotificationEmail instance that is appropriate to send to normal (non-admin) users.
*/
public static function asPublicEmail(Headers $headers = null, AbstractPart $body = null): self
public static function asPublicEmail(?Headers $headers = null, ?AbstractPart $body = null): self
{
$email = new static($headers, $body);
$email->markAsPublic();
@@ -88,7 +88,7 @@ class NotificationEmail extends TemplatedEmail
public function markdown(string $content): static
{
if (!class_exists(MarkdownExtension::class)) {
throw new \LogicException(sprintf('You cannot use "%s" if the Markdown Twig extension is not available. Try running "composer require twig/markdown-extra".', __METHOD__));
throw new \LogicException(\sprintf('You cannot use "%s" if the Markdown Twig extension is not available. Try running "composer require twig/markdown-extra".', __METHOD__));
}
$this->context['markdown'] = true;
@@ -174,6 +174,26 @@ class NotificationEmail extends TemplatedEmail
return '@email/'.$this->theme.'/notification/body.html.twig';
}
/**
* @return $this
*/
public function context(array $context): static
{
$parentContext = [];
foreach ($context as $key => $value) {
if (\array_key_exists($key, $this->context)) {
$this->context[$key] = $value;
} else {
$parentContext[$key] = $value;
}
}
parent::context($parentContext);
return $this;
}
public function getContext(): array
{
return array_merge($this->context, parent::getContext());
@@ -198,7 +218,7 @@ class NotificationEmail extends TemplatedEmail
$importance = $this->context['importance'] ?? self::IMPORTANCE_LOW;
$this->priority($this->determinePriority($importance));
if ($this->context['importance']) {
$headers->setHeaderBody('Text', 'Subject', sprintf('[%s] %s', strtoupper($importance), $this->getSubject()));
$headers->setHeaderBody('Text', 'Subject', \sprintf('[%s] %s', strtoupper($importance), $this->getSubject()));
}
return $headers;

View File

@@ -43,7 +43,7 @@ final class WrappedTemplatedEmail
* @param string|null $contentType The media type (i.e. MIME type) of the image file (e.g. 'image/png').
* Some email clients require this to display embedded images.
*/
public function image(string $image, string $contentType = null): string
public function image(string $image, ?string $contentType = null): string
{
$file = $this->twig->getLoader()->getSourceContext($image);
$body = $file->getPath() ? new File($file->getPath()) : $file->getCode();
@@ -59,7 +59,7 @@ final class WrappedTemplatedEmail
* @param string|null $contentType The media type (i.e. MIME type) of the file (e.g. 'application/pdf').
* Some email clients require this to display attached files.
*/
public function attach(string $file, string $name = null, string $contentType = null): void
public function attach(string $file, ?string $name = null, ?string $contentType = null): void
{
$file = $this->twig->getLoader()->getSourceContext($file);
$body = $file->getPath() ? new File($file->getPath()) : $file->getCode();