Skip to content

Commit

Permalink
[ci-review] Rector Rectify
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Feb 25, 2025
1 parent 8721264 commit aede0e8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
8 changes: 3 additions & 5 deletions src/ChangesReporting/Output/GitHubOutputFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand All @@ -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);
}
}
22 changes: 11 additions & 11 deletions src/ChangesReporting/Output/JUnitOutputFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,37 +75,37 @@ 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);
}
}

private function appendFileDiffs(
ProcessResult $processResult,
Configuration $configuration,
DOMDocument $domDocument,
DOMElement $xmlTestSuite,
DOMElement $domElement,
): void {
if (count($processResult->getFileDiffs()) === 0) {
if ($processResult->getFileDiffs() === []) {
return;
}

Expand All @@ -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);
}
}
}
4 changes: 2 additions & 2 deletions src/ValueObject/Error/SystemError.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit aede0e8

Please sign in to comment.