Skip to content

Commit

Permalink
Update to PSalm 5 (#705)
Browse files Browse the repository at this point in the history
  • Loading branch information
Slamdunk authored Dec 5, 2022
1 parent 31fd5d6 commit 7b0595a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ all: csfix static-analysis code-coverage

vendor: composer.json
composer update
composer bump
touch vendor

.PHONY: csfix
Expand Down
18 changes: 8 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,22 @@
"ext-reflection": "*",
"ext-simplexml": "*",
"jean85/pretty-package-versions": "^2.0.5",
"phpunit/php-code-coverage": "^9.2.17",
"phpunit/php-code-coverage": "^9.2.19",
"phpunit/php-file-iterator": "^3.0.6",
"phpunit/php-timer": "^5.0.3",
"phpunit/phpunit": "^9.5.24",
"phpunit/phpunit": "^9.5.26",
"sebastian/environment": "^5.1.4",
"symfony/console": "^5.4.12 || ^6.1.4",
"symfony/process": "^5.4.11 || ^6.1.3"
"symfony/console": "^5.4.12 || ^6.2",
"symfony/process": "^5.4.11 || ^6.2"
},
"require-dev": {
"ext-pcov": "*",
"ext-posix": "*",
"doctrine/coding-standard": "^10.0.0",
"infection/infection": "^0.26.14",
"malukenho/mcbumpface": "^1.1.5",
"infection/infection": "^0.26.16",
"squizlabs/php_codesniffer": "^3.7.1",
"symfony/filesystem": "^5.4.12 || ^6.1.4",
"vimeo/psalm": "^4.27.0"
"symfony/filesystem": "^5.4.12 || ^6.2",
"vimeo/psalm": "^5.1"
},
"autoload": {
"psr-4": {
Expand All @@ -78,8 +77,7 @@
"allow-plugins": {
"composer/package-versions-deprecated": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"infection/extension-installer": true,
"malukenho/mcbumpface": true
"infection/extension-installer": true
},
"sort-packages": true
}
Expand Down
12 changes: 7 additions & 5 deletions src/Logging/JUnit/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ final public static function caseFromNode(SimpleXMLElement $node): self
{
$systemOutput = null;
$systemOutputs = $node->xpath('system-out');
if ($systemOutputs !== []) {
if ($systemOutputs !== null && $systemOutputs !== []) {
assert(count($systemOutputs) === 1);
$systemOutput = (string) current($systemOutputs);
}
Expand All @@ -83,13 +83,15 @@ final public static function caseFromNode(SimpleXMLElement $node): self
return $node;
};
$getType = static function (SimpleXMLElement $node): string {
$attributes = iterator_to_array($node->attributes());
$element = $node->attributes();
assert($element !== null);
$attributes = iterator_to_array($element);
assert($attributes !== []);

return (string) $attributes['type'];
};

if (($errors = $node->xpath('error')) !== []) {
if (($errors = $node->xpath('error')) !== null && $errors !== []) {
$error = $getFirstNode($errors);
$type = $getType($error);
$text = (string) $error;
Expand Down Expand Up @@ -124,7 +126,7 @@ class_exists($type)
);
}

if (($warnings = $node->xpath('warning')) !== []) {
if (($warnings = $node->xpath('warning')) !== null && $warnings !== []) {
$warning = $getFirstNode($warnings);
$type = $getType($warning);
$text = (string) $warning;
Expand All @@ -142,7 +144,7 @@ class_exists($type)
);
}

if (($failures = $node->xpath('failure')) !== []) {
if (($failures = $node->xpath('failure')) !== null && $failures !== []) {
$failure = $getFirstNode($failures);
$type = $getType($failure);
$text = (string) $failure;
Expand Down
2 changes: 1 addition & 1 deletion test/Unit/Coverage/CoverageReporterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private function createCoverageReporter(string $fixtureFile): void
$filter->includeFile(__FILE__);
$codeCoverage = new CodeCoverage((new Selector())->forLineCoverage($filter), $filter);
$codeCoverage->append(RawCodeCoverageData::fromXdebugWithoutPathCoverage([
__FILE__ => [__LINE__ => 1],
__FILE__ => [__LINE__ - 1 => 1],
]), uniqid('test_'));

$configuration = (new Loader())->load($this->fixture($fixtureFile));
Expand Down

0 comments on commit 7b0595a

Please sign in to comment.