From e3b4806f88abf106a411847a78619a542e71de29 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 --- AbstractUriElement.php | 2 +- Crawler.php | 14 +++++++------- Form.php | 2 +- Image.php | 2 +- Tests/AbstractCrawlerTestCase.php | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/AbstractUriElement.php b/AbstractUriElement.php index 8ff0b992..f4b0e066 100644 --- a/AbstractUriElement.php +++ b/AbstractUriElement.php @@ -40,7 +40,7 @@ abstract class AbstractUriElement * * @throws \InvalidArgumentException if the node is not a link */ - public function __construct(\DOMElement $node, string $currentUri = null, ?string $method = 'GET') + public function __construct(\DOMElement $node, ?string $currentUri = null, ?string $method = 'GET') { $this->setNode($node); $this->method = $method ? strtoupper($method) : null; diff --git a/Crawler.php b/Crawler.php index 08baced5..a6c214ad 100644 --- a/Crawler.php +++ b/Crawler.php @@ -81,7 +81,7 @@ class Crawler implements \Countable, \IteratorAggregate /** * @param \DOMNodeList|\DOMNode|\DOMNode[]|string|null $node A Node to use as the base for the crawling */ - public function __construct($node = null, string $uri = null, string $baseHref = null) + public function __construct($node = null, ?string $uri = null, ?string $baseHref = null) { $this->uri = $uri; $this->baseHref = $baseHref ?: $uri; @@ -153,7 +153,7 @@ public function add($node) * or ISO-8859-1 as a fallback, which is the default charset defined by the * HTTP 1.1 specification. */ - public function addContent(string $content, string $type = null) + public function addContent(string $content, ?string $type = null) { if (empty($type)) { $type = str_starts_with($content, 'createSubCrawler(\array_slice($this->nodes, $offset, $length)); } @@ -546,7 +546,7 @@ public function ancestors() * @throws \InvalidArgumentException When current node is empty * @throws \RuntimeException If the CssSelector Component is not available and $selector is provided */ - public function children(string $selector = null) + public function children(?string $selector = null) { if (!$this->nodes) { throw new \InvalidArgumentException('The current node list is empty.'); @@ -610,7 +610,7 @@ public function nodeName() * * @throws \InvalidArgumentException When current node is empty */ - public function text(string $default = null, bool $normalizeWhitespace = true) + public function text(?string $default = null, bool $normalizeWhitespace = true) { if (!$this->nodes) { if (null !== $default) { @@ -646,7 +646,7 @@ public function innerText(): string * * @throws \InvalidArgumentException When current node is empty */ - public function html(string $default = null) + public function html(?string $default = null) { if (!$this->nodes) { if (null !== $default) { @@ -915,7 +915,7 @@ public function images() * * @throws \InvalidArgumentException If the current node list is empty or the selected node is not instance of DOMElement */ - public function form(array $values = null, string $method = null) + public function form(?array $values = null, ?string $method = null) { if (!$this->nodes) { throw new \InvalidArgumentException('The current node list is empty.'); diff --git a/Form.php b/Form.php index ebad35b3..3b03b586 100644 --- a/Form.php +++ b/Form.php @@ -44,7 +44,7 @@ class Form extends Link implements \ArrayAccess * * @throws \LogicException if the node is not a button inside a form tag */ - public function __construct(\DOMElement $node, string $currentUri = null, string $method = null, string $baseHref = null) + public function __construct(\DOMElement $node, ?string $currentUri = null, ?string $method = null, ?string $baseHref = null) { parent::__construct($node, $currentUri, $method); $this->baseHref = $baseHref; diff --git a/Image.php b/Image.php index b1ac5ca2..fb3a5793 100644 --- a/Image.php +++ b/Image.php @@ -16,7 +16,7 @@ */ class Image extends AbstractUriElement { - public function __construct(\DOMElement $node, string $currentUri = null) + public function __construct(\DOMElement $node, ?string $currentUri = null) { parent::__construct($node, $currentUri, 'GET'); } diff --git a/Tests/AbstractCrawlerTestCase.php b/Tests/AbstractCrawlerTestCase.php index 55178ca0..831c2f06 100644 --- a/Tests/AbstractCrawlerTestCase.php +++ b/Tests/AbstractCrawlerTestCase.php @@ -24,7 +24,7 @@ abstract class AbstractCrawlerTestCase extends TestCase abstract public static function getDoctype(): string; - protected function createCrawler($node = null, string $uri = null, string $baseHref = null) + protected function createCrawler($node = null, ?string $uri = null, ?string $baseHref = null) { return new Crawler($node, $uri, $baseHref); }