Skip to content

Commit e969571

Browse files
authored
Merge pull request #551 from emteknetnz/php84-implicit-nullable
Make nullable parameters explicity nullable for PHP 8.4
2 parents a63e149 + e1dcf77 commit e969571

8 files changed

+14
-14
lines changed

src/Document.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ private static function buildQuery(string $startQuery, array $attributes): strin
107107
/**
108108
* Select a element in the dom
109109
*/
110-
public function select(string $query, array $attributes = null, DOMNode $context = null): QueryResult
110+
public function select(string $query, ?array $attributes = null, ?DOMNode $context = null): QueryResult
111111
{
112112
if (!empty($attributes)) {
113113
$query = self::buildQuery($query, $attributes);
@@ -119,7 +119,7 @@ public function select(string $query, array $attributes = null, DOMNode $context
119119
/**
120120
* Select a element in the dom using a css selector
121121
*/
122-
public function selectCss(string $query, DOMNode $context = null): QueryResult
122+
public function selectCss(string $query, ?DOMNode $context = null): QueryResult
123123
{
124124
return $this->select(self::cssToXpath($query), null, $context);
125125
}

src/Embed.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Embed
1212
private Crawler $crawler;
1313
private ExtractorFactory $extractorFactory;
1414

15-
public function __construct(Crawler $crawler = null, ExtractorFactory $extractorFactory = null)
15+
public function __construct(?Crawler $crawler = null, ?ExtractorFactory $extractorFactory = null)
1616
{
1717
$this->crawler = $crawler ?: new Crawler();
1818
$this->extractorFactory = $extractorFactory ?: new ExtractorFactory();

src/EmbedCode.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class EmbedCode implements JsonSerializable
1313
public ?int $height;
1414
public ?float $ratio = null;
1515

16-
public function __construct(string $html, int $width = null, int $height = null)
16+
public function __construct(string $html, ?int $width = null, ?int $height = null)
1717
{
1818
$this->html = $html;
1919
$this->width = $width;

src/Http/Crawler.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Crawler implements ClientInterface, RequestFactoryInterface, UriFactoryInt
2020
'Cache-Control' => 'max-age=0',
2121
];
2222

23-
public function __construct(ClientInterface $client = null, RequestFactoryInterface $requestFactory = null, UriFactoryInterface $uriFactory = null)
23+
public function __construct(?ClientInterface $client = null, ?RequestFactoryInterface $requestFactory = null, ?UriFactoryInterface $uriFactory = null)
2424
{
2525
$this->client = $client ?: new CurlClient();
2626
$this->requestFactory = $requestFactory ?: FactoryDiscovery::getRequestFactory();

src/Http/CurlClient.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ final class CurlClient implements ClientInterface
1616
private ResponseFactoryInterface $responseFactory;
1717
private array $settings = [];
1818

19-
public function __construct(ResponseFactoryInterface $responseFactory = null)
19+
public function __construct(?ResponseFactoryInterface $responseFactory = null)
2020
{
2121
$this->responseFactory = $responseFactory ?: FactoryDiscovery::getResponseFactory();
2222
}

src/Http/CurlDispatcher.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public static function fetch(array $settings, ResponseFactoryInterface $response
8383
);
8484
}
8585

86-
private function __construct(array $settings, RequestInterface $request, StreamFactoryInterface $streamFactory = null)
86+
private function __construct(array $settings, RequestInterface $request, ?StreamFactoryInterface $streamFactory = null)
8787
{
8888
$this->request = $request;
8989
$this->curl = curl_init((string) $request->getUri());

src/LinkedData.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function getAll()
5151
return $this->allData;
5252
}
5353

54-
private function getGraph(string $name = null): ?GraphInterface
54+
private function getGraph(?string $name = null): ?GraphInterface
5555
{
5656
if (!isset($this->document)) {
5757
try {

src/QueryResult.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function filter(Closure $callback): self
3737
return $this;
3838
}
3939

40-
public function get(string $attribute = null)
40+
public function get(?string $attribute = null)
4141
{
4242
$node = $this->node();
4343

@@ -48,7 +48,7 @@ public function get(string $attribute = null)
4848
return $attribute ? self::getAttribute($node, $attribute) : $node->nodeValue;
4949
}
5050

51-
public function getAll(string $attribute = null): array
51+
public function getAll(?string $attribute = null): array
5252
{
5353
$nodes = $this->nodes();
5454

@@ -60,26 +60,26 @@ public function getAll(string $attribute = null): array
6060
);
6161
}
6262

63-
public function str(string $attribute = null): ?string
63+
public function str(?string $attribute = null): ?string
6464
{
6565
$value = $this->get($attribute);
6666

6767
return $value ? clean($value) : null;
6868
}
6969

70-
public function strAll(string $attribute = null): array
70+
public function strAll(?string $attribute = null): array
7171
{
7272
return array_filter(array_map(fn ($value) => clean($value), $this->getAll($attribute)));
7373
}
7474

75-
public function int(string $attribute = null): ?int
75+
public function int(?string $attribute = null): ?int
7676
{
7777
$value = $this->get($attribute);
7878

7979
return $value ? (int) $value : null;
8080
}
8181

82-
public function url(string $attribute = null): ?UriInterface
82+
public function url(?string $attribute = null): ?UriInterface
8383
{
8484
$value = $this->get($attribute);
8585

0 commit comments

Comments
 (0)