From 65d8b2937430e944c84a0123d2b0dd392c1c85c7 Mon Sep 17 00:00:00 2001 From: Tomasz Kowalczyk Date: Sat, 14 Jan 2023 10:22:27 +0100 Subject: [PATCH] Quality of Life (#108) * adjusted code for Psalm ^5.4 * allowed Composer plugins for infection/extension-installer * moved PHP 8.2 to regular CI workflow, allowed failures on PHP 8.3 nightly --- .github/workflows/test.yaml | 4 ++-- composer.json | 5 +++++ src/Parser/RegularParser.php | 1 - src/Serializer/XmlSerializer.php | 4 +++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 4ad899a..3b261d3 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -11,11 +11,11 @@ jobs: runs-on: '${{ matrix.os }}' strategy: matrix: - php: ['7.4', '8.0', '8.1'] + php: ['7.4', '8.0', '8.1', '8.2'] os: ['ubuntu-latest'] failure: [false] include: - - { php: '8.2', os: 'ubuntu-latest', failure: true } # '8.2' means 'nightly' + - { php: '8.3', os: 'ubuntu-latest', failure: true } # '8.3' means 'nightly' steps: - name: 'Checkout' uses: 'actions/checkout@v2' diff --git a/composer.json b/composer.json index b89f05a..0414ebc 100644 --- a/composer.json +++ b/composer.json @@ -30,5 +30,10 @@ "symfony/yaml": "if you want to use YAML serializer", "ext-dom": "if you want to use XML serializer", "ext-json": "if you want to use JSON serializer" + }, + "config": { + "allow-plugins": { + "infection/extension-installer": true + } } } diff --git a/src/Parser/RegularParser.php b/src/Parser/RegularParser.php index d46a36a..bfddc2c 100644 --- a/src/Parser/RegularParser.php +++ b/src/Parser/RegularParser.php @@ -142,7 +142,6 @@ private function shortcode(array &$names) } $this->beginBacktrack(); - /** @psalm-suppress MixedArgumentTypeCoercion */ $contentMatchedShortcodes = $this->shortcode($names); if(\is_string($contentMatchedShortcodes)) { $closingName = $contentMatchedShortcodes; diff --git a/src/Serializer/XmlSerializer.php b/src/Serializer/XmlSerializer.php index a2af59e..a4e67f7 100644 --- a/src/Serializer/XmlSerializer.php +++ b/src/Serializer/XmlSerializer.php @@ -88,6 +88,7 @@ public function unserialize($text) if($shortcode->length !== 1) { throw new \InvalidArgumentException('Invalid shortcode XML!'); } + /** @psalm-suppress PossiblyNullArgument */ $name = $this->getAttribute($shortcode->item(0), 'name'); $bbCode = $this->getValue($xpath->query('/shortcode/bbCode')); @@ -98,6 +99,7 @@ public function unserialize($text) for($i = 0; $i < $elements->length; $i++) { $node = $elements->item($i); + /** @psalm-suppress PossiblyNullReference */ $parameters[$this->getAttribute($node, 'name')] = $node->hasChildNodes() ? $node->nodeValue : null; } @@ -111,6 +113,7 @@ public function unserialize($text) */ private function getValue(\DOMNodeList $node) { + /** @psalm-suppress PossiblyNullReference,PossiblyNullPropertyFetch */ return $node->length === 1 && $node->item(0)->hasChildNodes() ? $node->item(0)->nodeValue : null; @@ -119,7 +122,6 @@ private function getValue(\DOMNodeList $node) /** * @param \DOMNode $node * @param string $name - * @psalm-suppress UnusedParam * * @return string */