77use PhpcsDiff \Filter \Filter ;
88use PhpcsDiff \Filter \Rule \HasMessagesRule ;
99use PhpcsDiff \Filter \Rule \PhpFileRule ;
10- use PhpcsDiff \Mapper \PhpcsOutputMapper ;
10+ use PhpcsDiff \Mapper \PhpcsViolationsMapper ;
1111
1212class PhpcsDiff
1313{
@@ -168,7 +168,7 @@ public function run()
168168 $ this ->climate ->comment ('Comparing phpcs output with changes lines from git diff. ' );
169169 }
170170
171- $ output = (new PhpcsOutputMapper (
171+ $ violations = (new PhpcsViolationsMapper (
172172 $ changedLinesPerFile ,
173173 getcwd ()
174174 ))->map ($ files );
@@ -177,14 +177,12 @@ public function run()
177177 $ this ->climate ->comment ('Preparing report. ' );
178178 }
179179
180- if (empty ($ output )) {
180+ if (empty ($ violations )) {
181181 $ this ->climate ->info ('No violations to report. ' );
182182 return ;
183183 }
184184
185- $ this ->climate ->flank (strtoupper ('Start of phpcs check ' ), '# ' , 10 )->br ();
186- $ this ->climate ->out (implode (PHP_EOL , $ output ));
187- $ this ->climate ->flank (strtoupper ('End of phpcs check ' ), '# ' , 11 );
185+ $ this ->outputViolations ($ violations );
188186 }
189187
190188 /**
@@ -210,6 +208,18 @@ protected function runPhpcs(array $files = [], $ruleset = 'ruleset.xml')
210208 );
211209 }
212210
211+ /**
212+ * @param array $output
213+ */
214+ protected function outputViolations (array $ output )
215+ {
216+ $ this ->climate ->flank (strtoupper ('Start of phpcs check ' ), '# ' , 10 )->br ();
217+ $ this ->climate ->out (implode (PHP_EOL , $ output ));
218+ $ this ->climate ->flank (strtoupper ('End of phpcs check ' ), '# ' , 11 )->br ();
219+
220+ $ this ->error ('Violations have been reported. ' );
221+ }
222+
213223 /**
214224 * Returns a list of files which are within the diff based on the current branch
215225 *
0 commit comments