Skip to content

Commit

Permalink
Merge branch '5.4' into 6.3
Browse files Browse the repository at this point in the history
* 5.4:
  Fix implicitly-required parameters
  List CS fix in .git-blame-ignore-revs
  Apply php-cs-fixer fix --rules nullable_type_declaration_for_default_null_value
  [Messenger][AmazonSqs] Allow async-aws/sqs version 2
  • Loading branch information
nicolas-grekas committed Jan 23, 2024
2 parents 25639a4 + f2ab692 commit 3b72add
Show file tree
Hide file tree
Showing 32 changed files with 59 additions and 59 deletions.
4 changes: 2 additions & 2 deletions BinaryFileResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class BinaryFileResponse extends Response
* @param bool $autoEtag Whether the ETag header should be automatically set
* @param bool $autoLastModified Whether the Last-Modified header should be automatically set
*/
public function __construct(\SplFileInfo|string $file, int $status = 200, array $headers = [], bool $public = true, string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true)
public function __construct(\SplFileInfo|string $file, int $status = 200, array $headers = [], bool $public = true, ?string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true)
{
parent::__construct(null, $status, $headers);

Expand All @@ -63,7 +63,7 @@ public function __construct(\SplFileInfo|string $file, int $status = 200, array
*
* @throws FileException
*/
public function setFile(\SplFileInfo|string $file, string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true): static
public function setFile(\SplFileInfo|string $file, ?string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true): static
{
if (!$file instanceof File) {
if ($file instanceof \SplFileInfo) {
Expand Down
4 changes: 2 additions & 2 deletions Cookie.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static function fromString(string $cookie, bool $decode = false): static
*
* @param self::SAMESITE_*|''|null $sameSite
*/
public static function create(string $name, string $value = null, int|string|\DateTimeInterface $expire = 0, ?string $path = '/', string $domain = null, bool $secure = null, bool $httpOnly = true, bool $raw = false, ?string $sameSite = self::SAMESITE_LAX): self
public static function create(string $name, ?string $value = null, int|string|\DateTimeInterface $expire = 0, ?string $path = '/', ?string $domain = null, ?bool $secure = null, bool $httpOnly = true, bool $raw = false, ?string $sameSite = self::SAMESITE_LAX): self
{
return new self($name, $value, $expire, $path, $domain, $secure, $httpOnly, $raw, $sameSite);
}
Expand All @@ -92,7 +92,7 @@ public static function create(string $name, string $value = null, int|string|\Da
*
* @throws \InvalidArgumentException
*/
public function __construct(string $name, string $value = null, int|string|\DateTimeInterface $expire = 0, ?string $path = '/', string $domain = null, bool $secure = null, bool $httpOnly = true, bool $raw = false, ?string $sameSite = self::SAMESITE_LAX)
public function __construct(string $name, ?string $value = null, int|string|\DateTimeInterface $expire = 0, ?string $path = '/', ?string $domain = null, ?bool $secure = null, bool $httpOnly = true, bool $raw = false, ?string $sameSite = self::SAMESITE_LAX)
{
// from PHP source code
if ($raw && false !== strpbrk($name, self::RESERVED_CHARS_LIST)) {
Expand Down
2 changes: 1 addition & 1 deletion Exception/SessionNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
class SessionNotFoundException extends \LogicException implements RequestExceptionInterface
{
public function __construct(string $message = 'There is currently no session available.', int $code = 0, \Throwable $previous = null)
public function __construct(string $message = 'There is currently no session available.', int $code = 0, ?\Throwable $previous = null)
{
parent::__construct($message, $code, $previous);
}
Expand Down
4 changes: 2 additions & 2 deletions File/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function getMimeType(): ?string
*
* @throws FileException if the target file could not be created
*/
public function move(string $directory, string $name = null): self
public function move(string $directory, ?string $name = null): self
{
$target = $this->getTargetFile($directory, $name);

Expand Down Expand Up @@ -112,7 +112,7 @@ public function getContent(): string
return $content;
}

protected function getTargetFile(string $directory, string $name = null): self
protected function getTargetFile(string $directory, ?string $name = null): self
{
if (!is_dir($directory)) {
if (false === @mkdir($directory, 0777, true) && !is_dir($directory)) {
Expand Down
4 changes: 2 additions & 2 deletions File/UploadedFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class UploadedFile extends File
* @throws FileException If file_uploads is disabled
* @throws FileNotFoundException If the file does not exist
*/
public function __construct(string $path, string $originalName, string $mimeType = null, int $error = null, bool $test = false)
public function __construct(string $path, string $originalName, ?string $mimeType = null, ?int $error = null, bool $test = false)
{
$this->originalName = $this->getName($originalName);
$this->mimeType = $mimeType ?: 'application/octet-stream';
Expand Down Expand Up @@ -158,7 +158,7 @@ public function isValid(): bool
*
* @throws FileException if, for any reason, the file could not have been moved
*/
public function move(string $directory, string $name = null): File
public function move(string $directory, ?string $name = null): File
{
if ($this->isValid()) {
if ($this->test) {
Expand Down
6 changes: 3 additions & 3 deletions HeaderBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function __toString(): string
*
* @return ($key is null ? array<string, list<string|null>> : list<string|null>)
*/
public function all(string $key = null): array
public function all(?string $key = null): array
{
if (null !== $key) {
return $this->headers[strtr($key, self::UPPER, self::LOWER)] ?? [];
Expand Down Expand Up @@ -110,7 +110,7 @@ public function add(array $headers)
/**
* Returns the first header by name or the default one.
*/
public function get(string $key, string $default = null): ?string
public function get(string $key, ?string $default = null): ?string
{
$headers = $this->all($key);

Expand Down Expand Up @@ -195,7 +195,7 @@ public function remove(string $key)
*
* @throws \RuntimeException When the HTTP header is not parseable
*/
public function getDate(string $key, \DateTime $default = null): ?\DateTimeInterface
public function getDate(string $key, ?\DateTime $default = null): ?\DateTimeInterface
{
if (null === $value = $this->get($key)) {
return $default;
Expand Down
2 changes: 1 addition & 1 deletion InputBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function set(string $key, mixed $value): void
*
* @return ?T
*/
public function getEnum(string $key, string $class, \BackedEnum $default = null): ?\BackedEnum
public function getEnum(string $key, string $class, ?\BackedEnum $default = null): ?\BackedEnum
{
try {
return parent::getEnum($key, $class, $default);
Expand Down
2 changes: 1 addition & 1 deletion JsonResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static function fromJsonString(string $data, int $status = 200, array $he
*
* @throws \InvalidArgumentException When the callback name is not valid
*/
public function setCallback(string $callback = null): static
public function setCallback(?string $callback = null): static
{
if (1 > \func_num_args()) {
trigger_deprecation('symfony/http-foundation', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__);
Expand Down
4 changes: 2 additions & 2 deletions ParameterBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct(array $parameters = [])
*
* @param string|null $key The name of the parameter to return or null to get them all
*/
public function all(string $key = null): array
public function all(?string $key = null): array
{
if (null === $key) {
return $this->parameters;
Expand Down Expand Up @@ -173,7 +173,7 @@ public function getBoolean(string $key, bool $default = false): bool
*
* @return ?T
*/
public function getEnum(string $key, string $class, \BackedEnum $default = null): ?\BackedEnum
public function getEnum(string $key, string $class, ?\BackedEnum $default = null): ?\BackedEnum
{
$value = $this->get($key);

Expand Down
6 changes: 3 additions & 3 deletions Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ public static function setFactory(?callable $callable)
* @param array|null $files The FILES parameters
* @param array|null $server The SERVER parameters
*/
public function duplicate(array $query = null, array $request = null, array $attributes = null, array $cookies = null, array $files = null, array $server = null): static
public function duplicate(?array $query = null, ?array $request = null, ?array $attributes = null, ?array $cookies = null, ?array $files = null, ?array $server = null): static
{
$dup = clone $this;
if (null !== $query) {
Expand Down Expand Up @@ -1604,7 +1604,7 @@ public function getPreferredFormat(?string $default = 'html'): ?string
*
* @param string[] $locales An array of ordered available locales
*/
public function getPreferredLanguage(array $locales = null): ?string
public function getPreferredLanguage(?array $locales = null): ?string
{
$preferredLanguages = $this->getLanguages();

Expand Down Expand Up @@ -2009,7 +2009,7 @@ public function isFromTrustedProxy(): bool
return self::$trustedProxies && IpUtils::checkIp($this->server->get('REMOTE_ADDR', ''), self::$trustedProxies);
}

private function getTrustedValues(int $type, string $ip = null): array
private function getTrustedValues(int $type, ?string $ip = null): array
{
$clientValues = [];
$forwardedValues = [];
Expand Down
2 changes: 1 addition & 1 deletion RequestMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class RequestMatcher implements RequestMatcherInterface
* @param string|string[]|null $ips
* @param string|string[]|null $schemes
*/
public function __construct(string $path = null, string $host = null, string|array $methods = null, string|array $ips = null, array $attributes = [], string|array $schemes = null, int $port = null)
public function __construct(?string $path = null, ?string $host = null, string|array|null $methods = null, string|array|null $ips = null, array $attributes = [], string|array|null $schemes = null, ?int $port = null)
{
$this->matchPath($path);
$this->matchHost($host);
Expand Down
10 changes: 5 additions & 5 deletions Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ public function getProtocolVersion(): string
*
* @final
*/
public function setStatusCode(int $code, string $text = null): static
public function setStatusCode(int $code, ?string $text = null): static
{
$this->statusCode = $code;
if ($this->isInvalid()) {
Expand Down Expand Up @@ -764,7 +764,7 @@ public function getExpires(): ?\DateTimeInterface
*
* @final
*/
public function setExpires(\DateTimeInterface $date = null): static
public function setExpires(?\DateTimeInterface $date = null): static
{
if (1 > \func_num_args()) {
trigger_deprecation('symfony/http-foundation', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__);
Expand Down Expand Up @@ -948,7 +948,7 @@ public function getLastModified(): ?\DateTimeInterface
*
* @final
*/
public function setLastModified(\DateTimeInterface $date = null): static
public function setLastModified(?\DateTimeInterface $date = null): static
{
if (1 > \func_num_args()) {
trigger_deprecation('symfony/http-foundation', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__);
Expand Down Expand Up @@ -989,7 +989,7 @@ public function getEtag(): ?string
*
* @final
*/
public function setEtag(string $etag = null, bool $weak = false): static
public function setEtag(?string $etag = null, bool $weak = false): static
{
if (1 > \func_num_args()) {
trigger_deprecation('symfony/http-foundation', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__);
Expand Down Expand Up @@ -1292,7 +1292,7 @@ public function isNotFound(): bool
*
* @final
*/
public function isRedirect(string $location = null): bool
public function isRedirect(?string $location = null): bool
{
return \in_array($this->statusCode, [201, 301, 302, 303, 307, 308]) && (null === $location ?: $location == $this->headers->get('Location'));
}
Expand Down
6 changes: 3 additions & 3 deletions ResponseHeaderBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function replace(array $headers = [])
}
}

public function all(string $key = null): array
public function all(?string $key = null): array
{
$headers = parent::all();

Expand Down Expand Up @@ -183,7 +183,7 @@ public function setCookie(Cookie $cookie)
*
* @return void
*/
public function removeCookie(string $name, ?string $path = '/', string $domain = null)
public function removeCookie(string $name, ?string $path = '/', ?string $domain = null)
{
$path ??= '/';

Expand Down Expand Up @@ -236,7 +236,7 @@ public function getCookies(string $format = self::COOKIES_FLAT): array
*
* @return void
*/
public function clearCookie(string $name, ?string $path = '/', string $domain = null, bool $secure = false, bool $httpOnly = true, string $sameSite = null)
public function clearCookie(string $name, ?string $path = '/', ?string $domain = null, bool $secure = false, bool $httpOnly = true, ?string $sameSite = null)
{
$this->setCookie(new Cookie($name, null, 1, $path, $domain, $secure, $httpOnly, false, $sameSite));
}
Expand Down
6 changes: 3 additions & 3 deletions Session/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Session implements FlashBagAwareSessionInterface, \IteratorAggregate, \Cou
private int $usageIndex = 0;
private ?\Closure $usageReporter;

public function __construct(SessionStorageInterface $storage = null, AttributeBagInterface $attributes = null, FlashBagInterface $flashes = null, callable $usageReporter = null)
public function __construct(?SessionStorageInterface $storage = null, ?AttributeBagInterface $attributes = null, ?FlashBagInterface $flashes = null, ?callable $usageReporter = null)
{
$this->storage = $storage ?? new NativeSessionStorage();
$this->usageReporter = null === $usageReporter ? null : $usageReporter(...);
Expand Down Expand Up @@ -151,14 +151,14 @@ public function isEmpty(): bool
return true;
}

public function invalidate(int $lifetime = null): bool
public function invalidate(?int $lifetime = null): bool
{
$this->storage->clear();

return $this->migrate(true, $lifetime);
}

public function migrate(bool $destroy = false, int $lifetime = null): bool
public function migrate(bool $destroy = false, ?int $lifetime = null): bool
{
return $this->storage->regenerate($destroy, $lifetime);
}
Expand Down
2 changes: 1 addition & 1 deletion Session/SessionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class SessionFactory implements SessionFactoryInterface
private SessionStorageFactoryInterface $storageFactory;
private ?\Closure $usageReporter;

public function __construct(RequestStack $requestStack, SessionStorageFactoryInterface $storageFactory, callable $usageReporter = null)
public function __construct(RequestStack $requestStack, SessionStorageFactoryInterface $storageFactory, ?callable $usageReporter = null)
{
$this->requestStack = $requestStack;
$this->storageFactory = $storageFactory;
Expand Down
4 changes: 2 additions & 2 deletions Session/SessionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function setName(string $name);
* to expire with browser session. Time is in seconds, and is
* not a Unix timestamp.
*/
public function invalidate(int $lifetime = null): bool;
public function invalidate(?int $lifetime = null): bool;

/**
* Migrates the current session to a new session id while maintaining all
Expand All @@ -74,7 +74,7 @@ public function invalidate(int $lifetime = null): bool;
* to expire with browser session. Time is in seconds, and is
* not a Unix timestamp.
*/
public function migrate(bool $destroy = false, int $lifetime = null): bool;
public function migrate(bool $destroy = false, ?int $lifetime = null): bool;

/**
* Force the session to be saved and closed.
Expand Down
2 changes: 1 addition & 1 deletion Session/Storage/Handler/NativeFileSessionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class NativeFileSessionHandler extends \SessionHandler
* @throws \InvalidArgumentException On invalid $savePath
* @throws \RuntimeException When failing to create the save directory
*/
public function __construct(string $savePath = null)
public function __construct(?string $savePath = null)
{
$baseDir = $savePath ??= \ini_get('session.save_path');

Expand Down
4 changes: 2 additions & 2 deletions Session/Storage/Handler/PdoSessionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class PdoSessionHandler extends AbstractSessionHandler
*
* @throws \InvalidArgumentException When PDO error mode is not PDO::ERRMODE_EXCEPTION
*/
public function __construct(#[\SensitiveParameter] \PDO|string $pdoOrDsn = null, #[\SensitiveParameter] array $options = [])
public function __construct(#[\SensitiveParameter] \PDO|string|null $pdoOrDsn = null, #[\SensitiveParameter] array $options = [])
{
if ($pdoOrDsn instanceof \PDO) {
if (\PDO::ERRMODE_EXCEPTION !== $pdoOrDsn->getAttribute(\PDO::ATTR_ERRMODE)) {
Expand Down Expand Up @@ -181,7 +181,7 @@ public function __construct(#[\SensitiveParameter] \PDO|string $pdoOrDsn = null,
/**
* Adds the Table to the Schema if it doesn't exist.
*/
public function configureSchema(Schema $schema, \Closure $isSameDatabase = null): void
public function configureSchema(Schema $schema, ?\Closure $isSameDatabase = null): void
{
if ($schema->hasTable($this->table) || ($isSameDatabase && !$isSameDatabase($this->getConnection()->exec(...)))) {
return;
Expand Down
4 changes: 2 additions & 2 deletions Session/Storage/MetadataBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function getLifetime(): int
*
* @return void
*/
public function stampNew(int $lifetime = null)
public function stampNew(?int $lifetime = null)
{
$this->stampCreated($lifetime);
}
Expand Down Expand Up @@ -139,7 +139,7 @@ public function setName(string $name)
$this->name = $name;
}

private function stampCreated(int $lifetime = null): void
private function stampCreated(?int $lifetime = null): void
{
$timeStamp = time();
$this->meta[self::CREATED] = $this->meta[self::UPDATED] = $this->lastUsed = $timeStamp;
Expand Down
6 changes: 3 additions & 3 deletions Session/Storage/MockArraySessionStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class MockArraySessionStorage implements SessionStorageInterface
*/
protected $bags = [];

public function __construct(string $name = 'MOCKSESSID', MetadataBag $metaBag = null)
public function __construct(string $name = 'MOCKSESSID', ?MetadataBag $metaBag = null)
{
$this->name = $name;
$this->setMetadataBag($metaBag);
Expand Down Expand Up @@ -91,7 +91,7 @@ public function start(): bool
return true;
}

public function regenerate(bool $destroy = false, int $lifetime = null): bool
public function regenerate(bool $destroy = false, ?int $lifetime = null): bool
{
if (!$this->started) {
$this->start();
Expand Down Expand Up @@ -192,7 +192,7 @@ public function isStarted(): bool
/**
* @return void
*/
public function setMetadataBag(MetadataBag $bag = null)
public function setMetadataBag(?MetadataBag $bag = null)
{
if (1 > \func_num_args()) {
trigger_deprecation('symfony/http-foundation', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__);
Expand Down
4 changes: 2 additions & 2 deletions Session/Storage/MockFileSessionStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class MockFileSessionStorage extends MockArraySessionStorage
/**
* @param string|null $savePath Path of directory to save session files
*/
public function __construct(string $savePath = null, string $name = 'MOCKSESSID', MetadataBag $metaBag = null)
public function __construct(?string $savePath = null, string $name = 'MOCKSESSID', ?MetadataBag $metaBag = null)
{
$savePath ??= sys_get_temp_dir();

Expand Down Expand Up @@ -60,7 +60,7 @@ public function start(): bool
return true;
}

public function regenerate(bool $destroy = false, int $lifetime = null): bool
public function regenerate(bool $destroy = false, ?int $lifetime = null): bool
{
if (!$this->started) {
$this->start();
Expand Down
Loading

0 comments on commit 3b72add

Please sign in to comment.