From 2f6f979b579ed1c051465c3c2fb81daf5bb4a002 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 23 Jan 2024 14:51:25 +0100 Subject: [PATCH] Apply php-cs-fixer fix --rules nullable_type_declaration_for_default_null_value --- AbstractBrowser.php | 6 +++--- Cookie.php | 4 ++-- CookieJar.php | 8 ++++---- HttpBrowser.php | 2 +- Request.php | 2 +- Test/Constraint/BrowserCookieValueSame.php | 2 +- Test/Constraint/BrowserHasCookie.php | 2 +- Tests/AbstractBrowserTest.php | 2 +- Tests/HttpBrowserTest.php | 2 +- Tests/TestHttpClient.php | 2 +- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/AbstractBrowser.php b/AbstractBrowser.php index 56792e70..785a2162 100644 --- a/AbstractBrowser.php +++ b/AbstractBrowser.php @@ -50,7 +50,7 @@ abstract class AbstractBrowser /** * @param array $server The server parameters (equivalent of $_SERVER) */ - public function __construct(array $server = [], History $history = null, CookieJar $cookieJar = null) + public function __construct(array $server = [], ?History $history = null, ?CookieJar $cookieJar = null) { $this->setServerParameters($server); $this->history = $history ?? new History(); @@ -146,7 +146,7 @@ public function getServerParameter(string $key, $default = '') return $this->server[$key] ?? $default; } - public function xmlHttpRequest(string $method, string $uri, array $parameters = [], array $files = [], array $server = [], string $content = null, bool $changeHistory = true): Crawler + public function xmlHttpRequest(string $method, string $uri, array $parameters = [], array $files = [], array $server = [], ?string $content = null, bool $changeHistory = true): Crawler { $this->setServerParameter('HTTP_X_REQUESTED_WITH', 'XMLHttpRequest'); @@ -352,7 +352,7 @@ public function submitForm(string $button, array $fieldValues = [], string $meth * * @return Crawler */ - public function request(string $method, string $uri, array $parameters = [], array $files = [], array $server = [], string $content = null, bool $changeHistory = true) + public function request(string $method, string $uri, array $parameters = [], array $files = [], array $server = [], ?string $content = null, bool $changeHistory = true) { if ($this->isMainRequest) { $this->redirectCount = 0; diff --git a/Cookie.php b/Cookie.php index d4be1319..bbec9477 100644 --- a/Cookie.php +++ b/Cookie.php @@ -55,7 +55,7 @@ class Cookie * @param bool $encodedValue Whether the value is encoded or not * @param string|null $samesite The cookie samesite attribute */ - public function __construct(string $name, ?string $value, string $expires = null, string $path = null, string $domain = '', bool $secure = false, bool $httponly = true, bool $encodedValue = false, string $samesite = null) + public function __construct(string $name, ?string $value, ?string $expires = null, ?string $path = null, string $domain = '', bool $secure = false, bool $httponly = true, bool $encodedValue = false, ?string $samesite = null) { if ($encodedValue) { $this->value = urldecode($value); @@ -125,7 +125,7 @@ public function __toString() * * @throws \InvalidArgumentException */ - public static function fromString(string $cookie, string $url = null) + public static function fromString(string $cookie, ?string $url = null) { $parts = explode(';', $cookie); diff --git a/CookieJar.php b/CookieJar.php index 2185cd2f..ced98785 100644 --- a/CookieJar.php +++ b/CookieJar.php @@ -35,7 +35,7 @@ public function set(Cookie $cookie) * * @return Cookie|null */ - public function get(string $name, string $path = '/', string $domain = null) + public function get(string $name, string $path = '/', ?string $domain = null) { $this->flushExpiredCookies(); @@ -67,7 +67,7 @@ public function get(string $name, string $path = '/', string $domain = null) * all cookies for the given name/path expire (this behavior * ensures a BC behavior with previous versions of Symfony). */ - public function expire(string $name, ?string $path = '/', string $domain = null) + public function expire(string $name, ?string $path = '/', ?string $domain = null) { if (null === $path) { $path = '/'; @@ -107,7 +107,7 @@ public function clear() * * @param string[] $setCookies Set-Cookie headers from an HTTP response */ - public function updateFromSetCookie(array $setCookies, string $uri = null) + public function updateFromSetCookie(array $setCookies, ?string $uri = null) { $cookies = []; @@ -133,7 +133,7 @@ public function updateFromSetCookie(array $setCookies, string $uri = null) /** * Updates the cookie jar from a Response object. */ - public function updateFromResponse(Response $response, string $uri = null) + public function updateFromResponse(Response $response, ?string $uri = null) { $this->updateFromSetCookie($response->getHeader('Set-Cookie', false), $uri); } diff --git a/HttpBrowser.php b/HttpBrowser.php index d4606057..c1a0fdcb 100644 --- a/HttpBrowser.php +++ b/HttpBrowser.php @@ -28,7 +28,7 @@ class HttpBrowser extends AbstractBrowser { private $client; - public function __construct(HttpClientInterface $client = null, History $history = null, CookieJar $cookieJar = null) + public function __construct(?HttpClientInterface $client = null, ?History $history = null, ?CookieJar $cookieJar = null) { if (!$client && !class_exists(HttpClient::class)) { throw new \LogicException(sprintf('You cannot use "%s" as the HttpClient component is not installed. Try running "composer require symfony/http-client".', __CLASS__)); diff --git a/Request.php b/Request.php index a8a4f501..9ab1afd9 100644 --- a/Request.php +++ b/Request.php @@ -33,7 +33,7 @@ class Request * @param array $server An array of server parameters * @param string $content The raw body data */ - public function __construct(string $uri, string $method, array $parameters = [], array $files = [], array $cookies = [], array $server = [], string $content = null) + public function __construct(string $uri, string $method, array $parameters = [], array $files = [], array $cookies = [], array $server = [], ?string $content = null) { $this->uri = $uri; $this->method = $method; diff --git a/Test/Constraint/BrowserCookieValueSame.php b/Test/Constraint/BrowserCookieValueSame.php index f3103242..d69d0f65 100644 --- a/Test/Constraint/BrowserCookieValueSame.php +++ b/Test/Constraint/BrowserCookieValueSame.php @@ -22,7 +22,7 @@ final class BrowserCookieValueSame extends Constraint private $path; private $domain; - public function __construct(string $name, string $value, bool $raw = false, string $path = '/', string $domain = null) + public function __construct(string $name, string $value, bool $raw = false, string $path = '/', ?string $domain = null) { $this->name = $name; $this->path = $path; diff --git a/Test/Constraint/BrowserHasCookie.php b/Test/Constraint/BrowserHasCookie.php index 2b84a5e9..e95a54c1 100644 --- a/Test/Constraint/BrowserHasCookie.php +++ b/Test/Constraint/BrowserHasCookie.php @@ -20,7 +20,7 @@ final class BrowserHasCookie extends Constraint private $path; private $domain; - public function __construct(string $name, string $path = '/', string $domain = null) + public function __construct(string $name, string $path = '/', ?string $domain = null) { $this->name = $name; $this->path = $path; diff --git a/Tests/AbstractBrowserTest.php b/Tests/AbstractBrowserTest.php index c732238a..1f0bb530 100644 --- a/Tests/AbstractBrowserTest.php +++ b/Tests/AbstractBrowserTest.php @@ -20,7 +20,7 @@ class AbstractBrowserTest extends TestCase { - public function getBrowser(array $server = [], History $history = null, CookieJar $cookieJar = null) + public function getBrowser(array $server = [], ?History $history = null, ?CookieJar $cookieJar = null) { return new TestClient($server, $history, $cookieJar); } diff --git a/Tests/HttpBrowserTest.php b/Tests/HttpBrowserTest.php index 44f61289..e1f19b16 100644 --- a/Tests/HttpBrowserTest.php +++ b/Tests/HttpBrowserTest.php @@ -19,7 +19,7 @@ class HttpBrowserTest extends AbstractBrowserTest { - public function getBrowser(array $server = [], History $history = null, CookieJar $cookieJar = null) + public function getBrowser(array $server = [], ?History $history = null, ?CookieJar $cookieJar = null) { return new TestHttpClient($server, $history, $cookieJar); } diff --git a/Tests/TestHttpClient.php b/Tests/TestHttpClient.php index 184418b7..6e8b5235 100644 --- a/Tests/TestHttpClient.php +++ b/Tests/TestHttpClient.php @@ -23,7 +23,7 @@ class TestHttpClient extends HttpBrowser protected $nextResponse = null; protected $nextScript = null; - public function __construct(array $server = [], History $history = null, CookieJar $cookieJar = null) + public function __construct(array $server = [], ?History $history = null, ?CookieJar $cookieJar = null) { $client = new MockHttpClient(function (string $method, string $url, array $options) { if (null === $this->nextResponse) {