Skip to content

Commit 9f81424

Browse files
committed
- detect deprecations in PHPUnit,
- fixed all instances of PHP 8.4 deprecated implicitly marking parameters as nullable.
1 parent a19b8ef commit 9f81424

File tree

7 files changed

+43
-12
lines changed

7 files changed

+43
-12
lines changed

Diff for: phpunit.xml.dist

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
22
<phpunit
3-
colors = "true"
4-
backupGlobals = "false"
5-
processIsolation = "false"
6-
stopOnFailure = "false"
7-
bootstrap = "vendor/autoload.php"
3+
colors="true"
4+
failOnNotice="true"
5+
failOnWarning="true"
6+
failOnDeprecation="true"
7+
bootstrap="vendor/autoload.php"
88
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
99
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd">
1010

Diff for: src/Event/FilterShortcodesEvent.php

+9-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,16 @@ class FilterShortcodesEvent
1818
/** @var ParsedShortcodeInterface[] */
1919
private $shortcodes = array();
2020

21-
/** @param ParsedShortcodeInterface[] $shortcodes */
22-
public function __construct(array $shortcodes, ProcessedShortcode $parent = null)
21+
/**
22+
* @param ParsedShortcodeInterface[] $shortcodes
23+
* @param ProcessedShortcode|null $parent
24+
*/
25+
public function __construct(array $shortcodes, $parent = null)
2326
{
27+
if(null !== $parent && false === $parent instanceof ProcessedShortcode) {
28+
throw new \LogicException('Parameter $parent must be an instance of ProcessedShortcode.');
29+
}
30+
2431
$this->parent = $parent;
2532
$this->setShortcodes($shortcodes);
2633
}

Diff for: src/Event/ReplaceShortcodesEvent.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,14 @@ class ReplaceShortcodesEvent
2525
/**
2626
* @param string $text
2727
* @param ReplacedShortcode[] $replacements
28+
* @param ShortcodeInterface|null $shortcode
2829
*/
29-
public function __construct($text, array $replacements, ShortcodeInterface $shortcode = null)
30+
public function __construct($text, array $replacements, $shortcode = null)
3031
{
32+
if(null !== $shortcode && false === $shortcode instanceof ShortcodeInterface) {
33+
throw new \LogicException('Parameter $shortcode must be an instance of ShortcodeInterface.');
34+
}
35+
3136
$this->shortcode = $shortcode;
3237
$this->text = $text;
3338

Diff for: src/Parser/RegexParser.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,13 @@ final class RegexParser implements ParserInterface
2121
/** @var non-empty-string */
2222
private $parametersRegex;
2323

24-
public function __construct(SyntaxInterface $syntax = null)
24+
/** @param SyntaxInterface|null $syntax */
25+
public function __construct($syntax = null)
2526
{
27+
if(null !== $syntax && false === $syntax instanceof SyntaxInterface) {
28+
throw new \LogicException('Parameter $syntax must be an instance of SyntaxInterface.');
29+
}
30+
2631
$this->syntax = $syntax ?: new Syntax();
2732
$this->shortcodeRegex = RegexBuilderUtility::buildShortcodeRegex($this->syntax);
2833
$this->singleShortcodeRegex = RegexBuilderUtility::buildSingleShortcodeRegex($this->syntax);

Diff for: src/Parser/RegularParser.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,13 @@ final class RegularParser implements ParserInterface
3535
const TOKEN_STRING = 6;
3636
const TOKEN_WS = 7;
3737

38-
public function __construct(SyntaxInterface $syntax = null)
38+
/** @param SyntaxInterface|null $syntax */
39+
public function __construct($syntax = null)
3940
{
41+
if(null !== $syntax && false === $syntax instanceof SyntaxInterface) {
42+
throw new \LogicException('Parameter $syntax must be an instance of SyntaxInterface.');
43+
}
44+
4045
$this->lexerRegex = $this->prepareLexer($syntax ?: new CommonSyntax());
4146
$this->nameRegex = '~^'.RegexBuilderUtility::buildNameRegex().'$~us';
4247
}

Diff for: src/Processor/Processor.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,15 @@ private function dispatchEvent($name, $event)
8686

8787
/**
8888
* @param string $text
89+
* @param ProcessedShortcode|null $parent
8990
*
9091
* @return string
9192
*/
92-
private function processIteration($text, ProcessorContext $context, ProcessedShortcode $parent = null)
93+
private function processIteration($text, ProcessorContext $context, $parent = null)
9394
{
95+
if(null !== $parent && false === $parent instanceof ProcessedShortcode) {
96+
throw new \LogicException('Parameter $parent must be an instance of ProcessedShortcode.');
97+
}
9498
if (null !== $this->recursionDepth && $context->recursionLevel > $this->recursionDepth) {
9599
return $text;
96100
}

Diff for: src/Serializer/TextSerializer.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@ final class TextSerializer implements SerializerInterface
1515
/** @var SyntaxInterface */
1616
private $syntax;
1717

18-
public function __construct(SyntaxInterface $syntax = null)
18+
/** @param SyntaxInterface|null $syntax */
19+
public function __construct($syntax = null)
1920
{
21+
if(null !== $syntax && false === $syntax instanceof SyntaxInterface) {
22+
throw new \LogicException('Parameter $syntax must be an instance of SyntaxInterface.');
23+
}
24+
2025
$this->syntax = $syntax ?: new Syntax();
2126
}
2227

0 commit comments

Comments
 (0)