Skip to content

Commit 521e5ed

Browse files
committed
Handles PHP8.4 nullable type deprecations
1 parent 7811195 commit 521e5ed

File tree

8 files changed

+12
-11
lines changed

8 files changed

+12
-11
lines changed

.php-cs-fixer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
'no_superfluous_phpdoc_tags' => true,
4141
'no_trailing_comma_in_singleline' => true,
4242
'no_unused_imports' => true,
43+
'nullable_type_declaration_for_default_null_value' => true,
4344
'ordered_imports' => ['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'alpha'],
4445
'phpdoc_add_missing_param_annotation' => ['only_untyped' => true],
4546
'phpdoc_align' => ['align' => 'left'],

components/Components/Domain.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public function withRootLabel(): DomainHostInterface
206206
};
207207
}
208208

209-
public function slice(int $offset, int $length = null): self
209+
public function slice(int $offset, ?int $length = null): self
210210
{
211211
$nbLabels = count($this->labels);
212212
if ($offset < -$nbLabels || $offset > $nbLabels) {

components/Components/HierarchicalPath.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ public function withoutSegment(int ...$keys): SegmentedPathInterface
351351
return new self($path);
352352
}
353353

354-
public function slice(int $offset, int $length = null): self
354+
public function slice(int $offset, ?int $length = null): self
355355
{
356356
$nbSegments = count($this->segments);
357357
if ($offset < -$nbSegments || $offset > $nbSegments) {
@@ -425,7 +425,7 @@ public function withExtension(Stringable|string $extension): SegmentedPathInterf
425425
/**
426426
* Creates a new basename with a new extension.
427427
*/
428-
private function buildBasename(string $extension, string $ext, string $param = null): string
428+
private function buildBasename(string $extension, string $ext, ?string $param = null): string
429429
{
430430
$length = strrpos($ext, '.'.pathinfo($ext, PATHINFO_EXTENSION));
431431
if (false !== $length) {

components/Components/Query.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ final class Query extends Component implements QueryInterface
5454
/**
5555
* Returns a new instance.
5656
*/
57-
private function __construct(Stringable|string|null $query, Converter $converter = null)
57+
private function __construct(Stringable|string|null $query, ?Converter $converter = null)
5858
{
5959
$converter ??= Converter::fromRFC3986();
6060
$this->pairs = QueryString::parseFromValue($query, $converter);

components/Modifier.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ public function removeRootLabel(): static
476476
/**
477477
* Slice the host from the URI.
478478
*/
479-
public function sliceLabels(int $offset, int $length = null): static
479+
public function sliceLabels(int $offset, ?int $length = null): static
480480
{
481481
$currentHost = $this->uri->getHost();
482482
$host = Domain::new($currentHost)->slice($offset, $length);
@@ -702,7 +702,7 @@ public function replaceSegment(int $offset, Stringable|string $segment): static
702702
/**
703703
* Slice the host from the URI.
704704
*/
705-
public function sliceSegments(int $offset, int $length = null): static
705+
public function sliceSegments(int $offset, ?int $length = null): static
706706
{
707707
return new static(static::normalizePath($this->uri, HierarchicalPath::fromUri($this->uri)->slice($offset, $length)));
708708
}

interfaces/Contracts/DomainHostInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function append(Stringable|string $label): self;
7373
*
7474
* If $length is null it returns all elements from $offset to the end of the Domain.
7575
*/
76-
public function slice(int $offset, int $length = null): self;
76+
public function slice(int $offset, ?int $length = null): self;
7777

7878
/**
7979
* Returns an instance with its Root label.

interfaces/Contracts/SegmentedPathInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function append(Stringable|string $segment): self;
8181
*
8282
* If $length is null it returns all elements from $offset to the end of the Path.
8383
*/
84-
public function slice(int $offset, int $length = null): self;
84+
public function slice(int $offset, ?int $length = null): self;
8585

8686
/**
8787
* Prepends a segment to the path.

interfaces/QueryString.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public static function build(iterable $pairs, string $separator = '&', int $encT
7979
* @throws SyntaxError If the encoding type is invalid
8080
* @throws SyntaxError If a pair is invalid
8181
*/
82-
public static function buildFromPairs(iterable $pairs, Converter $converter = null): ?string
82+
public static function buildFromPairs(iterable $pairs, ?Converter $converter = null): ?string
8383
{
8484
$keyValuePairs = [];
8585
foreach ($pairs as $pair) {
@@ -124,7 +124,7 @@ public static function extract(Stringable|string|bool|null $query, string $separ
124124
*
125125
* @throws SyntaxError
126126
*/
127-
public static function extractFromValue(Stringable|string|bool|null $query, Converter $converter = null): array
127+
public static function extractFromValue(Stringable|string|bool|null $query, ?Converter $converter = null): array
128128
{
129129
return self::convert(self::decodePairs(
130130
($converter ?? Converter::fromRFC3986())->toPairs($query),
@@ -153,7 +153,7 @@ public static function parse(Stringable|string|bool|null $query, string $separat
153153
*
154154
* @return array<int, array{0:string, 1:string|null}>
155155
*/
156-
public static function parseFromValue(Stringable|string|bool|null $query, Converter $converter = null): array
156+
public static function parseFromValue(Stringable|string|bool|null $query, ?Converter $converter = null): array
157157
{
158158
return self::decodePairs(
159159
($converter ?? Converter::fromRFC3986())->toPairs($query),

0 commit comments

Comments
 (0)