Skip to content

Commit

Permalink
[TASK] Avoid implicitly nullable method parameter
Browse files Browse the repository at this point in the history
Implicit nullable method parameters are deprecated
with PHP 8.4. The patch prepares affected method
signatures.
  • Loading branch information
lolli42 authored and ohader committed Jul 12, 2024
1 parent 39cc77c commit c672a2e
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/Behavior/CdataSection.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function getName(): string
return '#cdata-section';
}

public function handle(NodeInterface $node, ?DOMNode $domNode, Context $context, Behavior $behavior = null): ?DOMNode
public function handle(NodeInterface $node, ?DOMNode $domNode, Context $context, ?Behavior $behavior = null): ?DOMNode
{
if (!$this->secure || $domNode === null) {
return $domNode;
Expand Down
2 changes: 1 addition & 1 deletion src/Behavior/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function getName(): string
return '#comment';
}

public function handle(NodeInterface $node, ?DOMNode $domNode, Context $context, Behavior $behavior = null): ?DOMNode
public function handle(NodeInterface $node, ?DOMNode $domNode, Context $context, ?Behavior $behavior = null): ?DOMNode
{
if (!$this->secure || $domNode === null) {
return $domNode;
Expand Down
2 changes: 1 addition & 1 deletion src/Behavior/Handler/AsTextHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

class AsTextHandler implements HandlerInterface
{
public function handle(NodeInterface $node, ?DOMNode $domNode, Context $context, Behavior $behavior = null): ?DOMNode
public function handle(NodeInterface $node, ?DOMNode $domNode, Context $context, ?Behavior $behavior = null): ?DOMNode
{
if ($domNode === null) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion src/Behavior/Handler/ClosureHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct(Closure $closure)
$this->closure = $closure;
}

public function handle(NodeInterface $node, ?DOMNode $domNode, Context $context, Behavior $behavior = null): ?DOMNode
public function handle(NodeInterface $node, ?DOMNode $domNode, Context $context, ?Behavior $behavior = null): ?DOMNode
{
$result = call_user_func($this->closure, $node, $domNode, $context, $behavior);
if ($result !== null && !$result instanceof DOMNode) {
Expand Down
2 changes: 1 addition & 1 deletion src/Behavior/HandlerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@

interface HandlerInterface
{
public function handle(NodeInterface $node, ?DOMNode $domNode, Context $context, Behavior $behavior = null): ?DOMNode;
public function handle(NodeInterface $node, ?DOMNode $domNode, Context $context, ?Behavior $behavior = null): ?DOMNode;
}
2 changes: 1 addition & 1 deletion src/Behavior/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class Tag implements NodeInterface
*/
protected $attrs = [];

public function __construct(string $name, int $flags = null)
public function __construct(string $name, ?int $flags = null)
{
$this->name = $name;
// using `null` as default - potentially allows switching
Expand Down
2 changes: 1 addition & 1 deletion src/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Context
*/
public $initiator;

public function __construct(HTML5 $parser, InitiatorInterface $initiator = null)
public function __construct(HTML5 $parser, ?InitiatorInterface $initiator = null)
{
$this->parser = $parser;
$this->initiator = $initiator;
Expand Down
6 changes: 3 additions & 3 deletions src/Sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function __construct(...$items)
$this->parser = $this->createParser();
}

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

protected function handle(DOMNode $domNode, InitiatorInterface $initiator = null): DOMNode
protected function handle(DOMNode $domNode, ?InitiatorInterface $initiator = null): DOMNode
{
$this->context = new Context($this->parser, $initiator);
$this->beforeTraverse();
Expand Down Expand Up @@ -195,7 +195,7 @@ protected function replaceNode(DOMNode $source, ?DOMNode $target): ?DOMNode
return $target;
}

protected function createRules(InitiatorInterface $initiator = null): Rules
protected function createRules(?InitiatorInterface $initiator = null): Rules
{
$stream = fopen('php://temp', 'wb');
return (new Rules($stream, self::mastermindsDefaultOptions))
Expand Down

0 comments on commit c672a2e

Please sign in to comment.