diff --git a/src/ChangesReporting/Output/GitHubOutputFormatter.php b/src/ChangesReporting/Output/GitHubOutputFormatter.php index 9fe6d6d43e..30b6b0496c 100644 --- a/src/ChangesReporting/Output/GitHubOutputFormatter.php +++ b/src/ChangesReporting/Output/GitHubOutputFormatter.php @@ -125,10 +125,10 @@ private function sanitizeAnnotationProperties(array $annotationProperties): stri // TODO: Should be removed once github will have fixed it issue. unset($annotationProperties['endLine']); - $nonNullProperties = array_filter($annotationProperties, static fn ($value) => $value !== null); + $nonNullProperties = array_filter($annotationProperties, static fn ($value): bool => $value !== null); $sanitizedProperties = array_map( - fn ($key, $value) => sprintf('%s=%s', $key, $this->sanitizeAnnotationProperty($value)), + fn ($key, $value): string => sprintf('%s=%s', $key, $this->sanitizeAnnotationProperty($value)), array_keys($nonNullProperties), $nonNullProperties ); @@ -144,8 +144,6 @@ private function sanitizeAnnotationProperty(string|int|null $value): string $value = (string) $value; - $value = str_replace(['%', "\r", "\n", ':', ','], ['%25', '%0D', '%0A', '%3A', '%2C'], $value); - - return $value; + return str_replace(['%', "\r", "\n", ':', ','], ['%25', '%0D', '%0A', '%3A', '%2C'], $value); } } diff --git a/src/ChangesReporting/Output/JUnitOutputFormatter.php b/src/ChangesReporting/Output/JUnitOutputFormatter.php index d2e2af0f72..978295b751 100644 --- a/src/ChangesReporting/Output/JUnitOutputFormatter.php +++ b/src/ChangesReporting/Output/JUnitOutputFormatter.php @@ -75,27 +75,27 @@ private function appendSystemErrors( ProcessResult $processResult, Configuration $configuration, DOMDocument $domDocument, - DOMElement $xmlTestSuite, + DOMElement $domElement, ): void { - if (count($processResult->getSystemErrors()) === 0) { + if ($processResult->getSystemErrors() === []) { return; } - foreach ($processResult->getSystemErrors() as $error) { + foreach ($processResult->getSystemErrors() as $systemError) { $filePath = $configuration->isReportingWithRealPath() - ? ($error->getAbsoluteFilePath() ?? '') - : ($error->getRelativeFilePath() ?? '') + ? ($systemError->getAbsoluteFilePath() ?? '') + : ($systemError->getRelativeFilePath() ?? '') ; - $xmlError = $domDocument->createElement(self::XML_ELEMENT_ERROR, $error->getMessage()); + $xmlError = $domDocument->createElement(self::XML_ELEMENT_ERROR, $systemError->getMessage()); $xmlError->setAttribute(self::XML_ATTRIBUTE_TYPE, 'Error'); $xmlTestCase = $domDocument->createElement(self::XML_ELEMENT_TESTCASE); $xmlTestCase->setAttribute(self::XML_ATTRIBUTE_FILE, $filePath); - $xmlTestCase->setAttribute(self::XML_ATTRIBUTE_NAME, $filePath . ':' . $error->getLine()); + $xmlTestCase->setAttribute(self::XML_ATTRIBUTE_NAME, $filePath . ':' . $systemError->getLine()); $xmlTestCase->appendChild($xmlError); - $xmlTestSuite->appendChild($xmlTestCase); + $domElement->appendChild($xmlTestCase); } } @@ -103,9 +103,9 @@ private function appendFileDiffs( ProcessResult $processResult, Configuration $configuration, DOMDocument $domDocument, - DOMElement $xmlTestSuite, + DOMElement $domElement, ): void { - if (count($processResult->getFileDiffs()) === 0) { + if ($processResult->getFileDiffs() === []) { return; } @@ -128,7 +128,7 @@ private function appendFileDiffs( $xmlTestCase->setAttribute(self::XML_ATTRIBUTE_NAME, $filePath . ':' . $fileDiff->getFirstLineNumber()); $xmlTestCase->appendChild($xmlError); - $xmlTestSuite->appendChild($xmlTestCase); + $domElement->appendChild($xmlTestCase); } } } diff --git a/src/ValueObject/Error/SystemError.php b/src/ValueObject/Error/SystemError.php index 162ca20929..4722858079 100644 --- a/src/ValueObject/Error/SystemError.php +++ b/src/ValueObject/Error/SystemError.php @@ -82,8 +82,8 @@ public function getRectorClass(): ?string public function getRectorShortClass(): ?string { - $rectorClass = $this->getRectorClass(); - if ($rectorClass) { + $rectorClass = $this->rectorClass; + if ($rectorClass !== null && $rectorClass !== '' && $rectorClass !== '0') { return (string) Strings::after($rectorClass, '\\', -1); }