From 38965badba3166609da396872ff6138aa30e412d Mon Sep 17 00:00:00 2001 From: Denis Smetannikov Date: Wed, 23 Aug 2023 20:55:43 +0300 Subject: [PATCH] Fix Psalm issues (#34) --- composer.lock | 83 ++++++++++--------- src/Converters/JUnitConverter.php | 3 +- .../PhpUnitCloverStatsTcConverter.php | 6 +- 3 files changed, 51 insertions(+), 41 deletions(-) diff --git a/composer.lock b/composer.lock index c35e37d..3737641 100644 --- a/composer.lock +++ b/composer.lock @@ -65,16 +65,16 @@ }, { "name": "jbzoo/cli", - "version": "7.1.1", + "version": "7.1.3", "source": { "type": "git", "url": "https://github.com/JBZoo/Cli.git", - "reference": "cf71756468831111aa47f617573b6d903f4cd191" + "reference": "10f743b0a8b3294a45681188b254be95e27d9bd5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/JBZoo/Cli/zipball/cf71756468831111aa47f617573b6d903f4cd191", - "reference": "cf71756468831111aa47f617573b6d903f4cd191", + "url": "https://api.github.com/repos/JBZoo/Cli/zipball/10f743b0a8b3294a45681188b254be95e27d9bd5", + "reference": "10f743b0a8b3294a45681188b254be95e27d9bd5", "shasum": "" }, "require": { @@ -136,9 +136,9 @@ ], "support": { "issues": "https://github.com/JBZoo/Cli/issues", - "source": "https://github.com/JBZoo/Cli/tree/7.1.1" + "source": "https://github.com/JBZoo/Cli/tree/7.1.3" }, - "time": "2023-08-16T17:32:43+00:00" + "time": "2023-08-16T21:09:25+00:00" }, { "name": "jbzoo/data", @@ -340,16 +340,16 @@ }, { "name": "jbzoo/utils", - "version": "7.1.0", + "version": "7.1.1", "source": { "type": "git", "url": "https://github.com/JBZoo/Utils.git", - "reference": "0a9bfeecdee3d8d4bb0b8ddf8f5ae2b5682f1fae" + "reference": "501a27310c96030467516d3829fb4e1f1820cb82" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/JBZoo/Utils/zipball/0a9bfeecdee3d8d4bb0b8ddf8f5ae2b5682f1fae", - "reference": "0a9bfeecdee3d8d4bb0b8ddf8f5ae2b5682f1fae", + "url": "https://api.github.com/repos/JBZoo/Utils/zipball/501a27310c96030467516d3829fb4e1f1820cb82", + "reference": "501a27310c96030467516d3829fb4e1f1820cb82", "shasum": "" }, "require": { @@ -433,9 +433,9 @@ ], "support": { "issues": "https://github.com/JBZoo/Utils/issues", - "source": "https://github.com/JBZoo/Utils/tree/7.1.0" + "source": "https://github.com/JBZoo/Utils/tree/7.1.1" }, - "time": "2023-08-08T23:45:26+00:00" + "time": "2023-08-17T00:04:38+00:00" }, { "name": "monolog/monolog", @@ -4200,16 +4200,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.10.29", + "version": "1.10.30", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "ee5d8f2d3977fb09e55603eee6fb53bdd76ee9c1" + "reference": "2910afdd3fe33e5afd71c09f3fb0d0845b48c410" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/ee5d8f2d3977fb09e55603eee6fb53bdd76ee9c1", - "reference": "ee5d8f2d3977fb09e55603eee6fb53bdd76ee9c1", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/2910afdd3fe33e5afd71c09f3fb0d0845b48c410", + "reference": "2910afdd3fe33e5afd71c09f3fb0d0845b48c410", "shasum": "" }, "require": { @@ -4258,7 +4258,7 @@ "type": "tidelift" } ], - "time": "2023-08-14T13:24:11+00:00" + "time": "2023-08-22T13:48:25+00:00" }, { "name": "phpstan/phpstan-strict-rules", @@ -4630,16 +4630,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.10", + "version": "9.6.11", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "a6d351645c3fe5a30f5e86be6577d946af65a328" + "reference": "810500e92855eba8a7a5319ae913be2da6f957b0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a6d351645c3fe5a30f5e86be6577d946af65a328", - "reference": "a6d351645c3fe5a30f5e86be6577d946af65a328", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/810500e92855eba8a7a5319ae913be2da6f957b0", + "reference": "810500e92855eba8a7a5319ae913be2da6f957b0", "shasum": "" }, "require": { @@ -4713,7 +4713,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.10" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.11" }, "funding": [ { @@ -4729,7 +4729,7 @@ "type": "tidelift" } ], - "time": "2023-07-10T04:04:23+00:00" + "time": "2023-08-19T07:10:56+00:00" }, { "name": "povils/phpmnd", @@ -5092,12 +5092,12 @@ "source": { "type": "git", "url": "https://github.com/Roave/SecurityAdvisories.git", - "reference": "ae0e6ea6df489cfc6dc2c1b5dc2a107ed056ed2d" + "reference": "9160fb2612003a99a28abbd588519d5ab3a77024" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/ae0e6ea6df489cfc6dc2c1b5dc2a107ed056ed2d", - "reference": "ae0e6ea6df489cfc6dc2c1b5dc2a107ed056ed2d", + "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/9160fb2612003a99a28abbd588519d5ab3a77024", + "reference": "9160fb2612003a99a28abbd588519d5ab3a77024", "shasum": "" }, "conflict": { @@ -5166,7 +5166,7 @@ "centreon/centreon": "<22.10.0.0-beta1", "cesnet/simplesamlphp-module-proxystatistics": "<3.1", "chriskacerguis/codeigniter-restserver": "<=2.7.1", - "cockpit-hq/cockpit": "<2.6.3", + "cockpit-hq/cockpit": "<=2.6.3", "codeception/codeception": "<3.1.3|>=4,<4.1.22", "codeigniter/framework": "<3.1.9", "codeigniter4/framework": "<4.3.5", @@ -5182,7 +5182,7 @@ "contao/listing-bundle": ">=4,<4.4.8", "contao/managed-edition": "<=1.5", "cosenary/instagram": "<=2.3", - "craftcms/cms": "<4.4.12", + "craftcms/cms": "<=4.4.14", "croogo/croogo": "<4", "cuyz/valinor": "<0.12", "czproject/git-php": "<4.0.3", @@ -5246,8 +5246,8 @@ "firebase/php-jwt": "<6", "fixpunkt/fp-masterquiz": "<2.2.1|>=3,<3.5.2", "fixpunkt/fp-newsletter": "<1.1.1|>=2,<2.1.2|>=2.2,<3.2.6", - "flarum/core": "<1.7", - "flarum/framework": "<=0.1.0.0-beta7.1", + "flarum/core": "<1.8", + "flarum/framework": "<1.8", "flarum/mentions": "<1.6.3", "flarum/sticky": ">=0.1.0.0-beta14,<=0.1.0.0-beta15", "flarum/tags": "<=0.1.0.0-beta13", @@ -5337,6 +5337,7 @@ "kitodo/presentation": "<3.2.3|>=3.3,<3.3.4", "klaviyo/magento2-extension": ">=1,<3", "knplabs/knp-snappy": "<1.4.2", + "kohana/core": "<3.3.3", "krayin/laravel-crm": "<1.2.2", "kreait/firebase-php": ">=3.2,<3.8.1", "la-haute-societe/tcpdf": "<6.2.22", @@ -5456,7 +5457,7 @@ "pimcore/customer-management-framework-bundle": "<3.4.2", "pimcore/data-hub": "<1.2.4", "pimcore/perspective-editor": "<1.5.1", - "pimcore/pimcore": "<10.6.7", + "pimcore/pimcore": "<10.6.8", "pixelfed/pixelfed": "<=0.11.4", "pocketmine/bedrock-protocol": "<8.0.2", "pocketmine/pocketmine-mp": "<4.22.3|>=5,<5.2.1", @@ -5640,8 +5641,9 @@ "verot/class.upload.php": "<=1.0.3|>=2,<=2.0.4", "vova07/yii2-fileapi-widget": "<0.1.9", "vrana/adminer": "<4.8.1", + "waldhacker/hcaptcha": "<2.1.2", "wallabag/tcpdf": "<6.2.22", - "wallabag/wallabag": "<=2.5.4", + "wallabag/wallabag": "<=2.6.2", "wanglelecc/laracms": "<=1.0.3", "web-auth/webauthn-framework": ">=3.3,<3.3.4", "webbuilders-group/silverstripe-kapost-bridge": "<0.4", @@ -5741,7 +5743,7 @@ "type": "tidelift" } ], - "time": "2023-08-15T23:04:14+00:00" + "time": "2023-08-23T09:04:12+00:00" }, { "name": "sabre/event", @@ -8018,16 +8020,16 @@ }, { "name": "vimeo/psalm", - "version": "5.14.1", + "version": "5.15.0", "source": { "type": "git", "url": "https://github.com/vimeo/psalm.git", - "reference": "b9d355e0829c397b9b3b47d0c0ed042a8a70284d" + "reference": "5c774aca4746caf3d239d9c8cadb9f882ca29352" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vimeo/psalm/zipball/b9d355e0829c397b9b3b47d0c0ed042a8a70284d", - "reference": "b9d355e0829c397b9b3b47d0c0ed042a8a70284d", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/5c774aca4746caf3d239d9c8cadb9f882ca29352", + "reference": "5c774aca4746caf3d239d9c8cadb9f882ca29352", "shasum": "" }, "require": { @@ -8055,6 +8057,9 @@ "symfony/console": "^4.1.6 || ^5.0 || ^6.0", "symfony/filesystem": "^5.4 || ^6.0" }, + "conflict": { + "nikic/php-parser": "4.17.0" + }, "provide": { "psalm/psalm": "self.version" }, @@ -8118,9 +8123,9 @@ ], "support": { "issues": "https://github.com/vimeo/psalm/issues", - "source": "https://github.com/vimeo/psalm/tree/5.14.1" + "source": "https://github.com/vimeo/psalm/tree/5.15.0" }, - "time": "2023-08-01T05:16:55+00:00" + "time": "2023-08-20T23:07:30+00:00" }, { "name": "webmozart/assert", diff --git a/src/Converters/JUnitConverter.php b/src/Converters/JUnitConverter.php index 0f36cad..a3ce500 100644 --- a/src/Converters/JUnitConverter.php +++ b/src/Converters/JUnitConverter.php @@ -122,11 +122,12 @@ private function createSourceNodes(array $xmlAsArray, SourceSuite $currentSuite) $case->classname = $attrs->getStringNull('classname'); $case->assertions = $attrs->getIntNull('assertions'); + /** @var array $output */ foreach ($xmlAsArray['_children'] as $output) { $typeOfOutput = $output['_node']; $type = $output['_attrs']['type'] ?? null; $message = $output['_attrs']['message'] ?? null; - $details = ($output['_cdata'] ?? null) ?? $output['_text'] ?? null; + $details = $output['_cdata'] ?? $output['_text'] ?? null; $caseOutput = new SourceCaseOutput($type, $message, $details); diff --git a/src/Converters/PhpUnitCloverStatsTcConverter.php b/src/Converters/PhpUnitCloverStatsTcConverter.php index dc049f9..7f3005b 100644 --- a/src/Converters/PhpUnitCloverStatsTcConverter.php +++ b/src/Converters/PhpUnitCloverStatsTcConverter.php @@ -33,7 +33,7 @@ final class PhpUnitCloverStatsTcConverter extends AbstractStatsTcConverter public function toInternalMetric(string $sourceCode): Metrics { $cloverXml = new \SimpleXMLElement($sourceCode); - $info = data((array)$cloverXml->project->metrics)->getSelf('@attributes'); + $info = data((array)$cloverXml->project?->metrics)->getSelf('@attributes'); $coveredClasses = 0; @@ -41,6 +41,10 @@ public function toInternalMetric(string $sourceCode): Metrics // @phpstan-ignore-next-line if (\is_iterable($nodeClasses)) { foreach ($nodeClasses as $class) { + if ($class->metrics === null) { + continue; + } + if ((int)$class->metrics['coveredmethods'] === (int)$class->metrics['methods']) { $coveredClasses++; }