Skip to content

Commit

Permalink
Apply php-cs-fixer fix --rules nullable_type_declaration_for_default_…
Browse files Browse the repository at this point in the history
…null_value
  • Loading branch information
nicolas-grekas committed Jan 23, 2024
1 parent 528f59f commit f2ab692
Show file tree
Hide file tree
Showing 30 changed files with 55 additions and 55 deletions.
6 changes: 3 additions & 3 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($file, int $status = 200, array $headers = [], bool $public = true, string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true)
public function __construct($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 @@ -69,7 +69,7 @@ public function __construct($file, int $status = 200, array $headers = [], bool
*
* @deprecated since Symfony 5.2, use __construct() instead.
*/
public static function create($file = null, int $status = 200, array $headers = [], bool $public = true, string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true)
public static function create($file = null, int $status = 200, array $headers = [], bool $public = true, ?string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true)
{
trigger_deprecation('symfony/http-foundation', '5.2', 'The "%s()" method is deprecated, use "new %s()" instead.', __METHOD__, static::class);

Expand All @@ -85,7 +85,7 @@ public static function create($file = null, int $status = 200, array $headers =
*
* @throws FileException
*/
public function setFile($file, string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true)
public function setFile($file, ?string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true)
{
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 @@ -71,7 +71,7 @@ public static function fromString(string $cookie, bool $decode = false)
return new static($name, $value, $data['expires'], $data['path'], $data['domain'], $data['secure'], $data['httponly'], $data['raw'], $data['samesite']);
}

public static function create(string $name, string $value = null, $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, $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 @@ -89,7 +89,7 @@ public static function create(string $name, string $value = null, $expire = 0, ?
*
* @throws \InvalidArgumentException
*/
public function __construct(string $name, string $value = null, $expire = 0, ?string $path = '/', string $domain = null, bool $secure = null, bool $httpOnly = true, bool $raw = false, ?string $sameSite = 'lax')
public function __construct(string $name, ?string $value = null, $expire = 0, ?string $path = '/', ?string $domain = null, ?bool $secure = null, bool $httpOnly = true, bool $raw = false, ?string $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 @@ -88,7 +88,7 @@ public function getMimeType()
*
* @throws FileException if the target file could not be created
*/
public function move(string $directory, string $name = null)
public function move(string $directory, ?string $name = null)
{
$target = $this->getTargetFile($directory, $name);

Expand Down Expand Up @@ -121,7 +121,7 @@ public function getContent(): string
/**
* @return self
*/
protected function getTargetFile(string $directory, string $name = null)
protected function getTargetFile(string $directory, ?string $name = null)
{
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 @@ -172,7 +172,7 @@ public function isValid()
*
* @throws FileException if, for any reason, the file could not have been moved
*/
public function move(string $directory, string $name = null)
public function move(string $directory, ?string $name = null)
{
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 @@ -67,7 +67,7 @@ public function __toString()
*
* @return array<string, array<int, string|null>>|array<int, string|null>
*/
public function all(string $key = null)
public function all(?string $key = null)
{
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)
*
* @return string|null
*/
public function get(string $key, string $default = null)
public function get(string $key, ?string $default = null)
{
$headers = $this->all($key);

Expand Down Expand Up @@ -197,7 +197,7 @@ public function remove(string $key)
*
* @throws \RuntimeException When the HTTP header is not parseable
*/
public function getDate(string $key, \DateTime $default = null)
public function getDate(string $key, ?\DateTime $default = null)
{
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 @@ -45,7 +45,7 @@ public function get(string $key, $default = null)
/**
* {@inheritdoc}
*/
public function all(string $key = null): array
public function all(?string $key = null): array
{
return parent::all($key);
}
Expand Down
2 changes: 1 addition & 1 deletion JsonResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,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)
public function setCallback(?string $callback = null)
{
if (null !== $callback) {
// partially taken from https://geekality.net/2011/08/03/valid-javascript-identifier/
Expand Down
6 changes: 3 additions & 3 deletions Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ public static function setFactory(?callable $callable)
*
* @return static
*/
public function duplicate(array $query = null, array $request = null, array $attributes = null, array $cookies = null, array $files = null, array $server = null)
public function duplicate(?array $query = null, ?array $request = null, ?array $attributes = null, ?array $cookies = null, ?array $files = null, ?array $server = null)
{
$dup = clone $this;
if (null !== $query) {
Expand Down Expand Up @@ -1651,7 +1651,7 @@ public function getPreferredFormat(?string $default = 'html'): ?string
*
* @return string|null
*/
public function getPreferredLanguage(array $locales = null)
public function getPreferredLanguage(?array $locales = null)
{
$preferredLanguages = $this->getLanguages();

Expand Down Expand Up @@ -2061,7 +2061,7 @@ public function isFromTrustedProxy()
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 @@ -58,7 +58,7 @@ class RequestMatcher implements RequestMatcherInterface
* @param string|string[]|null $ips
* @param string|string[]|null $schemes
*/
public function __construct(string $path = null, string $host = null, $methods = null, $ips = null, array $attributes = [], $schemes = null, int $port = null)
public function __construct(?string $path = null, ?string $host = null, $methods = null, $ips = null, array $attributes = [], $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 @@ -463,7 +463,7 @@ public function getProtocolVersion(): string
*
* @final
*/
public function setStatusCode(int $code, string $text = null): object
public function setStatusCode(int $code, ?string $text = null): object
{
$this->statusCode = $code;
if ($this->isInvalid()) {
Expand Down Expand Up @@ -737,7 +737,7 @@ public function getExpires(): ?\DateTimeInterface
*
* @final
*/
public function setExpires(\DateTimeInterface $date = null): object
public function setExpires(?\DateTimeInterface $date = null): object
{
if (null === $date) {
$this->headers->remove('Expires');
Expand Down Expand Up @@ -886,7 +886,7 @@ public function getLastModified(): ?\DateTimeInterface
*
* @final
*/
public function setLastModified(\DateTimeInterface $date = null): object
public function setLastModified(?\DateTimeInterface $date = null): object
{
if (null === $date) {
$this->headers->remove('Last-Modified');
Expand Down Expand Up @@ -924,7 +924,7 @@ public function getEtag(): ?string
*
* @final
*/
public function setEtag(string $etag = null, bool $weak = false): object
public function setEtag(?string $etag = null, bool $weak = false): object
{
if (null === $etag) {
$this->headers->remove('Etag');
Expand Down Expand Up @@ -1217,7 +1217,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 @@ -88,7 +88,7 @@ public function replace(array $headers = [])
/**
* {@inheritdoc}
*/
public function all(string $key = null)
public function all(?string $key = null)
{
$headers = parent::all();

Expand Down Expand Up @@ -186,7 +186,7 @@ public function setCookie(Cookie $cookie)
/**
* Removes a cookie from the array, but does not unset it in the browser.
*/
public function removeCookie(string $name, ?string $path = '/', string $domain = null)
public function removeCookie(string $name, ?string $path = '/', ?string $domain = null)
{
if (null === $path) {
$path = '/';
Expand Down Expand Up @@ -239,7 +239,7 @@ public function getCookies(string $format = self::COOKIES_FLAT)
/**
* Clears a cookie in the browser.
*/
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 @@ -39,7 +39,7 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable
private $usageIndex = 0;
private $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 = $usageReporter;
Expand Down Expand Up @@ -175,7 +175,7 @@ public function isEmpty(): bool
/**
* {@inheritdoc}
*/
public function invalidate(int $lifetime = null)
public function invalidate(?int $lifetime = null)
{
$this->storage->clear();

Expand All @@ -185,7 +185,7 @@ public function invalidate(int $lifetime = null)
/**
* {@inheritdoc}
*/
public function migrate(bool $destroy = false, int $lifetime = null)
public function migrate(bool $destroy = false, ?int $lifetime = null)
{
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 $storageFactory;
private $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 @@ -66,7 +66,7 @@ public function setName(string $name);
*
* @return bool
*/
public function invalidate(int $lifetime = null);
public function invalidate(?int $lifetime = null);

/**
* Migrates the current session to a new session id while maintaining all
Expand All @@ -80,7 +80,7 @@ public function invalidate(int $lifetime = null);
*
* @return bool
*/
public function migrate(bool $destroy = false, int $lifetime = null);
public function migrate(bool $destroy = false, ?int $lifetime = null);

/**
* 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)
{
if (null === $savePath) {
$savePath = \ini_get('session.save_path');
Expand Down
4 changes: 2 additions & 2 deletions Session/Storage/MetadataBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function getLifetime()
* to expire with browser session. Time is in seconds, and is
* not a Unix timestamp.
*/
public function stampNew(int $lifetime = null)
public function stampNew(?int $lifetime = null)
{
$this->stampCreated($lifetime);
}
Expand Down Expand Up @@ -158,7 +158,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 @@ -94,7 +94,7 @@ public function start()
/**
* {@inheritdoc}
*/
public function regenerate(bool $destroy = false, int $lifetime = null)
public function regenerate(bool $destroy = false, ?int $lifetime = null)
{
if (!$this->started) {
$this->start();
Expand Down Expand Up @@ -204,7 +204,7 @@ public function isStarted()
return $this->started;
}

public function setMetadataBag(MetadataBag $bag = null)
public function setMetadataBag(?MetadataBag $bag = null)
{
if (null === $bag) {
$bag = new MetadataBag();
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)
{
if (null === $savePath) {
$savePath = sys_get_temp_dir();
Expand Down Expand Up @@ -68,7 +68,7 @@ public function start()
/**
* {@inheritdoc}
*/
public function regenerate(bool $destroy = false, int $lifetime = null)
public function regenerate(bool $destroy = false, ?int $lifetime = null)
{
if (!$this->started) {
$this->start();
Expand Down
2 changes: 1 addition & 1 deletion Session/Storage/MockFileSessionStorageFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class MockFileSessionStorageFactory implements SessionStorageFactoryInterface
/**
* @see MockFileSessionStorage constructor.
*/
public function __construct(string $savePath = null, string $name = 'MOCKSESSID', MetadataBag $metaBag = null)
public function __construct(?string $savePath = null, string $name = 'MOCKSESSID', ?MetadataBag $metaBag = null)
{
$this->savePath = $savePath;
$this->name = $name;
Expand Down
Loading

0 comments on commit f2ab692

Please sign in to comment.