Skip to content

Commit f2ab692

Browse files
Apply php-cs-fixer fix --rules nullable_type_declaration_for_default_null_value
1 parent 528f59f commit f2ab692

30 files changed

+55
-55
lines changed

BinaryFileResponse.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class BinaryFileResponse extends Response
4545
* @param bool $autoEtag Whether the ETag header should be automatically set
4646
* @param bool $autoLastModified Whether the Last-Modified header should be automatically set
4747
*/
48-
public function __construct($file, int $status = 200, array $headers = [], bool $public = true, string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true)
48+
public function __construct($file, int $status = 200, array $headers = [], bool $public = true, ?string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true)
4949
{
5050
parent::__construct(null, $status, $headers);
5151

@@ -69,7 +69,7 @@ public function __construct($file, int $status = 200, array $headers = [], bool
6969
*
7070
* @deprecated since Symfony 5.2, use __construct() instead.
7171
*/
72-
public static function create($file = null, int $status = 200, array $headers = [], bool $public = true, string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true)
72+
public static function create($file = null, int $status = 200, array $headers = [], bool $public = true, ?string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true)
7373
{
7474
trigger_deprecation('symfony/http-foundation', '5.2', 'The "%s()" method is deprecated, use "new %s()" instead.', __METHOD__, static::class);
7575

@@ -85,7 +85,7 @@ public static function create($file = null, int $status = 200, array $headers =
8585
*
8686
* @throws FileException
8787
*/
88-
public function setFile($file, string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true)
88+
public function setFile($file, ?string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true)
8989
{
9090
if (!$file instanceof File) {
9191
if ($file instanceof \SplFileInfo) {

Cookie.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public static function fromString(string $cookie, bool $decode = false)
7171
return new static($name, $value, $data['expires'], $data['path'], $data['domain'], $data['secure'], $data['httponly'], $data['raw'], $data['samesite']);
7272
}
7373

74-
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
74+
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
7575
{
7676
return new self($name, $value, $expire, $path, $domain, $secure, $httpOnly, $raw, $sameSite);
7777
}
@@ -89,7 +89,7 @@ public static function create(string $name, string $value = null, $expire = 0, ?
8989
*
9090
* @throws \InvalidArgumentException
9191
*/
92-
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')
92+
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')
9393
{
9494
// from PHP source code
9595
if ($raw && false !== strpbrk($name, self::RESERVED_CHARS_LIST)) {

Exception/SessionNotFoundException.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
class SessionNotFoundException extends \LogicException implements RequestExceptionInterface
2222
{
23-
public function __construct(string $message = 'There is currently no session available.', int $code = 0, \Throwable $previous = null)
23+
public function __construct(string $message = 'There is currently no session available.', int $code = 0, ?\Throwable $previous = null)
2424
{
2525
parent::__construct($message, $code, $previous);
2626
}

File/File.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function getMimeType()
8888
*
8989
* @throws FileException if the target file could not be created
9090
*/
91-
public function move(string $directory, string $name = null)
91+
public function move(string $directory, ?string $name = null)
9292
{
9393
$target = $this->getTargetFile($directory, $name);
9494

@@ -121,7 +121,7 @@ public function getContent(): string
121121
/**
122122
* @return self
123123
*/
124-
protected function getTargetFile(string $directory, string $name = null)
124+
protected function getTargetFile(string $directory, ?string $name = null)
125125
{
126126
if (!is_dir($directory)) {
127127
if (false === @mkdir($directory, 0777, true) && !is_dir($directory)) {

File/UploadedFile.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class UploadedFile extends File
6060
* @throws FileException If file_uploads is disabled
6161
* @throws FileNotFoundException If the file does not exist
6262
*/
63-
public function __construct(string $path, string $originalName, string $mimeType = null, int $error = null, bool $test = false)
63+
public function __construct(string $path, string $originalName, ?string $mimeType = null, ?int $error = null, bool $test = false)
6464
{
6565
$this->originalName = $this->getName($originalName);
6666
$this->mimeType = $mimeType ?: 'application/octet-stream';
@@ -172,7 +172,7 @@ public function isValid()
172172
*
173173
* @throws FileException if, for any reason, the file could not have been moved
174174
*/
175-
public function move(string $directory, string $name = null)
175+
public function move(string $directory, ?string $name = null)
176176
{
177177
if ($this->isValid()) {
178178
if ($this->test) {

HeaderBag.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function __toString()
6767
*
6868
* @return array<string, array<int, string|null>>|array<int, string|null>
6969
*/
70-
public function all(string $key = null)
70+
public function all(?string $key = null)
7171
{
7272
if (null !== $key) {
7373
return $this->headers[strtr($key, self::UPPER, self::LOWER)] ?? [];
@@ -110,7 +110,7 @@ public function add(array $headers)
110110
*
111111
* @return string|null
112112
*/
113-
public function get(string $key, string $default = null)
113+
public function get(string $key, ?string $default = null)
114114
{
115115
$headers = $this->all($key);
116116

@@ -197,7 +197,7 @@ public function remove(string $key)
197197
*
198198
* @throws \RuntimeException When the HTTP header is not parseable
199199
*/
200-
public function getDate(string $key, \DateTime $default = null)
200+
public function getDate(string $key, ?\DateTime $default = null)
201201
{
202202
if (null === $value = $this->get($key)) {
203203
return $default;

InputBag.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function get(string $key, $default = null)
4545
/**
4646
* {@inheritdoc}
4747
*/
48-
public function all(string $key = null): array
48+
public function all(?string $key = null): array
4949
{
5050
return parent::all($key);
5151
}

JsonResponse.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public static function fromJsonString(string $data, int $status = 200, array $he
105105
*
106106
* @throws \InvalidArgumentException When the callback name is not valid
107107
*/
108-
public function setCallback(string $callback = null)
108+
public function setCallback(?string $callback = null)
109109
{
110110
if (null !== $callback) {
111111
// partially taken from https://geekality.net/2011/08/03/valid-javascript-identifier/

Request.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ public static function setFactory(?callable $callable)
451451
*
452452
* @return static
453453
*/
454-
public function duplicate(array $query = null, array $request = null, array $attributes = null, array $cookies = null, array $files = null, array $server = null)
454+
public function duplicate(?array $query = null, ?array $request = null, ?array $attributes = null, ?array $cookies = null, ?array $files = null, ?array $server = null)
455455
{
456456
$dup = clone $this;
457457
if (null !== $query) {
@@ -1651,7 +1651,7 @@ public function getPreferredFormat(?string $default = 'html'): ?string
16511651
*
16521652
* @return string|null
16531653
*/
1654-
public function getPreferredLanguage(array $locales = null)
1654+
public function getPreferredLanguage(?array $locales = null)
16551655
{
16561656
$preferredLanguages = $this->getLanguages();
16571657

@@ -2061,7 +2061,7 @@ public function isFromTrustedProxy()
20612061
return self::$trustedProxies && IpUtils::checkIp($this->server->get('REMOTE_ADDR', ''), self::$trustedProxies);
20622062
}
20632063

2064-
private function getTrustedValues(int $type, string $ip = null): array
2064+
private function getTrustedValues(int $type, ?string $ip = null): array
20652065
{
20662066
$clientValues = [];
20672067
$forwardedValues = [];

RequestMatcher.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class RequestMatcher implements RequestMatcherInterface
5858
* @param string|string[]|null $ips
5959
* @param string|string[]|null $schemes
6060
*/
61-
public function __construct(string $path = null, string $host = null, $methods = null, $ips = null, array $attributes = [], $schemes = null, int $port = null)
61+
public function __construct(?string $path = null, ?string $host = null, $methods = null, $ips = null, array $attributes = [], $schemes = null, ?int $port = null)
6262
{
6363
$this->matchPath($path);
6464
$this->matchHost($host);

Response.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ public function getProtocolVersion(): string
463463
*
464464
* @final
465465
*/
466-
public function setStatusCode(int $code, string $text = null): object
466+
public function setStatusCode(int $code, ?string $text = null): object
467467
{
468468
$this->statusCode = $code;
469469
if ($this->isInvalid()) {
@@ -737,7 +737,7 @@ public function getExpires(): ?\DateTimeInterface
737737
*
738738
* @final
739739
*/
740-
public function setExpires(\DateTimeInterface $date = null): object
740+
public function setExpires(?\DateTimeInterface $date = null): object
741741
{
742742
if (null === $date) {
743743
$this->headers->remove('Expires');
@@ -886,7 +886,7 @@ public function getLastModified(): ?\DateTimeInterface
886886
*
887887
* @final
888888
*/
889-
public function setLastModified(\DateTimeInterface $date = null): object
889+
public function setLastModified(?\DateTimeInterface $date = null): object
890890
{
891891
if (null === $date) {
892892
$this->headers->remove('Last-Modified');
@@ -924,7 +924,7 @@ public function getEtag(): ?string
924924
*
925925
* @final
926926
*/
927-
public function setEtag(string $etag = null, bool $weak = false): object
927+
public function setEtag(?string $etag = null, bool $weak = false): object
928928
{
929929
if (null === $etag) {
930930
$this->headers->remove('Etag');
@@ -1217,7 +1217,7 @@ public function isNotFound(): bool
12171217
*
12181218
* @final
12191219
*/
1220-
public function isRedirect(string $location = null): bool
1220+
public function isRedirect(?string $location = null): bool
12211221
{
12221222
return \in_array($this->statusCode, [201, 301, 302, 303, 307, 308]) && (null === $location ?: $location == $this->headers->get('Location'));
12231223
}

ResponseHeaderBag.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function replace(array $headers = [])
8888
/**
8989
* {@inheritdoc}
9090
*/
91-
public function all(string $key = null)
91+
public function all(?string $key = null)
9292
{
9393
$headers = parent::all();
9494

@@ -186,7 +186,7 @@ public function setCookie(Cookie $cookie)
186186
/**
187187
* Removes a cookie from the array, but does not unset it in the browser.
188188
*/
189-
public function removeCookie(string $name, ?string $path = '/', string $domain = null)
189+
public function removeCookie(string $name, ?string $path = '/', ?string $domain = null)
190190
{
191191
if (null === $path) {
192192
$path = '/';
@@ -239,7 +239,7 @@ public function getCookies(string $format = self::COOKIES_FLAT)
239239
/**
240240
* Clears a cookie in the browser.
241241
*/
242-
public function clearCookie(string $name, ?string $path = '/', string $domain = null, bool $secure = false, bool $httpOnly = true, string $sameSite = null)
242+
public function clearCookie(string $name, ?string $path = '/', ?string $domain = null, bool $secure = false, bool $httpOnly = true, ?string $sameSite = null)
243243
{
244244
$this->setCookie(new Cookie($name, null, 1, $path, $domain, $secure, $httpOnly, false, $sameSite));
245245
}

Session/Session.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable
3939
private $usageIndex = 0;
4040
private $usageReporter;
4141

42-
public function __construct(SessionStorageInterface $storage = null, AttributeBagInterface $attributes = null, FlashBagInterface $flashes = null, callable $usageReporter = null)
42+
public function __construct(?SessionStorageInterface $storage = null, ?AttributeBagInterface $attributes = null, ?FlashBagInterface $flashes = null, ?callable $usageReporter = null)
4343
{
4444
$this->storage = $storage ?? new NativeSessionStorage();
4545
$this->usageReporter = $usageReporter;
@@ -175,7 +175,7 @@ public function isEmpty(): bool
175175
/**
176176
* {@inheritdoc}
177177
*/
178-
public function invalidate(int $lifetime = null)
178+
public function invalidate(?int $lifetime = null)
179179
{
180180
$this->storage->clear();
181181

@@ -185,7 +185,7 @@ public function invalidate(int $lifetime = null)
185185
/**
186186
* {@inheritdoc}
187187
*/
188-
public function migrate(bool $destroy = false, int $lifetime = null)
188+
public function migrate(bool $destroy = false, ?int $lifetime = null)
189189
{
190190
return $this->storage->regenerate($destroy, $lifetime);
191191
}

Session/SessionFactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class SessionFactory implements SessionFactoryInterface
2626
private $storageFactory;
2727
private $usageReporter;
2828

29-
public function __construct(RequestStack $requestStack, SessionStorageFactoryInterface $storageFactory, callable $usageReporter = null)
29+
public function __construct(RequestStack $requestStack, SessionStorageFactoryInterface $storageFactory, ?callable $usageReporter = null)
3030
{
3131
$this->requestStack = $requestStack;
3232
$this->storageFactory = $storageFactory;

Session/SessionInterface.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function setName(string $name);
6666
*
6767
* @return bool
6868
*/
69-
public function invalidate(int $lifetime = null);
69+
public function invalidate(?int $lifetime = null);
7070

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

8585
/**
8686
* Force the session to be saved and closed.

Session/Storage/Handler/NativeFileSessionHandler.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class NativeFileSessionHandler extends \SessionHandler
2828
* @throws \InvalidArgumentException On invalid $savePath
2929
* @throws \RuntimeException When failing to create the save directory
3030
*/
31-
public function __construct(string $savePath = null)
31+
public function __construct(?string $savePath = null)
3232
{
3333
if (null === $savePath) {
3434
$savePath = \ini_get('session.save_path');

Session/Storage/MetadataBag.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function getLifetime()
100100
* to expire with browser session. Time is in seconds, and is
101101
* not a Unix timestamp.
102102
*/
103-
public function stampNew(int $lifetime = null)
103+
public function stampNew(?int $lifetime = null)
104104
{
105105
$this->stampCreated($lifetime);
106106
}
@@ -158,7 +158,7 @@ public function setName(string $name)
158158
$this->name = $name;
159159
}
160160

161-
private function stampCreated(int $lifetime = null): void
161+
private function stampCreated(?int $lifetime = null): void
162162
{
163163
$timeStamp = time();
164164
$this->meta[self::CREATED] = $this->meta[self::UPDATED] = $this->lastUsed = $timeStamp;

Session/Storage/MockArraySessionStorage.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class MockArraySessionStorage implements SessionStorageInterface
6262
*/
6363
protected $bags = [];
6464

65-
public function __construct(string $name = 'MOCKSESSID', MetadataBag $metaBag = null)
65+
public function __construct(string $name = 'MOCKSESSID', ?MetadataBag $metaBag = null)
6666
{
6767
$this->name = $name;
6868
$this->setMetadataBag($metaBag);
@@ -94,7 +94,7 @@ public function start()
9494
/**
9595
* {@inheritdoc}
9696
*/
97-
public function regenerate(bool $destroy = false, int $lifetime = null)
97+
public function regenerate(bool $destroy = false, ?int $lifetime = null)
9898
{
9999
if (!$this->started) {
100100
$this->start();
@@ -204,7 +204,7 @@ public function isStarted()
204204
return $this->started;
205205
}
206206

207-
public function setMetadataBag(MetadataBag $bag = null)
207+
public function setMetadataBag(?MetadataBag $bag = null)
208208
{
209209
if (null === $bag) {
210210
$bag = new MetadataBag();

Session/Storage/MockFileSessionStorage.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class MockFileSessionStorage extends MockArraySessionStorage
3030
/**
3131
* @param string|null $savePath Path of directory to save session files
3232
*/
33-
public function __construct(string $savePath = null, string $name = 'MOCKSESSID', MetadataBag $metaBag = null)
33+
public function __construct(?string $savePath = null, string $name = 'MOCKSESSID', ?MetadataBag $metaBag = null)
3434
{
3535
if (null === $savePath) {
3636
$savePath = sys_get_temp_dir();
@@ -68,7 +68,7 @@ public function start()
6868
/**
6969
* {@inheritdoc}
7070
*/
71-
public function regenerate(bool $destroy = false, int $lifetime = null)
71+
public function regenerate(bool $destroy = false, ?int $lifetime = null)
7272
{
7373
if (!$this->started) {
7474
$this->start();

Session/Storage/MockFileSessionStorageFactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class MockFileSessionStorageFactory implements SessionStorageFactoryInterface
2828
/**
2929
* @see MockFileSessionStorage constructor.
3030
*/
31-
public function __construct(string $savePath = null, string $name = 'MOCKSESSID', MetadataBag $metaBag = null)
31+
public function __construct(?string $savePath = null, string $name = 'MOCKSESSID', ?MetadataBag $metaBag = null)
3232
{
3333
$this->savePath = $savePath;
3434
$this->name = $name;

0 commit comments

Comments
 (0)