File tree Expand file tree Collapse file tree 1 file changed +22
-4
lines changed
src/PhpGitHooks/Infrastructure/PhpCsFixer Expand file tree Collapse file tree 1 file changed +22
-4
lines changed Original file line number Diff line number Diff line change 44
55use IgnoreFiles \IgnoreFiles ;
66use PhpGitHooks \Application \Message \MessageConfigData ;
7+ use PhpGitHooks \Command \BadJobLogo ;
78use PhpGitHooks \Command \OutputHandlerInterface ;
89use PhpGitHooks \Infrastructure \Common \InteractiveToolInterface ;
910use PhpGitHooks \Infrastructure \Common \ToolHandler ;
@@ -75,10 +76,11 @@ public function run(array $messages)
7576 }
7677
7778 if ($ errors ) {
78- $ this ->writeOutputError (
79- new PhpCsFixerException (implode ('' , $ errors )),
80- $ messages [MessageConfigData::KEY_ERROR_MESSAGE ]
81- );
79+ $ this ->outputHandler ->setError ($ this ->getErrors ($ errors ));
80+ $ this ->output ->writeln ($ this ->outputHandler ->getError ());
81+ $ this ->output ->writeln (BadJobLogo::paint ($ messages [MessageConfigData::KEY_ERROR_MESSAGE ]));
82+
83+ throw new PhpCsFixerException ();
8284 }
8385
8486 $ this ->output ->writeln ($ this ->outputHandler ->getSuccessfulStepMessage ());
@@ -116,4 +118,20 @@ public function setLevels(array $levels)
116118 {
117119 $ this ->levels = $ levels ;
118120 }
121+
122+ /**
123+ * @param array $errors
124+ *
125+ * @return null|string
126+ */
127+ private function getErrors (array $ errors )
128+ {
129+ $ errorText = null ;
130+
131+ foreach ($ errors as $ error ) {
132+ $ errorText .= trim ($ error )."\n" ;
133+ }
134+
135+ return $ errorText ;
136+ }
119137}
You can’t perform that action at this time.
0 commit comments