Fix PHPStan issues and build on PHP 8.2 (#368)

Limit PHPStan to PHP 8.1
This commit is contained in:
Alexey Kopytko 2022-09-05 10:33:36 +09:00 committed by GitHub
parent 6ca731e849
commit 546b80a136
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 9 deletions

View file

@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php:
php:
- '7.4'
- '8.0'
- '8.1'
@ -26,4 +26,5 @@ jobs:
- run: composer install --no-progress
# - run: composer codestyle
- run: composer phpstan
if: matrix.php == '8.1'
- run: composer tests

View file

@ -601,6 +601,7 @@ class MarkdownExtra extends \Michelf\Markdown {
else {
$parsed .= $tag;
}
// @phpstan-ignore-next-line
} while ($depth >= 0);
return array($parsed, $text);

View file

@ -24,11 +24,10 @@
"psr-4": { "Michelf\\": "Michelf/" }
},
"require-dev": {
"phpspec/prophecy": "^1.6",
"friendsofphp/php-cs-fixer": "^3.0",
"phpunit/phpunit": "^9.5",
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-phpunit": "^1.0"
"phpstan/phpstan": ">=1.0",
"phpstan/phpstan-phpunit": ">=1.0"
},
"scripts": {

View file

@ -22,7 +22,6 @@ class MarkdownTestHelper
$dataValues = array();
/** @var SplFileInfo $inputFile */
foreach ($regexIterator as $inputFiles) {
foreach ($inputFiles as $inputMarkdownPath) {
$xhtml = true;
@ -163,6 +162,7 @@ class MarkdownTestHelper
foreach ($node_list as $node) {
switch ($node->nodeType) {
case XML_ELEMENT_NODE:
/** @var DOMElement $node */
static::normalizeElementContent($node, $whitespace_preserve);
static::normalizeElementAttributes($node);
@ -207,6 +207,7 @@ class MarkdownTestHelper
break;
case XML_TEXT_NODE:
/** @var DOMText $node */
if (!$whitespace_preserve) {
if (trim($node->data) === "") {
$node->data = $whitespace;
@ -222,8 +223,8 @@ class MarkdownTestHelper
($whitespace === "\n\n" || $whitespace === "\n")) {
if ($element->firstChild) {
if ($element->firstChild->nodeType == XML_TEXT_NODE) {
$element->firstChild->data =
preg_replace('{^\s+}', "\n", $element->firstChild->data);
$element->firstChild->data = // @phpstan-ignore-line
preg_replace('{^\s+}', "\n", $element->firstChild->data ?? '');
}
else {
$element->insertBefore(new DOMText("\n"), $element->firstChild);
@ -231,8 +232,8 @@ class MarkdownTestHelper
}
if ($element->lastChild) {
if ($element->lastChild->nodeType == XML_TEXT_NODE) {
$element->lastChild->data =
preg_replace('{\s+$}', "\n", $element->lastChild->data);
$element->lastChild->data = // @phpstan-ignore-line
preg_replace('{\s+$}', "\n", $element->lastChild->data ?? '');
}
else {
$element->insertBefore(new DOMText("\n"), null);