From 73dba719b50b68ac33a72bbb0ec6b024302b6216 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 6 Sep 2020 10:07:04 +0200 Subject: [PATCH 01/14] encode newlines in GithubErrorFormatter --- src/Command/ErrorFormatter/GithubErrorFormatter.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Command/ErrorFormatter/GithubErrorFormatter.php b/src/Command/ErrorFormatter/GithubErrorFormatter.php index a0260efbcd..42a08294be 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); From 224a50b8cd5882fdffb45f1a28bc268cf5cacdd7 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 6 Sep 2020 10:41:14 +0200 Subject: [PATCH 02/14] added test --- src/Testing/ErrorFormatterTestCase.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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([ From 6128cf9b0ab945f6e1fdb12ec0d40932867e3c79 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 6 Sep 2020 10:47:25 +0200 Subject: [PATCH 03/14] fix expectations --- .../ErrorFormatter/BaselineNeonErrorFormatterTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/PHPStan/Command/ErrorFormatter/BaselineNeonErrorFormatterTest.php b/tests/PHPStan/Command/ErrorFormatter/BaselineNeonErrorFormatterTest.php index 0a747a9c39..b4642a53d8 100644 --- a/tests/PHPStan/Command/ErrorFormatter/BaselineNeonErrorFormatterTest.php +++ b/tests/PHPStan/Command/ErrorFormatter/BaselineNeonErrorFormatterTest.php @@ -57,7 +57,7 @@ public function dataFormatterOutputProvider(): iterable 'path' => 'foo.php', ], [ - 'message' => '#^Bar$#', + 'message' => "#^Bar\nBar2$#", 'count' => 1, 'path' => 'foo.php', ], @@ -71,12 +71,12 @@ public function dataFormatterOutputProvider(): iterable 2, [ [ - 'message' => '#^Bar$#', + 'message' => "#^Bar\nBar2$#", 'count' => 1, 'path' => 'folder with unicode 😃/file name with "spaces" and unicode 😃.php', ], [ - 'message' => '#^Foo$#', + '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', ], From e7088a16f597e8a431c5f88ebad1894d4bf33798 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 6 Sep 2020 10:48:23 +0200 Subject: [PATCH 04/14] fix excpectations --- .../ErrorFormatter/CheckstyleErrorFormatterTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 ' - + - + From 9b023997e325d35f2420028003a075bd6c7b557e Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 6 Sep 2020 10:51:17 +0200 Subject: [PATCH 05/14] fix expectations --- .../ErrorFormatter/GitlabFormatterTest.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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": { From 3c875ec570820b31a8ff13cbb294b6fe331a18cd Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 6 Sep 2020 10:54:00 +0200 Subject: [PATCH 06/14] fix expectations --- .../ErrorFormatter/GithubErrorFormatterTest.php | 12 ++++++++---- .../ErrorFormatter/JsonErrorFormatterTest.php | 8 ++++---- 2 files changed, 12 insertions(+), 8 deletions(-) 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/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 } From d808e1fd21c63f474b37438c4549ea072df76275 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 6 Sep 2020 10:54:50 +0200 Subject: [PATCH 07/14] fix expectations --- .../Command/ErrorFormatter/JunitErrorFormatterTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 - + From 5fdb3b8996260367469599368adb3c1a40995ac4 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 6 Sep 2020 10:56:46 +0200 Subject: [PATCH 08/14] fix expectations --- .../Command/ErrorFormatter/BaselineNeonErrorFormatterTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/PHPStan/Command/ErrorFormatter/BaselineNeonErrorFormatterTest.php b/tests/PHPStan/Command/ErrorFormatter/BaselineNeonErrorFormatterTest.php index b4642a53d8..ee24ca2d6f 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', ], From d97fe2ecb4f4c1e70cd0b8300b4c62c89894c8c8 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 6 Sep 2020 11:01:41 +0200 Subject: [PATCH 09/14] fix expectations --- .../Command/ErrorFormatter/TableErrorFormatterTest.php | 4 ++++ 1 file changed, 4 insertions(+) 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 ------ --------- -- ---------------------- From 70ba6f66cb3e06e5a818738059fabe80ec724e3a Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 6 Sep 2020 11:02:23 +0200 Subject: [PATCH 10/14] fix expectations --- .../Command/ErrorFormatter/TeamcityErrorFormatterTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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\'] ', From 90667779e1805d9679388bbe1ff7446477650040 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 6 Sep 2020 11:03:46 +0200 Subject: [PATCH 11/14] fix expectations --- .../Command/ErrorFormatter/RawErrorFormatterTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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", ]; } From 5c324853c7d7ab12680c12c81c63d7c66848a7c8 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 6 Sep 2020 11:13:11 +0200 Subject: [PATCH 12/14] fix typo --- .../Command/ErrorFormatter/BaselineNeonErrorFormatterTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/PHPStan/Command/ErrorFormatter/BaselineNeonErrorFormatterTest.php b/tests/PHPStan/Command/ErrorFormatter/BaselineNeonErrorFormatterTest.php index ee24ca2d6f..2434032542 100644 --- a/tests/PHPStan/Command/ErrorFormatter/BaselineNeonErrorFormatterTest.php +++ b/tests/PHPStan/Command/ErrorFormatter/BaselineNeonErrorFormatterTest.php @@ -76,7 +76,7 @@ public function dataFormatterOutputProvider(): iterable 'path' => 'folder with unicode 😃/file name with "spaces" and unicode 😃.php', ], [ - 'message' => "#^Bar\nBar2$#", + 'message' => '#^Foo$#', 'count' => 1, 'path' => 'folder with unicode 😃/file name with "spaces" and unicode 😃.php', ], From 953c886668141656dd70ea749666e14ff0871a21 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 6 Sep 2020 11:19:58 +0200 Subject: [PATCH 13/14] same fix for other places --- src/Command/ErrorFormatter/GithubErrorFormatter.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Command/ErrorFormatter/GithubErrorFormatter.php b/src/Command/ErrorFormatter/GithubErrorFormatter.php index 42a08294be..a3c70de6f1 100644 --- a/src/Command/ErrorFormatter/GithubErrorFormatter.php +++ b/src/Command/ErrorFormatter/GithubErrorFormatter.php @@ -52,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); @@ -59,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); From b30a2634a19f71a4edfd8afc67cab7af2b20a68e Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 6 Sep 2020 11:22:29 +0200 Subject: [PATCH 14/14] fix CS --- src/Command/ErrorFormatter/GithubErrorFormatter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Command/ErrorFormatter/GithubErrorFormatter.php b/src/Command/ErrorFormatter/GithubErrorFormatter.php index a3c70de6f1..0743b26d3a 100644 --- a/src/Command/ErrorFormatter/GithubErrorFormatter.php +++ b/src/Command/ErrorFormatter/GithubErrorFormatter.php @@ -66,7 +66,7 @@ public function formatErrors(AnalysisResult $analysisResult, Output $output): in // 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);