Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
35 changes: 19 additions & 16 deletions src/ChangesReporting/Output/JUnitOutputFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,17 @@
public const NAME = 'junit';

private const XML_ATTRIBUTE_FILE = 'file';

private const XML_ATTRIBUTE_NAME = 'name';

private const XML_ATTRIBUTE_TYPE = 'type';

private const XML_ELEMENT_TESTSUITES = 'testsuites';

private const XML_ELEMENT_TESTSUITE = 'testsuite';

private const XML_ELEMENT_TESTCASE = 'testcase';

private const XML_ELEMENT_ERROR = 'error';

public function __construct(
Expand All @@ -42,7 +47,7 @@ public function getName(): string

public function report(ProcessResult $processResult, Configuration $configuration): void
{
if (!extension_loaded('dom')) {
if (! extension_loaded('dom')) {
$this->symfonyStyle->warning(
'The "dom" extension is not loaded. The rector could not generate a response in the JUnit format',
);
Expand Down Expand Up @@ -70,39 +75,37 @@ private function appendSystemErrors(
ProcessResult $processResult,
Configuration $configuration,
DOMDocument $domDocument,
DOMElement $xmlTestSuite,
): void
{
if (count($processResult->getSystemErrors()) === 0) {
DOMElement $domElement,
): void {
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,
): void
{
if (count($processResult->getFileDiffs()) === 0) {
DOMElement $domElement,
): void {
if ($processResult->getFileDiffs() === []) {
return;
}

Expand All @@ -125,7 +128,7 @@ private function appendFileDiffs(
$xmlTestCase->setAttribute(self::XML_ATTRIBUTE_NAME, $filePath . ':' . $fileDiff->getFirstLineNumber());
$xmlTestCase->appendChild($xmlError);

$xmlTestSuite->appendChild($xmlTestCase);
$domElement->appendChild($xmlTestCase);
}
}
}
6 changes: 0 additions & 6 deletions src/Config/Level/CodeQualityLevel.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@
use Rector\CodeQuality\Rector\Ternary\SwitchNegatedTernaryRector;
use Rector\CodeQuality\Rector\Ternary\TernaryEmptyArrayArrayDimFetchToCoalesceRector;
use Rector\CodeQuality\Rector\Ternary\UnnecessaryTernaryExpressionRector;
use Rector\CodingStyle\Rector\ClassMethod\FuncGetArgsToVariadicParamRector;
use Rector\CodingStyle\Rector\FuncCall\CallUserFuncToMethodCallRector;
use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector;
use Rector\Contract\Rector\RectorInterface;
use Rector\Php52\Rector\Property\VarToPublicPropertyRector;
use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector;
Expand Down Expand Up @@ -154,10 +151,7 @@ final class CodeQualityLevel
SwitchNegatedTernaryRector::class,
SingularSwitchToIfRector::class,
SimplifyIfNullableReturnRector::class,
FuncGetArgsToVariadicParamRector::class,
CallUserFuncToMethodCallRector::class,
CallUserFuncWithArrowFunctionToInlineRector::class,
CountArrayToEmptyArrayComparisonRector::class,
FlipTypeControlToUseExclusiveTypeRector::class,
InlineArrayReturnAssignRector::class,
InlineIsAInstanceOfRector::class,
Expand Down
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