diff --git a/AbstractUriElement.php b/AbstractUriElement.php index 9a3712b..d75dcd2 100644 --- a/AbstractUriElement.php +++ b/AbstractUriElement.php @@ -29,7 +29,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 315e225..85d9c1e 100644 --- a/Crawler.php +++ b/Crawler.php @@ -60,7 +60,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(\DOMNodeList|\DOMNode|array|string $node = null, string $uri = null, string $baseHref = null, bool $useHtml5Parser = true) + public function __construct(\DOMNodeList|\DOMNode|array|string|null $node = null, ?string $uri = null, ?string $baseHref = null, bool $useHtml5Parser = true) { $this->uri = $uri; $this->baseHref = $baseHref ?: $uri; @@ -128,7 +128,7 @@ public function add(\DOMNodeList|\DOMNode|array|string|null $node): void * 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): void + public function addContent(string $content, ?string $type = null): void { if (empty($type)) { $type = str_starts_with($content, 'createSubCrawler(\array_slice($this->nodes, $offset, $length)); } @@ -479,7 +479,7 @@ public function ancestors(): static * @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): static + public function children(?string $selector = null): static { if (!$this->nodes) { throw new \InvalidArgumentException('The current node list is empty.'); @@ -504,7 +504,7 @@ public function children(string $selector = null): static * * @throws \InvalidArgumentException When current node is empty */ - public function attr(string $attribute, string $default = null): ?string + public function attr(string $attribute, ?string $default = null): ?string { if (!$this->nodes) { if (null !== $default) { @@ -543,7 +543,7 @@ public function nodeName(): string * * @throws \InvalidArgumentException When current node is empty */ - public function text(string $default = null, bool $normalizeWhitespace = true): string + public function text(?string $default = null, bool $normalizeWhitespace = true): string { if (!$this->nodes) { if (null !== $default) { @@ -591,7 +591,7 @@ public function innerText(bool $normalizeWhitespace = true): string * * @throws \InvalidArgumentException When current node is empty */ - public function html(string $default = null): string + public function html(?string $default = null): string { if (!$this->nodes) { if (null !== $default) { @@ -840,7 +840,7 @@ public function images(): array * * @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): Form + public function form(?array $values = null, ?string $method = null): Form { if (!$this->nodes) { throw new \InvalidArgumentException('The current node list is empty.'); diff --git a/Form.php b/Form.php index 1747bf9..fc2849e 100644 --- a/Form.php +++ b/Form.php @@ -33,7 +33,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 5573928..dc7c0b4 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 2169a49..90c97e7 100644 --- a/Tests/AbstractCrawlerTestCase.php +++ b/Tests/AbstractCrawlerTestCase.php @@ -21,7 +21,7 @@ abstract class AbstractCrawlerTestCase extends TestCase { abstract public static function getDoctype(): string; - protected function createCrawler($node = null, string $uri = null, string $baseHref = null, bool $useHtml5Parser = true) + protected function createCrawler($node = null, ?string $uri = null, ?string $baseHref = null, bool $useHtml5Parser = true) { return new Crawler($node, $uri, $baseHref, $useHtml5Parser); }