Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
do not access properties before initialization
  • Loading branch information
xabbuh committed Oct 9, 2023
commit 6e19d1ad4e9adec858e5e69ebe06ee30eae4f713
10 changes: 7 additions & 3 deletions src/Symfony/Component/HttpFoundation/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ class Request
protected string $defaultLocale = 'en';

/**
* @var array<string, string[]>
* @var array<string, string[]>|null
*/
protected static array $formats;
protected static ?array $formats = null;

protected static ?\Closure $requestFactory = null;

Expand Down Expand Up @@ -1499,7 +1499,11 @@ public function isNoCache(): bool
*/
public function getPreferredFormat(?string $default = 'html'): ?string
{
if ($this->preferredFormat ??= $this->getRequestFormat(null)) {
if (!isset($this->preferredFormat) && null !== $preferredFormat = $this->getRequestFormat(null)) {
$this->preferredFormat = $preferredFormat;
}

if ($this->preferredFormat ?? null) {
return $this->preferredFormat;
}

Expand Down