Skip to content

Commit

Permalink
- detect deprecations in PHPUnit,
Browse files Browse the repository at this point in the history
- fixed all instances of PHP 8.4 deprecated implicitly marking parameters as nullable.
  • Loading branch information
thunderer committed Dec 15, 2024
1 parent a19b8ef commit 9f81424
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 12 deletions.
10 changes: 5 additions & 5 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<phpunit
colors = "true"
backupGlobals = "false"
processIsolation = "false"
stopOnFailure = "false"
bootstrap = "vendor/autoload.php"
colors="true"
failOnNotice="true"
failOnWarning="true"
failOnDeprecation="true"
bootstrap="vendor/autoload.php"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd">

Expand Down
11 changes: 9 additions & 2 deletions src/Event/FilterShortcodesEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,16 @@ class FilterShortcodesEvent
/** @var ParsedShortcodeInterface[] */
private $shortcodes = array();

/** @param ParsedShortcodeInterface[] $shortcodes */
public function __construct(array $shortcodes, ProcessedShortcode $parent = null)
/**
* @param ParsedShortcodeInterface[] $shortcodes
* @param ProcessedShortcode|null $parent
*/
public function __construct(array $shortcodes, $parent = null)
{
if(null !== $parent && false === $parent instanceof ProcessedShortcode) {

Check warning on line 27 in src/Event/FilterShortcodesEvent.php

View workflow job for this annotation

GitHub Actions / test (8.0, ubuntu-latest, false)

Escaped Mutant for Mutator "InstanceOf_": --- Original +++ New @@ @@ */ public function __construct(array $shortcodes, $parent = null) { - if (null !== $parent && false === $parent instanceof ProcessedShortcode) { + if (null !== $parent && false === true) { throw new \LogicException('Parameter $parent must be an instance of ProcessedShortcode.'); } $this->parent = $parent;

Check warning on line 27 in src/Event/FilterShortcodesEvent.php

View workflow job for this annotation

GitHub Actions / test (8.4, ubuntu-latest, true)

Escaped Mutant for Mutator "InstanceOf_": @@ @@ */ public function __construct(array $shortcodes, $parent = null) { - if (null !== $parent && false === $parent instanceof ProcessedShortcode) { + if (null !== $parent && false === true) { throw new \LogicException('Parameter $parent must be an instance of ProcessedShortcode.'); } $this->parent = $parent;

Check warning on line 27 in src/Event/FilterShortcodesEvent.php

View workflow job for this annotation

GitHub Actions / test (8.5, ubuntu-latest, true)

Escaped Mutant for Mutator "InstanceOf_": @@ @@ */ public function __construct(array $shortcodes, $parent = null) { - if (null !== $parent && false === $parent instanceof ProcessedShortcode) { + if (null !== $parent && false === true) { throw new \LogicException('Parameter $parent must be an instance of ProcessedShortcode.'); } $this->parent = $parent;

Check warning on line 27 in src/Event/FilterShortcodesEvent.php

View workflow job for this annotation

GitHub Actions / test (8.2, ubuntu-latest, false)

Escaped Mutant for Mutator "InstanceOf_": --- Original +++ New @@ @@ */ public function __construct(array $shortcodes, $parent = null) { - if (null !== $parent && false === $parent instanceof ProcessedShortcode) { + if (null !== $parent && false === true) { throw new \LogicException('Parameter $parent must be an instance of ProcessedShortcode.'); } $this->parent = $parent;

Check warning on line 27 in src/Event/FilterShortcodesEvent.php

View workflow job for this annotation

GitHub Actions / test (8.3, ubuntu-latest, false)

Escaped Mutant for Mutator "InstanceOf_": --- Original +++ New @@ @@ */ public function __construct(array $shortcodes, $parent = null) { - if (null !== $parent && false === $parent instanceof ProcessedShortcode) { + if (null !== $parent && false === true) { throw new \LogicException('Parameter $parent must be an instance of ProcessedShortcode.'); } $this->parent = $parent;

Check warning on line 27 in src/Event/FilterShortcodesEvent.php

View workflow job for this annotation

GitHub Actions / test (8.1, ubuntu-latest, false)

Escaped Mutant for Mutator "InstanceOf_": --- Original +++ New @@ @@ */ public function __construct(array $shortcodes, $parent = null) { - if (null !== $parent && false === $parent instanceof ProcessedShortcode) { + if (null !== $parent && false === true) { throw new \LogicException('Parameter $parent must be an instance of ProcessedShortcode.'); } $this->parent = $parent;
throw new \LogicException('Parameter $parent must be an instance of ProcessedShortcode.');
}

$this->parent = $parent;
$this->setShortcodes($shortcodes);
}
Expand Down
7 changes: 6 additions & 1 deletion src/Event/ReplaceShortcodesEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,14 @@ class ReplaceShortcodesEvent
/**
* @param string $text
* @param ReplacedShortcode[] $replacements
* @param ShortcodeInterface|null $shortcode
*/
public function __construct($text, array $replacements, ShortcodeInterface $shortcode = null)
public function __construct($text, array $replacements, $shortcode = null)
{
if(null !== $shortcode && false === $shortcode instanceof ShortcodeInterface) {

Check warning on line 32 in src/Event/ReplaceShortcodesEvent.php

View workflow job for this annotation

GitHub Actions / test (8.0, ubuntu-latest, false)

Escaped Mutant for Mutator "InstanceOf_": --- Original +++ New @@ @@ */ public function __construct($text, array $replacements, $shortcode = null) { - if (null !== $shortcode && false === $shortcode instanceof ShortcodeInterface) { + if (null !== $shortcode && false === true) { throw new \LogicException('Parameter $shortcode must be an instance of ShortcodeInterface.'); } $this->shortcode = $shortcode;

Check warning on line 32 in src/Event/ReplaceShortcodesEvent.php

View workflow job for this annotation

GitHub Actions / test (8.4, ubuntu-latest, true)

Escaped Mutant for Mutator "InstanceOf_": @@ @@ */ public function __construct($text, array $replacements, $shortcode = null) { - if (null !== $shortcode && false === $shortcode instanceof ShortcodeInterface) { + if (null !== $shortcode && false === true) { throw new \LogicException('Parameter $shortcode must be an instance of ShortcodeInterface.'); } $this->shortcode = $shortcode;

Check warning on line 32 in src/Event/ReplaceShortcodesEvent.php

View workflow job for this annotation

GitHub Actions / test (8.5, ubuntu-latest, true)

Escaped Mutant for Mutator "InstanceOf_": @@ @@ */ public function __construct($text, array $replacements, $shortcode = null) { - if (null !== $shortcode && false === $shortcode instanceof ShortcodeInterface) { + if (null !== $shortcode && false === true) { throw new \LogicException('Parameter $shortcode must be an instance of ShortcodeInterface.'); } $this->shortcode = $shortcode;

Check warning on line 32 in src/Event/ReplaceShortcodesEvent.php

View workflow job for this annotation

GitHub Actions / test (8.2, ubuntu-latest, false)

Escaped Mutant for Mutator "InstanceOf_": --- Original +++ New @@ @@ */ public function __construct($text, array $replacements, $shortcode = null) { - if (null !== $shortcode && false === $shortcode instanceof ShortcodeInterface) { + if (null !== $shortcode && false === true) { throw new \LogicException('Parameter $shortcode must be an instance of ShortcodeInterface.'); } $this->shortcode = $shortcode;

Check warning on line 32 in src/Event/ReplaceShortcodesEvent.php

View workflow job for this annotation

GitHub Actions / test (8.3, ubuntu-latest, false)

Escaped Mutant for Mutator "InstanceOf_": --- Original +++ New @@ @@ */ public function __construct($text, array $replacements, $shortcode = null) { - if (null !== $shortcode && false === $shortcode instanceof ShortcodeInterface) { + if (null !== $shortcode && false === true) { throw new \LogicException('Parameter $shortcode must be an instance of ShortcodeInterface.'); } $this->shortcode = $shortcode;

Check warning on line 32 in src/Event/ReplaceShortcodesEvent.php

View workflow job for this annotation

GitHub Actions / test (8.1, ubuntu-latest, false)

Escaped Mutant for Mutator "InstanceOf_": --- Original +++ New @@ @@ */ public function __construct($text, array $replacements, $shortcode = null) { - if (null !== $shortcode && false === $shortcode instanceof ShortcodeInterface) { + if (null !== $shortcode && false === true) { throw new \LogicException('Parameter $shortcode must be an instance of ShortcodeInterface.'); } $this->shortcode = $shortcode;
throw new \LogicException('Parameter $shortcode must be an instance of ShortcodeInterface.');
}

$this->shortcode = $shortcode;
$this->text = $text;

Expand Down
7 changes: 6 additions & 1 deletion src/Parser/RegexParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ final class RegexParser implements ParserInterface
/** @var non-empty-string */
private $parametersRegex;

public function __construct(SyntaxInterface $syntax = null)
/** @param SyntaxInterface|null $syntax */
public function __construct($syntax = null)
{
if(null !== $syntax && false === $syntax instanceof SyntaxInterface) {
throw new \LogicException('Parameter $syntax must be an instance of SyntaxInterface.');
}

$this->syntax = $syntax ?: new Syntax();
$this->shortcodeRegex = RegexBuilderUtility::buildShortcodeRegex($this->syntax);
$this->singleShortcodeRegex = RegexBuilderUtility::buildSingleShortcodeRegex($this->syntax);
Expand Down
7 changes: 6 additions & 1 deletion src/Parser/RegularParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,13 @@ final class RegularParser implements ParserInterface
const TOKEN_STRING = 6;
const TOKEN_WS = 7;

public function __construct(SyntaxInterface $syntax = null)
/** @param SyntaxInterface|null $syntax */
public function __construct($syntax = null)
{
if(null !== $syntax && false === $syntax instanceof SyntaxInterface) {
throw new \LogicException('Parameter $syntax must be an instance of SyntaxInterface.');
}

$this->lexerRegex = $this->prepareLexer($syntax ?: new CommonSyntax());
$this->nameRegex = '~^'.RegexBuilderUtility::buildNameRegex().'$~us';
}
Expand Down
6 changes: 5 additions & 1 deletion src/Processor/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,15 @@ private function dispatchEvent($name, $event)

/**
* @param string $text
* @param ProcessedShortcode|null $parent
*
* @return string
*/
private function processIteration($text, ProcessorContext $context, ProcessedShortcode $parent = null)
private function processIteration($text, ProcessorContext $context, $parent = null)
{
if(null !== $parent && false === $parent instanceof ProcessedShortcode) {
throw new \LogicException('Parameter $parent must be an instance of ProcessedShortcode.');
}
if (null !== $this->recursionDepth && $context->recursionLevel > $this->recursionDepth) {
return $text;
}
Expand Down
7 changes: 6 additions & 1 deletion src/Serializer/TextSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@ final class TextSerializer implements SerializerInterface
/** @var SyntaxInterface */
private $syntax;

public function __construct(SyntaxInterface $syntax = null)
/** @param SyntaxInterface|null $syntax */
public function __construct($syntax = null)
{
if(null !== $syntax && false === $syntax instanceof SyntaxInterface) {
throw new \LogicException('Parameter $syntax must be an instance of SyntaxInterface.');
}

$this->syntax = $syntax ?: new Syntax();
}

Expand Down

0 comments on commit 9f81424

Please sign in to comment.