diff --git a/src/Command/ErrorFormatter/GithubErrorFormatter.php b/src/Command/ErrorFormatter/GithubErrorFormatter.php
index a0260efbcd..0743b26d3a 100644
--- a/src/Command/ErrorFormatter/GithubErrorFormatter.php
+++ b/src/Command/ErrorFormatter/GithubErrorFormatter.php
@@ -41,6 +41,9 @@ public function formatErrors(AnalysisResult $analysisResult, Output $output): in
});
$message = $fileSpecificError->getMessage();
+ // newlines need to be encoded
+ // see https://github.com/actions/starter-workflows/issues/68#issuecomment-581479448
+ $message = str_replace("\n", '%0A', $message);
$line = sprintf('::error %s::%s', implode(',', $metas), $message);
@@ -49,6 +52,10 @@ public function formatErrors(AnalysisResult $analysisResult, Output $output): in
}
foreach ($analysisResult->getNotFileSpecificErrors() as $notFileSpecificError) {
+ // newlines need to be encoded
+ // see https://github.com/actions/starter-workflows/issues/68#issuecomment-581479448
+ $notFileSpecificError = str_replace("\n", '%0A', $notFileSpecificError);
+
$line = sprintf('::error ::%s', $notFileSpecificError);
$output->writeRaw($line);
@@ -56,6 +63,10 @@ public function formatErrors(AnalysisResult $analysisResult, Output $output): in
}
foreach ($analysisResult->getWarnings() as $warning) {
+ // newlines need to be encoded
+ // see https://github.com/actions/starter-workflows/issues/68#issuecomment-581479448
+ $warning = str_replace("\n", '%0A', $warning);
+
$line = sprintf('::warning ::%s', $warning);
$output->writeRaw($line);
diff --git a/src/Testing/ErrorFormatterTestCase.php b/src/Testing/ErrorFormatterTestCase.php
index 3485680fbd..01c48c9c4d 100644
--- a/src/Testing/ErrorFormatterTestCase.php
+++ b/src/Testing/ErrorFormatterTestCase.php
@@ -67,8 +67,8 @@ protected function getAnalysisResult(int $numFileErrors, int $numGenericErrors):
$fileErrors = array_slice([
new Error('Foo', self::DIRECTORY_PATH . '/folder with unicode 😃/file name with "spaces" and unicode 😃.php', 4),
new Error('Foo', self::DIRECTORY_PATH . '/foo.php', 1),
- new Error('Bar', self::DIRECTORY_PATH . '/foo.php', 5),
- new Error('Bar', self::DIRECTORY_PATH . '/folder with unicode 😃/file name with "spaces" and unicode 😃.php', 2),
+ new Error("Bar\nBar2", self::DIRECTORY_PATH . '/foo.php', 5),
+ new Error("Bar\nBar2", self::DIRECTORY_PATH . '/folder with unicode 😃/file name with "spaces" and unicode 😃.php', 2),
], 0, $numFileErrors);
$genericErrors = array_slice([
diff --git a/tests/PHPStan/Command/ErrorFormatter/BaselineNeonErrorFormatterTest.php b/tests/PHPStan/Command/ErrorFormatter/BaselineNeonErrorFormatterTest.php
index 0a747a9c39..2434032542 100644
--- a/tests/PHPStan/Command/ErrorFormatter/BaselineNeonErrorFormatterTest.php
+++ b/tests/PHPStan/Command/ErrorFormatter/BaselineNeonErrorFormatterTest.php
@@ -42,7 +42,7 @@ public function dataFormatterOutputProvider(): iterable
0,
[
[
- 'message' => '#^Bar$#',
+ 'message' => "#^Bar\nBar2$#",
'count' => 1,
'path' => 'folder with unicode 😃/file name with "spaces" and unicode 😃.php',
],
@@ -57,7 +57,7 @@ public function dataFormatterOutputProvider(): iterable
'path' => 'foo.php',
],
[
- 'message' => '#^Bar$#',
+ 'message' => "#^Bar\nBar2$#",
'count' => 1,
'path' => 'foo.php',
],
@@ -71,7 +71,7 @@ public function dataFormatterOutputProvider(): iterable
2,
[
[
- 'message' => '#^Bar$#',
+ 'message' => "#^Bar\nBar2$#",
'count' => 1,
'path' => 'folder with unicode 😃/file name with "spaces" and unicode 😃.php',
],
@@ -86,7 +86,7 @@ public function dataFormatterOutputProvider(): iterable
'path' => 'foo.php',
],
[
- 'message' => '#^Bar$#',
+ 'message' => "#^Bar\nBar2$#",
'count' => 1,
'path' => 'foo.php',
],
diff --git a/tests/PHPStan/Command/ErrorFormatter/CheckstyleErrorFormatterTest.php b/tests/PHPStan/Command/ErrorFormatter/CheckstyleErrorFormatterTest.php
index a1c9dde04a..ab868c23a8 100644
--- a/tests/PHPStan/Command/ErrorFormatter/CheckstyleErrorFormatterTest.php
+++ b/tests/PHPStan/Command/ErrorFormatter/CheckstyleErrorFormatterTest.php
@@ -59,12 +59,12 @@ public function dataFormatterOutputProvider(): iterable
'
-
+
-
+
',
@@ -93,12 +93,12 @@ public function dataFormatterOutputProvider(): iterable
'
-
+
-
+
diff --git a/tests/PHPStan/Command/ErrorFormatter/GithubErrorFormatterTest.php b/tests/PHPStan/Command/ErrorFormatter/GithubErrorFormatterTest.php
index 411ff15f50..ac48603aa3 100644
--- a/tests/PHPStan/Command/ErrorFormatter/GithubErrorFormatterTest.php
+++ b/tests/PHPStan/Command/ErrorFormatter/GithubErrorFormatterTest.php
@@ -64,6 +64,7 @@ public function dataFormatterOutputProvider(): iterable
Line folder with unicode 😃/file name with "spaces" and unicode 😃.php
------ -----------------------------------------------------------------
2 Bar
+ Bar2
4 Foo
------ -----------------------------------------------------------------
@@ -72,14 +73,15 @@ public function dataFormatterOutputProvider(): iterable
------ ---------
1 Foo
5 Bar
+ Bar2
------ ---------
[ERROR] Found 4 errors
-::error file=folder with unicode 😃/file name with "spaces" and unicode 😃.php,line=2,col=0::Bar
+::error file=folder with unicode 😃/file name with "spaces" and unicode 😃.php,line=2,col=0::Bar%0ABar2
::error file=folder with unicode 😃/file name with "spaces" and unicode 😃.php,line=4,col=0::Foo
::error file=foo.php,line=1,col=0::Foo
-::error file=foo.php,line=5,col=0::Bar
+::error file=foo.php,line=5,col=0::Bar%0ABar2
',
];
@@ -111,6 +113,7 @@ public function dataFormatterOutputProvider(): iterable
Line folder with unicode 😃/file name with "spaces" and unicode 😃.php
------ -----------------------------------------------------------------
2 Bar
+ Bar2
4 Foo
------ -----------------------------------------------------------------
@@ -119,6 +122,7 @@ public function dataFormatterOutputProvider(): iterable
------ ---------
1 Foo
5 Bar
+ Bar2
------ ---------
-- ----------------------
@@ -130,10 +134,10 @@ public function dataFormatterOutputProvider(): iterable
[ERROR] Found 6 errors
-::error file=folder with unicode 😃/file name with "spaces" and unicode 😃.php,line=2,col=0::Bar
+::error file=folder with unicode 😃/file name with "spaces" and unicode 😃.php,line=2,col=0::Bar%0ABar2
::error file=folder with unicode 😃/file name with "spaces" and unicode 😃.php,line=4,col=0::Foo
::error file=foo.php,line=1,col=0::Foo
-::error file=foo.php,line=5,col=0::Bar
+::error file=foo.php,line=5,col=0::Bar%0ABar2
::error ::first generic error
::error ::second generic error
',
diff --git a/tests/PHPStan/Command/ErrorFormatter/GitlabFormatterTest.php b/tests/PHPStan/Command/ErrorFormatter/GitlabFormatterTest.php
index 3a045443f6..c746f4f1e2 100644
--- a/tests/PHPStan/Command/ErrorFormatter/GitlabFormatterTest.php
+++ b/tests/PHPStan/Command/ErrorFormatter/GitlabFormatterTest.php
@@ -63,8 +63,8 @@ public function dataFormatterOutputProvider(): iterable
0,
'[
{
- "description": "Bar",
- "fingerprint": "d112f1651daa597592156359ef28c9a4b81a8a96dbded1c0f1009f5bbc2bda97",
+ "description": "Bar\nBar2",
+ "fingerprint": "034b4afbfb347494c14e396ed8327692f58be4cd27e8aff5f19f4194934db7c9",
"location": {
"path": "with space/and unicode 😃/project/folder with unicode 😃/file name with \"spaces\" and unicode 😃.php",
"lines": {
@@ -93,8 +93,8 @@ public function dataFormatterOutputProvider(): iterable
}
},
{
- "description": "Bar",
- "fingerprint": "d83022ee5bc7c71b6a4988ec47a377c9998b929d12d86fc71b745ec2b04c81e5",
+ "description": "Bar\nBar2",
+ "fingerprint": "829f6c782152fdac840b39208c5b519d18e51bff2c601b6197812fffb8bcd9ed",
"location": {
"path": "with space/and unicode \ud83d\ude03/project/foo.php",
"lines": {
@@ -141,8 +141,8 @@ public function dataFormatterOutputProvider(): iterable
2,
'[
{
- "description": "Bar",
- "fingerprint": "d112f1651daa597592156359ef28c9a4b81a8a96dbded1c0f1009f5bbc2bda97",
+ "description": "Bar\nBar2",
+ "fingerprint": "034b4afbfb347494c14e396ed8327692f58be4cd27e8aff5f19f4194934db7c9",
"location": {
"path": "with space/and unicode \ud83d\ude03/project/folder with unicode \ud83d\ude03/file name with \"spaces\" and unicode \ud83d\ude03.php",
"lines": {
@@ -171,8 +171,8 @@ public function dataFormatterOutputProvider(): iterable
}
},
{
- "description": "Bar",
- "fingerprint": "d83022ee5bc7c71b6a4988ec47a377c9998b929d12d86fc71b745ec2b04c81e5",
+ "description": "Bar\nBar2",
+ "fingerprint": "829f6c782152fdac840b39208c5b519d18e51bff2c601b6197812fffb8bcd9ed",
"location": {
"path": "with space/and unicode \ud83d\ude03/project/foo.php",
"lines": {
diff --git a/tests/PHPStan/Command/ErrorFormatter/JsonErrorFormatterTest.php b/tests/PHPStan/Command/ErrorFormatter/JsonErrorFormatterTest.php
index dd6a3e82e6..48d2b2e209 100644
--- a/tests/PHPStan/Command/ErrorFormatter/JsonErrorFormatterTest.php
+++ b/tests/PHPStan/Command/ErrorFormatter/JsonErrorFormatterTest.php
@@ -86,7 +86,7 @@ public function dataFormatterOutputProvider(): iterable
"errors":2,
"messages":[
{
- "message": "Bar",
+ "message": "Bar\nBar2",
"line": 2,
"ignorable": true
},
@@ -106,7 +106,7 @@ public function dataFormatterOutputProvider(): iterable
"ignorable": true
},
{
- "message": "Bar",
+ "message": "Bar\nBar2",
"line": 5,
"ignorable": true
}
@@ -152,7 +152,7 @@ public function dataFormatterOutputProvider(): iterable
"errors":2,
"messages":[
{
- "message": "Bar",
+ "message": "Bar\nBar2",
"line": 2,
"ignorable": true
},
@@ -172,7 +172,7 @@ public function dataFormatterOutputProvider(): iterable
"ignorable": true
},
{
- "message": "Bar",
+ "message": "Bar\nBar2",
"line": 5,
"ignorable": true
}
diff --git a/tests/PHPStan/Command/ErrorFormatter/JunitErrorFormatterTest.php b/tests/PHPStan/Command/ErrorFormatter/JunitErrorFormatterTest.php
index b3495ca738..5fd4814d94 100644
--- a/tests/PHPStan/Command/ErrorFormatter/JunitErrorFormatterTest.php
+++ b/tests/PHPStan/Command/ErrorFormatter/JunitErrorFormatterTest.php
@@ -69,7 +69,7 @@ public function dataFormatterOutputProvider(): Generator
'
-
+
@@ -78,7 +78,7 @@ public function dataFormatterOutputProvider(): Generator
-
+
',
@@ -107,7 +107,7 @@ public function dataFormatterOutputProvider(): Generator
'
-
+
@@ -116,7 +116,7 @@ public function dataFormatterOutputProvider(): Generator
-
+
diff --git a/tests/PHPStan/Command/ErrorFormatter/RawErrorFormatterTest.php b/tests/PHPStan/Command/ErrorFormatter/RawErrorFormatterTest.php
index 023f7d0164..0f35ad8fda 100644
--- a/tests/PHPStan/Command/ErrorFormatter/RawErrorFormatterTest.php
+++ b/tests/PHPStan/Command/ErrorFormatter/RawErrorFormatterTest.php
@@ -38,10 +38,10 @@ public function dataFormatterOutputProvider(): iterable
1,
4,
0,
- '/data/folder/with space/and unicode 😃/project/folder with unicode 😃/file name with "spaces" and unicode 😃.php:2:Bar' . "\n" .
+ '/data/folder/with space/and unicode 😃/project/folder with unicode 😃/file name with "spaces" and unicode 😃.php:2:Bar' . "\nBar2\n" .
'/data/folder/with space/and unicode 😃/project/folder with unicode 😃/file name with "spaces" and unicode 😃.php:4:Foo' . "\n" .
'/data/folder/with space/and unicode 😃/project/foo.php:1:Foo' . "\n" .
- '/data/folder/with space/and unicode 😃/project/foo.php:5:Bar' . "\n",
+ '/data/folder/with space/and unicode 😃/project/foo.php:5:Bar' . "\nBar2\n",
];
yield [
@@ -60,10 +60,10 @@ public function dataFormatterOutputProvider(): iterable
2,
'?:?:first generic error' . "\n" .
'?:?:second generic error' . "\n" .
- '/data/folder/with space/and unicode 😃/project/folder with unicode 😃/file name with "spaces" and unicode 😃.php:2:Bar' . "\n" .
+ '/data/folder/with space/and unicode 😃/project/folder with unicode 😃/file name with "spaces" and unicode 😃.php:2:Bar' . "\nBar2\n" .
'/data/folder/with space/and unicode 😃/project/folder with unicode 😃/file name with "spaces" and unicode 😃.php:4:Foo' . "\n" .
'/data/folder/with space/and unicode 😃/project/foo.php:1:Foo' . "\n" .
- '/data/folder/with space/and unicode 😃/project/foo.php:5:Bar' . "\n",
+ '/data/folder/with space/and unicode 😃/project/foo.php:5:Bar' . "\nBar2\n",
];
}
diff --git a/tests/PHPStan/Command/ErrorFormatter/TableErrorFormatterTest.php b/tests/PHPStan/Command/ErrorFormatter/TableErrorFormatterTest.php
index a54bb5c90e..c1670e9cfb 100644
--- a/tests/PHPStan/Command/ErrorFormatter/TableErrorFormatterTest.php
+++ b/tests/PHPStan/Command/ErrorFormatter/TableErrorFormatterTest.php
@@ -62,6 +62,7 @@ public function dataFormatterOutputProvider(): iterable
Line folder with unicode 😃/file name with "spaces" and unicode 😃.php
------ -----------------------------------------------------------------
2 Bar
+ Bar2
4 Foo
------ -----------------------------------------------------------------
@@ -70,6 +71,7 @@ public function dataFormatterOutputProvider(): iterable
------ ---------
1 Foo
5 Bar
+ Bar2
------ ---------
[ERROR] Found 4 errors
@@ -103,6 +105,7 @@ public function dataFormatterOutputProvider(): iterable
Line folder with unicode 😃/file name with "spaces" and unicode 😃.php
------ -----------------------------------------------------------------
2 Bar
+ Bar2
4 Foo
------ -----------------------------------------------------------------
@@ -111,6 +114,7 @@ public function dataFormatterOutputProvider(): iterable
------ ---------
1 Foo
5 Bar
+ Bar2
------ ---------
-- ----------------------
diff --git a/tests/PHPStan/Command/ErrorFormatter/TeamcityErrorFormatterTest.php b/tests/PHPStan/Command/ErrorFormatter/TeamcityErrorFormatterTest.php
index 69e64405cc..68b6c6dc0c 100644
--- a/tests/PHPStan/Command/ErrorFormatter/TeamcityErrorFormatterTest.php
+++ b/tests/PHPStan/Command/ErrorFormatter/TeamcityErrorFormatterTest.php
@@ -44,10 +44,10 @@ public function dataFormatterOutputProvider(): iterable
4,
0,
'##teamcity[inspectionType id=\'phpstan\' name=\'phpstan\' category=\'phpstan\' description=\'phpstan Inspection\']
-##teamcity[inspection typeId=\'phpstan\' message=\'Bar\' file=\'folder with unicode 😃/file name with "spaces" and unicode 😃.php\' line=\'2\' SEVERITY=\'ERROR\' ignorable=\'1\' tip=\'\']
+##teamcity[inspection typeId=\'phpstan\' message=\'Bar||nBar2\' file=\'folder with unicode 😃/file name with "spaces" and unicode 😃.php\' line=\'2\' SEVERITY=\'ERROR\' ignorable=\'1\' tip=\'\']
##teamcity[inspection typeId=\'phpstan\' message=\'Foo\' file=\'folder with unicode 😃/file name with "spaces" and unicode 😃.php\' line=\'4\' SEVERITY=\'ERROR\' ignorable=\'1\' tip=\'\']
##teamcity[inspection typeId=\'phpstan\' message=\'Foo\' file=\'foo.php\' line=\'1\' SEVERITY=\'ERROR\' ignorable=\'1\' tip=\'\']
-##teamcity[inspection typeId=\'phpstan\' message=\'Bar\' file=\'foo.php\' line=\'5\' SEVERITY=\'ERROR\' ignorable=\'1\' tip=\'\']
+##teamcity[inspection typeId=\'phpstan\' message=\'Bar||nBar2\' file=\'foo.php\' line=\'5\' SEVERITY=\'ERROR\' ignorable=\'1\' tip=\'\']
',
];
@@ -68,10 +68,10 @@ public function dataFormatterOutputProvider(): iterable
4,
2,
'##teamcity[inspectionType id=\'phpstan\' name=\'phpstan\' category=\'phpstan\' description=\'phpstan Inspection\']
-##teamcity[inspection typeId=\'phpstan\' message=\'Bar\' file=\'folder with unicode 😃/file name with "spaces" and unicode 😃.php\' line=\'2\' SEVERITY=\'ERROR\' ignorable=\'1\' tip=\'\']
+##teamcity[inspection typeId=\'phpstan\' message=\'Bar||nBar2\' file=\'folder with unicode 😃/file name with "spaces" and unicode 😃.php\' line=\'2\' SEVERITY=\'ERROR\' ignorable=\'1\' tip=\'\']
##teamcity[inspection typeId=\'phpstan\' message=\'Foo\' file=\'folder with unicode 😃/file name with "spaces" and unicode 😃.php\' line=\'4\' SEVERITY=\'ERROR\' ignorable=\'1\' tip=\'\']
##teamcity[inspection typeId=\'phpstan\' message=\'Foo\' file=\'foo.php\' line=\'1\' SEVERITY=\'ERROR\' ignorable=\'1\' tip=\'\']
-##teamcity[inspection typeId=\'phpstan\' message=\'Bar\' file=\'foo.php\' line=\'5\' SEVERITY=\'ERROR\' ignorable=\'1\' tip=\'\']
+##teamcity[inspection typeId=\'phpstan\' message=\'Bar||nBar2\' file=\'foo.php\' line=\'5\' SEVERITY=\'ERROR\' ignorable=\'1\' tip=\'\']
##teamcity[inspection typeId=\'phpstan\' message=\'first generic error\' file=\'./\' SEVERITY=\'ERROR\']
##teamcity[inspection typeId=\'phpstan\' message=\'second generic error\' file=\'./\' SEVERITY=\'ERROR\']
',