Skip to content

Commit 5bbc5ed

Browse files
authored
replace PHP_EOL with \n when used with symfony console (#7174)
1 parent bda2d3c commit 5bbc5ed

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

src/ChangesReporting/Output/ConsoleOutputFormatter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,15 @@ private function reportErrors(array $errors, bool $absoluteFilePath): void
115115
foreach ($errors as $error) {
116116
$errorMessage = $error->getMessage();
117117
$errorMessage = $this->normalizePathsToRelativeWithLine($errorMessage);
118+
$errorMessage = str_replace("\r\n", "\n", $errorMessage);
118119

119120
$filePath = $absoluteFilePath ? $error->getAbsoluteFilePath() : $error->getRelativeFilePath();
120121

121122
$message = sprintf(
122123
'Could not process %s%s, due to: %s"%s".',
123124
$filePath !== null ? '"' . $filePath . '" file' : 'some files',
124125
$error->getRectorClass() !== null ? ' by "' . $error->getRectorClass() . '"' : '',
125-
PHP_EOL,
126+
"\n",
126127
$errorMessage
127128
);
128129

src/Console/Command/ProcessCommand.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
119119
if ($setAndRulesDuplicatedRegistrations !== []) {
120120
$this->symfonyStyle->warning(sprintf(
121121
'These rules are registered in both sets and "withRules()". Remove them from "withRules()" to avoid duplications: %s* %s',
122-
PHP_EOL . PHP_EOL,
123-
implode(' * ', $setAndRulesDuplicatedRegistrations) . PHP_EOL
122+
"\n\n",
123+
implode(' * ', $setAndRulesDuplicatedRegistrations) . "\n"
124124
));
125125
}
126126

@@ -145,8 +145,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
145145
$isSingular ? 'es' : '',
146146
$isSingular ? '' : 's',
147147
$isSingular ? 'y' : 'ies',
148-
PHP_EOL . PHP_EOL . ' - ',
149-
implode(PHP_EOL . ' - ', $paths)
148+
"\n\n" . ' - ',
149+
implode("\n" . ' - ', $paths)
150150
)
151151
);
152152

@@ -253,7 +253,7 @@ private function reportLevelOverflow(LevelOverflow $levelOverflow): void
253253
$levelOverflow->getConfigurationName(),
254254
$levelOverflow->getRuleCount(),
255255
$levelOverflow->getLevel(),
256-
PHP_EOL,
256+
"\n",
257257
$suggestedSetMethod,
258258
));
259259
}

src/Console/Command/SetupCICommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
4242

4343
$noteMessage = sprintf(
4444
'Only GitHub and GitLab are currently supported.%s Contribute your CI template to Rector to make this work: %s',
45-
PHP_EOL,
45+
"\n",
4646
'https://github.com/rectorphp/rector-src/'
4747
);
4848

src/NodeTypeResolver/DependencyInjection/PHPStanServicesFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function __construct()
5858
} catch (Throwable $throwable) {
5959
if ($throwable->getMessage() === "File 'phar://phpstan.phar/conf/bleedingEdge.neon' is missing or is not readable.") {
6060
$symfonyStyle = new SymfonyStyle(new ArrayInput([]), new ConsoleOutput());
61-
$symfonyStyle->error(sprintf(self::INVALID_BLEEDING_EDGE_PATH_MESSAGE, $throwable->getMessage()));
61+
$symfonyStyle->error(str_replace("\r\n", "\n", sprintf(self::INVALID_BLEEDING_EDGE_PATH_MESSAGE, $throwable->getMessage())));
6262

6363
exit(-1);
6464
}

src/Reporting/MissConfigurationReporter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function reportVendorInPaths(array $filePaths): void
5555

5656
$this->symfonyStyle->warning(sprintf(
5757
'Rector has detected a "/vendor" directory in your configured paths. If this is Composer\'s vendor directory, this is not necessary as it will be autoloaded. Scanning the Composer /vendor directory will cause Rector to run much slower and possibly with errors.%sRemove "/vendor" from Rector paths and run again.',
58-
PHP_EOL . PHP_EOL
58+
"\n\n"
5959
));
6060

6161
sleep(3);
@@ -69,12 +69,12 @@ public function reportStartWithShortOpenTag(): void
6969
}
7070

7171
$suffix = count($files) > 1 ? 's were' : ' was';
72-
$fileList = implode(PHP_EOL, $files);
72+
$fileList = implode("\n", $files);
7373

7474
$this->symfonyStyle->warning(sprintf(
7575
'The following file%s skipped as starting with short open tag. Migrate to long open PHP tag first: %s%s',
7676
$suffix,
77-
PHP_EOL . PHP_EOL,
77+
"\n\n",
7878
$fileList
7979
));
8080

0 commit comments

Comments
 (0)