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

Detect deprecations in PHPUnit #115

Merged
merged 1 commit into from
Dec 15, 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
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 @@
/** @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.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;

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.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;
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 @@
/**
* @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.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;

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.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;
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
Loading