Skip to content

Commit c672a2e

Browse files
lolli42ohader
authored andcommitted
[TASK] Avoid implicitly nullable method parameter
Implicit nullable method parameters are deprecated with PHP 8.4. The patch prepares affected method signatures.
1 parent 39cc77c commit c672a2e

8 files changed

+10
-10
lines changed

src/Behavior/CdataSection.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function getName(): string
3939
return '#cdata-section';
4040
}
4141

42-
public function handle(NodeInterface $node, ?DOMNode $domNode, Context $context, Behavior $behavior = null): ?DOMNode
42+
public function handle(NodeInterface $node, ?DOMNode $domNode, Context $context, ?Behavior $behavior = null): ?DOMNode
4343
{
4444
if (!$this->secure || $domNode === null) {
4545
return $domNode;

src/Behavior/Comment.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function getName(): string
3939
return '#comment';
4040
}
4141

42-
public function handle(NodeInterface $node, ?DOMNode $domNode, Context $context, Behavior $behavior = null): ?DOMNode
42+
public function handle(NodeInterface $node, ?DOMNode $domNode, Context $context, ?Behavior $behavior = null): ?DOMNode
4343
{
4444
if (!$this->secure || $domNode === null) {
4545
return $domNode;

src/Behavior/Handler/AsTextHandler.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
class AsTextHandler implements HandlerInterface
2525
{
26-
public function handle(NodeInterface $node, ?DOMNode $domNode, Context $context, Behavior $behavior = null): ?DOMNode
26+
public function handle(NodeInterface $node, ?DOMNode $domNode, Context $context, ?Behavior $behavior = null): ?DOMNode
2727
{
2828
if ($domNode === null) {
2929
return null;

src/Behavior/Handler/ClosureHandler.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct(Closure $closure)
3434
$this->closure = $closure;
3535
}
3636

37-
public function handle(NodeInterface $node, ?DOMNode $domNode, Context $context, Behavior $behavior = null): ?DOMNode
37+
public function handle(NodeInterface $node, ?DOMNode $domNode, Context $context, ?Behavior $behavior = null): ?DOMNode
3838
{
3939
$result = call_user_func($this->closure, $node, $domNode, $context, $behavior);
4040
if ($result !== null && !$result instanceof DOMNode) {

src/Behavior/HandlerInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@
2020

2121
interface HandlerInterface
2222
{
23-
public function handle(NodeInterface $node, ?DOMNode $domNode, Context $context, Behavior $behavior = null): ?DOMNode;
23+
public function handle(NodeInterface $node, ?DOMNode $domNode, Context $context, ?Behavior $behavior = null): ?DOMNode;
2424
}

src/Behavior/Tag.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class Tag implements NodeInterface
6262
*/
6363
protected $attrs = [];
6464

65-
public function __construct(string $name, int $flags = null)
65+
public function __construct(string $name, ?int $flags = null)
6666
{
6767
$this->name = $name;
6868
// using `null` as default - potentially allows switching

src/Context.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Context
3232
*/
3333
public $initiator;
3434

35-
public function __construct(HTML5 $parser, InitiatorInterface $initiator = null)
35+
public function __construct(HTML5 $parser, ?InitiatorInterface $initiator = null)
3636
{
3737
$this->parser = $parser;
3838
$this->initiator = $initiator;

src/Sanitizer.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function __construct(...$items)
9292
$this->parser = $this->createParser();
9393
}
9494

95-
public function sanitize(string $html, InitiatorInterface $initiator = null): string
95+
public function sanitize(string $html, ?InitiatorInterface $initiator = null): string
9696
{
9797
$root = $this->parse($html);
9898
// @todo drop deprecated property
@@ -109,7 +109,7 @@ protected function parse(string $html): DOMDocumentFragment
109109
return $this->parser->parseFragment($html);
110110
}
111111

112-
protected function handle(DOMNode $domNode, InitiatorInterface $initiator = null): DOMNode
112+
protected function handle(DOMNode $domNode, ?InitiatorInterface $initiator = null): DOMNode
113113
{
114114
$this->context = new Context($this->parser, $initiator);
115115
$this->beforeTraverse();
@@ -195,7 +195,7 @@ protected function replaceNode(DOMNode $source, ?DOMNode $target): ?DOMNode
195195
return $target;
196196
}
197197

198-
protected function createRules(InitiatorInterface $initiator = null): Rules
198+
protected function createRules(?InitiatorInterface $initiator = null): Rules
199199
{
200200
$stream = fopen('php://temp', 'wb');
201201
return (new Rules($stream, self::mastermindsDefaultOptions))

0 commit comments

Comments
 (0)