Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 8.4 compatibility #117

Merged
merged 4 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down
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