11<?php
22
3+ use PHP_CodeSniffer \Files \FileList ;
4+ use PHP_CodeSniffer \Reporter ;
5+ use PHP_CodeSniffer \Util \Timing ;
6+ use PHP_CodeSniffer \Config ;
37use Stringy \Stringy as S ;
48
59class Runner
@@ -82,7 +86,7 @@ public function run($files)
8286 try {
8387 $ resultFile = tempnam (sys_get_temp_dir (), 'phpcodesniffer ' );
8488
85- $ extra_config_options = array ('--report=json ' , ' --report-file= ' . $ resultFile );
89+ $ extra_config_options = array ('--report-json= ' . $ resultFile );
8690
8791 if (isset ($ this ->config ['config ' ]['standard ' ])) {
8892 $ extra_config_options [] = '--standard= ' . $ this ->config ['config ' ]['standard ' ];
@@ -106,13 +110,25 @@ public function run($files)
106110 ob_start ();
107111
108112 // setup the code sniffer
109- $ cli = new PHP_CodeSniffer_CLI ();
110- $ cli ->setCommandLineValues ($ extra_config_options );
113+ $ runner = new \PHP_CodeSniffer \Runner ();
114+ $ runner ->config = new Config ($ extra_config_options );
115+ $ runner ->init ();
116+
117+ // setup the code sniffer
118+ $ runner ->reporter = new Reporter ($ runner ->config );
111119
112120 // start the code sniffing
113- PHP_CodeSniffer_Reporting::startTiming ();
114- $ cli ->checkRequirements ();
115- $ cli ->process ();
121+ Timing::startTiming ();
122+ $ runner ->checkRequirements ();
123+
124+ $ todo = new FileList ($ runner ->config , $ runner ->ruleset );
125+ foreach ($ todo as $ path => $ file ) {
126+ if ($ file ->ignored === false ) {
127+ $ runner ->processFile ($ file );
128+ }
129+ }
130+
131+ $ runner ->reporter ->printReports ();
116132
117133 // clean up the output buffers (might be more that one)
118134 while (ob_get_level ()) {
0 commit comments