1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Responsible for running PHPCS and PHPCBF. |
4
|
|
|
* |
5
|
|
|
* After creating an object of this class, you probably just want to |
6
|
|
|
* call runPHPCS() or runPHPCBF(). |
7
|
|
|
* |
8
|
|
|
* @author Greg Sherwood <[email protected]> |
9
|
|
|
* @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) |
10
|
|
|
* @license https://github.com/squizlabs/Symplify\PHP7_CodeSniffer/blob/master/licence.txt BSD Licence |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace Symplify\PHP7_CodeSniffer; |
14
|
|
|
|
15
|
|
|
use Symplify\PHP7_CodeSniffer\Files\FileList; |
16
|
|
|
use Symplify\PHP7_CodeSniffer\Files\File; |
17
|
|
|
use Symplify\PHP7_CodeSniffer\Files\DummyFile; |
18
|
|
|
use Symplify\PHP7_CodeSniffer\Util\Cache; |
19
|
|
|
use Symplify\PHP7_CodeSniffer\Util\Common; |
20
|
|
|
use Symplify\PHP7_CodeSniffer\Exceptions\RuntimeException; |
21
|
|
|
|
22
|
|
|
class Runner |
23
|
|
|
{ |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* The config data for the run. |
27
|
|
|
* |
28
|
|
|
* @var \Symplify\PHP7_CodeSniffer\Config |
29
|
|
|
*/ |
30
|
|
|
public $config = null; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* The ruleset used for the run. |
34
|
|
|
* |
35
|
|
|
* @var \Symplify\PHP7_CodeSniffer\Ruleset |
36
|
|
|
*/ |
37
|
|
|
public $ruleset = null; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* The reporter used for generating reports after the run. |
41
|
|
|
* |
42
|
|
|
* @var \Symplify\PHP7_CodeSniffer\Reporter |
43
|
|
|
*/ |
44
|
|
|
public $reporter = null; |
45
|
|
|
|
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Run the PHPCS script. |
49
|
|
|
* |
50
|
|
|
* @return array |
51
|
|
|
*/ |
52
|
|
|
public function runPHPCS() |
53
|
|
|
{ |
54
|
|
|
Util\Timing::startTiming(); |
55
|
|
|
|
56
|
|
|
if (defined('PHP_CodeSniffer_CBF') === false) { |
57
|
|
|
define('PHP_CodeSniffer_CBF', false); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
// Creating the Config object populates it with all required settings |
61
|
|
|
// based on the CLI arguments provided to the script and any config |
62
|
|
|
// values the user has set. |
63
|
|
|
$this->config = new Config(); |
64
|
|
|
|
65
|
|
|
// Init the run and load the rulesets to set additional config vars. |
66
|
|
|
$this->init(); |
67
|
|
|
|
68
|
|
|
// Print a list of sniffs in each of the supplied standards. |
69
|
|
|
// We fudge the config here so that each standard is explained in isolation. |
70
|
|
|
if ($this->config->explain === true) { |
|
|
|
|
71
|
|
|
$standards = $this->config->standards; |
|
|
|
|
72
|
|
|
foreach ($standards as $standard) { |
73
|
|
|
$this->config->standards = array($standard); |
|
|
|
|
74
|
|
|
$ruleset = new Ruleset($this->config); |
75
|
|
|
$ruleset->explain(); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
exit(0); |
|
|
|
|
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
// Disable caching if we are processing STDIN as we can't be 100% |
82
|
|
|
// sure where the file came from or if it will change in the future. |
83
|
|
|
if ($this->config->stdin === true) { |
|
|
|
|
84
|
|
|
$this->config->cache = false; |
|
|
|
|
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
$numErrors = $this->run(); |
88
|
|
|
|
89
|
|
|
// Print all the reports for this run. |
90
|
|
|
$toScreen = $this->reporter->printReports(); |
91
|
|
|
|
92
|
|
|
// Only print timer output if no reports were |
93
|
|
|
// printed to the screen so we don't put additional output |
94
|
|
|
// in something like an XML report. If we are printing to screen, |
95
|
|
|
// the report types would have already worked out who should |
96
|
|
|
// print the timer info. |
97
|
|
|
if (($toScreen === false |
98
|
|
|
|| (($this->reporter->totalErrors + $this->reporter->totalWarnings) === 0 && $this->config->showProgress === true)) |
|
|
|
|
99
|
|
|
) { |
100
|
|
|
Util\Timing::printRunTime(); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
if ($numErrors === 0) { |
104
|
|
|
exit(0); |
|
|
|
|
105
|
|
|
} else { |
106
|
|
|
exit(1); |
|
|
|
|
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
}//end runPHPCS() |
110
|
|
|
|
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* Run the PHPCBF script. |
114
|
|
|
* |
115
|
|
|
* @return array |
116
|
|
|
*/ |
117
|
|
|
public function runPHPCBF() |
118
|
|
|
{ |
119
|
|
|
if (defined('PHP_CodeSniffer_CBF') === false) { |
120
|
|
|
define('PHP_CodeSniffer_CBF', true); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
Util\Timing::startTiming(); |
124
|
|
|
|
125
|
|
|
// Creating the Config object populates it with all required settings |
126
|
|
|
// based on the CLI arguments provided to the script and any config |
127
|
|
|
// values the user has set. |
128
|
|
|
$this->config = new Config(); |
129
|
|
|
|
130
|
|
|
// Init the run and load the rulesets to set additional config vars. |
131
|
|
|
$this->init(); |
132
|
|
|
|
133
|
|
|
// Override some of the command line settings that might break the fixes. |
134
|
|
|
$this->config->verbosity = 0; |
|
|
|
|
135
|
|
|
$this->config->showProgress = false; |
|
|
|
|
136
|
|
|
$this->config->explain = false; |
|
|
|
|
137
|
|
|
$this->config->cache = false; |
|
|
|
|
138
|
|
|
$this->config->showSources = false; |
|
|
|
|
139
|
|
|
$this->config->recordErrors = false; |
|
|
|
|
140
|
|
|
$this->config->reports = array('cbf' => null); |
|
|
|
|
141
|
|
|
|
142
|
|
|
// If a standard tries to set command line arguments itself, some |
143
|
|
|
// may be blocked because PHPCBF is running, so stop the script |
144
|
|
|
// dying if any are found. |
145
|
|
|
$this->config->dieOnUnknownArg = false; |
146
|
|
|
|
147
|
|
|
$numErrors = $this->run(); |
148
|
|
|
$this->reporter->printReports(); |
149
|
|
|
|
150
|
|
|
echo PHP_EOL; |
151
|
|
|
Util\Timing::printRunTime(); |
152
|
|
|
|
153
|
|
|
// We can't tell exactly how many errors were fixed, but |
154
|
|
|
// we know how many errors were found. |
155
|
|
|
exit($numErrors); |
|
|
|
|
156
|
|
|
|
157
|
|
|
}//end runPHPCBF() |
158
|
|
|
|
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* Init the rulesets and other high-level settings. |
162
|
|
|
* |
163
|
|
|
* @return void |
164
|
|
|
*/ |
165
|
|
|
private function init() |
166
|
|
|
{ |
167
|
|
|
// Ensure this option is enabled or else line endings will not always |
168
|
|
|
// be detected properly for files created on a Mac with the /r line ending. |
169
|
|
|
ini_set('auto_detect_line_endings', true); |
170
|
|
|
|
171
|
|
|
// Check that the standards are valid. |
172
|
|
|
foreach ($this->config->standards as $standard) { |
|
|
|
|
173
|
|
|
if (Util\Standards::isInstalledStandard($standard) === false) { |
174
|
|
|
// They didn't select a valid coding standard, so help them |
175
|
|
|
// out by letting them know which standards are installed. |
176
|
|
|
echo 'ERROR: the "'.$standard.'" coding standard is not installed. '; |
177
|
|
|
Util\Standards::printInstalledStandards(); |
178
|
|
|
exit(2); |
|
|
|
|
179
|
|
|
} |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
// Saves passing the Config object into other objects that only need |
183
|
|
|
// the verbostity flag for deubg output. |
184
|
|
|
if (defined('PHP_CodeSniffer_VERBOSITY') === false) { |
185
|
|
|
define('PHP_CodeSniffer_VERBOSITY', $this->config->verbosity); |
|
|
|
|
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
// Create this class so it is autoloaded and sets up a bunch |
189
|
|
|
// of Symplify\PHP7_CodeSniffer-specific token type constants. |
190
|
|
|
$tokens = new Util\Tokens(); |
|
|
|
|
191
|
|
|
|
192
|
|
|
// The ruleset contains all the information about how the files |
193
|
|
|
// should be checked and/or fixed. |
194
|
|
|
$this->ruleset = new Ruleset($this->config); |
195
|
|
|
|
196
|
|
|
}//end init() |
197
|
|
|
|
198
|
|
|
|
199
|
|
|
/** |
200
|
|
|
* Performs the run. |
201
|
|
|
* |
202
|
|
|
* @return int The number of errors and warnings found. |
203
|
|
|
*/ |
204
|
|
|
private function run() |
205
|
|
|
{ |
206
|
|
|
// The class that manages all reporters for the run. |
207
|
|
|
$this->reporter = new Reporter($this->config); |
208
|
|
|
|
209
|
|
|
if ($this->config->stdin === true) { |
|
|
|
|
210
|
|
|
$fileContents = $this->config->stdinContent; |
|
|
|
|
211
|
|
|
if ($fileContents === null) { |
212
|
|
|
$handle = fopen('php://stdin', 'r'); |
213
|
|
|
stream_set_blocking($handle, true); |
214
|
|
|
$fileContents = stream_get_contents($handle); |
215
|
|
|
fclose($handle); |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
$todo = new FileList($this->config, $this->ruleset); |
219
|
|
|
$dummy = new DummyFile($fileContents, $this->ruleset, $this->config); |
220
|
|
|
$todo->addFile($dummy->path, $dummy); |
221
|
|
|
|
222
|
|
|
$numFiles = 1; |
223
|
|
|
} else { |
224
|
|
|
if (empty($this->config->files) === true) { |
|
|
|
|
225
|
|
|
echo 'ERROR: You must supply at least one file or directory to process.'.PHP_EOL.PHP_EOL; |
226
|
|
|
$this->config->printUsage(); |
227
|
|
|
exit(0); |
|
|
|
|
228
|
|
|
} |
229
|
|
|
|
230
|
|
|
if (PHP_CodeSniffer_VERBOSITY > 0) { |
231
|
|
|
echo 'Creating file list... '; |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
$todo = new FileList($this->config, $this->ruleset); |
235
|
|
|
$numFiles = count($todo); |
236
|
|
|
|
237
|
|
|
if (PHP_CodeSniffer_VERBOSITY > 0) { |
238
|
|
|
echo "DONE ($numFiles files in queue)".PHP_EOL; |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
if ($this->config->cache === true) { |
|
|
|
|
242
|
|
|
if (PHP_CodeSniffer_VERBOSITY > 0) { |
243
|
|
|
echo 'Loading cache... '; |
244
|
|
|
} |
245
|
|
|
|
246
|
|
|
Cache::load($this->ruleset, $this->config); |
247
|
|
|
|
248
|
|
|
if (PHP_CodeSniffer_VERBOSITY > 0) { |
249
|
|
|
$size = Cache::getSize(); |
250
|
|
|
echo "DONE ($size files in cache)".PHP_EOL; |
251
|
|
|
} |
252
|
|
|
} |
253
|
|
|
}//end if |
254
|
|
|
|
255
|
|
|
$numProcessed = 0; |
256
|
|
|
$dots = 0; |
257
|
|
|
$maxLength = strlen($numFiles); |
258
|
|
|
$lastDir = ''; |
259
|
|
|
$childProcs = array(); |
|
|
|
|
260
|
|
|
|
261
|
|
|
// Turn all sniff errors into exceptions. |
262
|
|
|
set_error_handler(array($this, 'handleErrors')); |
263
|
|
|
|
264
|
|
|
// Running normally. |
265
|
|
|
foreach ($todo as $path => $file) { |
266
|
|
|
$currDir = dirname($path); |
267
|
|
|
if ($lastDir !== $currDir) { |
268
|
|
|
if (PHP_CodeSniffer_VERBOSITY > 0 || (PHP_CodeSniffer_CBF === true && $this->config->stdin === false)) { |
|
|
|
|
269
|
|
|
echo 'Changing into directory '.Common::stripBasepath($currDir, $this->config->basepath).PHP_EOL; |
|
|
|
|
270
|
|
|
} |
271
|
|
|
|
272
|
|
|
$lastDir = $currDir; |
273
|
|
|
} |
274
|
|
|
|
275
|
|
|
$this->processFile($file); |
276
|
|
|
|
277
|
|
|
$numProcessed++; |
278
|
|
|
|
279
|
|
|
if (PHP_CodeSniffer_VERBOSITY > 0 |
280
|
|
|
|| $this->config->interactive === true |
|
|
|
|
281
|
|
|
|| $this->config->showProgress === false |
|
|
|
|
282
|
|
|
) { |
283
|
|
|
continue; |
284
|
|
|
} |
285
|
|
|
|
286
|
|
|
// Show progress information. |
287
|
|
|
if ($file->ignored === true) { |
288
|
|
|
echo 'S'; |
289
|
|
|
} else { |
290
|
|
|
$errors = $file->getErrorCount(); |
291
|
|
|
$warnings = $file->getWarningCount(); |
292
|
|
View Code Duplication |
if ($errors > 0) { |
|
|
|
|
293
|
|
|
if ($this->config->colors === true) { |
|
|
|
|
294
|
|
|
echo "\033[31m"; |
295
|
|
|
} |
296
|
|
|
|
297
|
|
|
echo 'E'; |
298
|
|
|
} else if ($warnings > 0) { |
299
|
|
|
if ($this->config->colors === true) { |
|
|
|
|
300
|
|
|
echo "\033[33m"; |
301
|
|
|
} |
302
|
|
|
|
303
|
|
|
echo 'W'; |
304
|
|
|
} else { |
305
|
|
|
echo '.'; |
306
|
|
|
} |
307
|
|
|
|
308
|
|
|
if ($this->config->colors === true) { |
|
|
|
|
309
|
|
|
echo "\033[0m"; |
310
|
|
|
} |
311
|
|
|
}//end if |
312
|
|
|
|
313
|
|
|
$dots++; |
314
|
|
View Code Duplication |
if ($dots === 60) { |
|
|
|
|
315
|
|
|
$padding = ($maxLength - strlen($numProcessed)); |
316
|
|
|
echo str_repeat(' ', $padding); |
317
|
|
|
$percent = round(($numProcessed / $numFiles) * 100); |
318
|
|
|
echo " $numProcessed / $numFiles ($percent%)".PHP_EOL; |
319
|
|
|
$dots = 0; |
320
|
|
|
} |
321
|
|
|
}//end foreach |
322
|
|
|
|
323
|
|
|
restore_error_handler(); |
324
|
|
|
|
325
|
|
|
if (PHP_CodeSniffer_VERBOSITY === 0 |
326
|
|
|
&& $this->config->interactive === false |
|
|
|
|
327
|
|
|
&& $this->config->showProgress === true |
|
|
|
|
328
|
|
|
) { |
329
|
|
|
echo PHP_EOL.PHP_EOL; |
330
|
|
|
} |
331
|
|
|
|
332
|
|
|
if ($this->config->cache === true) { |
|
|
|
|
333
|
|
|
Cache::save(); |
334
|
|
|
} |
335
|
|
|
|
336
|
|
|
$ignoreWarnings = Config::getConfigData('ignore_warnings_on_exit'); |
337
|
|
|
$ignoreErrors = Config::getConfigData('ignore_errors_on_exit'); |
338
|
|
|
|
339
|
|
|
$return = ($this->reporter->totalErrors + $this->reporter->totalWarnings); |
340
|
|
|
if ($ignoreErrors !== null) { |
341
|
|
|
$ignoreErrors = (bool) $ignoreErrors; |
342
|
|
|
if ($ignoreErrors === true) { |
343
|
|
|
$return -= $this->reporter->totalErrors; |
344
|
|
|
} |
345
|
|
|
} |
346
|
|
|
|
347
|
|
|
if ($ignoreWarnings !== null) { |
348
|
|
|
$ignoreWarnings = (bool) $ignoreWarnings; |
349
|
|
|
if ($ignoreWarnings === true) { |
350
|
|
|
$return -= $this->reporter->totalWarnings; |
351
|
|
|
} |
352
|
|
|
} |
353
|
|
|
|
354
|
|
|
return $return; |
355
|
|
|
|
356
|
|
|
}//end run() |
357
|
|
|
|
358
|
|
|
|
359
|
|
|
/** |
360
|
|
|
* Converts all PHP errors into exceptions. |
361
|
|
|
* |
362
|
|
|
* This method forces a sniff to stop processing if it is not |
363
|
|
|
* able to handle a specific piece of code, instead of continuing |
364
|
|
|
* and potentially getting into a loop. |
365
|
|
|
* |
366
|
|
|
* @param int $code The level of error raised. |
367
|
|
|
* @param string $message The error message. |
368
|
|
|
* @param string $file The path of the file that raised the error. |
369
|
|
|
* @param int $line The line number the error was raised at. |
370
|
|
|
* |
371
|
|
|
* @return void |
372
|
|
|
*/ |
373
|
|
|
public function handleErrors($code, $message, $file, $line) |
374
|
|
|
{ |
375
|
|
|
throw new RuntimeException("$message in $file on line $line"); |
376
|
|
|
|
377
|
|
|
}//end handleErrors() |
378
|
|
|
|
379
|
|
|
|
380
|
|
|
/** |
381
|
|
|
* Processes a single file, including checking and fixing. |
382
|
|
|
* |
383
|
|
|
* @param \Symplify\PHP7_CodeSniffer\Files\File $file The file to be processed. |
384
|
|
|
* |
385
|
|
|
* @return void |
386
|
|
|
*/ |
387
|
|
|
private function processFile($file) |
388
|
|
|
{ |
389
|
|
|
if (PHP_CodeSniffer_VERBOSITY > 0 || (PHP_CodeSniffer_CBF === true && $this->config->stdin === false)) { |
|
|
|
|
390
|
|
|
$startTime = microtime(true); |
391
|
|
|
echo 'Processing '.basename($file->path).' '; |
392
|
|
|
if (PHP_CodeSniffer_VERBOSITY > 1) { |
393
|
|
|
echo PHP_EOL; |
394
|
|
|
} |
395
|
|
|
} |
396
|
|
|
|
397
|
|
|
try { |
398
|
|
|
$file->process(); |
399
|
|
|
|
400
|
|
|
if (PHP_CodeSniffer_VERBOSITY > 0 |
401
|
|
|
|| (PHP_CodeSniffer_CBF === true && $this->config->stdin === false) |
|
|
|
|
402
|
|
|
) { |
403
|
|
|
$timeTaken = ((microtime(true) - $startTime) * 1000); |
|
|
|
|
404
|
|
|
if ($timeTaken < 1000) { |
405
|
|
|
$timeTaken = round($timeTaken); |
406
|
|
|
echo "DONE in {$timeTaken}ms"; |
407
|
|
|
} else { |
408
|
|
|
$timeTaken = round(($timeTaken / 1000), 2); |
409
|
|
|
echo "DONE in $timeTaken secs"; |
410
|
|
|
} |
411
|
|
|
|
412
|
|
|
if (PHP_CodeSniffer_CBF === true) { |
413
|
|
|
$errors = $file->getFixableCount(); |
414
|
|
|
echo " ($errors fixable violations)".PHP_EOL; |
415
|
|
|
} else { |
416
|
|
|
$errors = $file->getErrorCount(); |
417
|
|
|
$warnings = $file->getWarningCount(); |
418
|
|
|
echo " ($errors errors, $warnings warnings)".PHP_EOL; |
419
|
|
|
} |
420
|
|
|
} |
421
|
|
|
} catch (\Exception $e) { |
422
|
|
|
$error = 'An error occurred during processing; checking has been aborted. The error message was: '.$e->getMessage(); |
423
|
|
|
$file->addErrorOnLine($error, 1, 'Internal.Exception'); |
424
|
|
|
}//end try |
425
|
|
|
|
426
|
|
|
$this->reporter->cacheFileReport($file, $this->config); |
|
|
|
|
427
|
|
|
|
428
|
|
|
// Clean up the file to save (a lot of) memory. |
429
|
|
|
$file->cleanUp(); |
430
|
|
|
|
431
|
|
|
if ($this->config->interactive === true) { |
|
|
|
|
432
|
|
|
/* |
433
|
|
|
Running interactively. |
434
|
|
|
Print the error report for the current file and then wait for user input. |
435
|
|
|
*/ |
436
|
|
|
|
437
|
|
|
// Get current violations and then clear the list to make sure |
438
|
|
|
// we only print violations for a single file each time. |
439
|
|
|
$numErrors = null; |
440
|
|
|
while ($numErrors !== 0) { |
441
|
|
|
$numErrors = ($file->getErrorCount() + $file->getWarningCount()); |
442
|
|
|
if ($numErrors === 0) { |
443
|
|
|
continue; |
444
|
|
|
} |
445
|
|
|
|
446
|
|
|
$this->reporter->printReport('full'); |
447
|
|
|
|
448
|
|
|
echo '<ENTER> to recheck, [s] to skip or [q] to quit : '; |
449
|
|
|
$input = fgets(STDIN); |
450
|
|
|
$input = trim($input); |
451
|
|
|
|
452
|
|
|
switch ($input) { |
453
|
|
|
case 's': |
454
|
|
|
break(2); |
455
|
|
|
case 'q': |
456
|
|
|
exit(0); |
|
|
|
|
457
|
|
|
default: |
458
|
|
|
// Repopulate the sniffs because some of them save their state |
459
|
|
|
// and only clear it when the file changes, but we are rechecking |
460
|
|
|
// the same file. |
461
|
|
|
$file->ruleset->populateTokenListeners(); |
462
|
|
|
$file->reloadContent(); |
463
|
|
|
$file->process(); |
464
|
|
|
$this->reporter->cacheFileReport($file, $this->config); |
|
|
|
|
465
|
|
|
break; |
466
|
|
|
} |
467
|
|
|
}//end while |
468
|
|
|
}//end if |
469
|
|
|
|
470
|
|
|
}//end processFile() |
471
|
|
|
|
472
|
|
|
|
473
|
|
|
/** |
474
|
|
|
* Waits for child processes to complete and cleans up after them. |
475
|
|
|
* |
476
|
|
|
* The reporting information returned by each child process is merged |
477
|
|
|
* into the main reporter class. |
478
|
|
|
* |
479
|
|
|
* @param array $childProcs An array of child processes to wait for. |
480
|
|
|
* |
481
|
|
|
* @return void |
482
|
|
|
*/ |
483
|
|
|
private function processChildProcs($childProcs) |
|
|
|
|
484
|
|
|
{ |
485
|
|
|
$dots = 0; |
486
|
|
|
$numProcessed = 0; |
487
|
|
|
$totalBatches = count($childProcs); |
488
|
|
|
$maxLength = strlen($totalBatches); |
489
|
|
|
|
490
|
|
|
while (count($childProcs) > 0) { |
491
|
|
|
foreach ($childProcs as $key => $procData) { |
492
|
|
|
$res = pcntl_waitpid($procData['pid'], $status, WNOHANG); |
493
|
|
|
if ($res === $procData['pid']) { |
494
|
|
|
if (file_exists($procData['out']) === true) { |
495
|
|
|
include $procData['out']; |
496
|
|
|
if (isset($childOutput) === true) { |
497
|
|
|
$this->reporter->totalFiles += $childOutput['totalFiles']; |
|
|
|
|
498
|
|
|
$this->reporter->totalErrors += $childOutput['totalErrors']; |
499
|
|
|
$this->reporter->totalWarnings += $childOutput['totalWarnings']; |
500
|
|
|
$this->reporter->totalFixable += $childOutput['totalFixable']; |
501
|
|
|
} |
502
|
|
|
|
503
|
|
|
if (isset($debugOutput) === true) { |
504
|
|
|
echo $debugOutput; |
|
|
|
|
505
|
|
|
} |
506
|
|
|
|
507
|
|
|
if (isset($childCache) === true) { |
508
|
|
|
foreach ($childCache as $path => $cache) { |
|
|
|
|
509
|
|
|
Cache::set($path, $cache); |
510
|
|
|
} |
511
|
|
|
} |
512
|
|
|
|
513
|
|
|
unlink($procData['out']); |
514
|
|
|
unset($childProcs[$key]); |
515
|
|
|
|
516
|
|
|
$numProcessed++; |
517
|
|
|
|
518
|
|
|
if (PHP_CodeSniffer_VERBOSITY > 0 |
519
|
|
|
|| $this->config->showProgress === false |
|
|
|
|
520
|
|
|
) { |
521
|
|
|
continue; |
522
|
|
|
} |
523
|
|
|
|
524
|
|
View Code Duplication |
if ($childOutput['totalErrors'] > 0) { |
|
|
|
|
525
|
|
|
if ($this->config->colors === true) { |
|
|
|
|
526
|
|
|
echo "\033[31m"; |
527
|
|
|
} |
528
|
|
|
|
529
|
|
|
echo 'E'; |
530
|
|
|
} else if ($childOutput['totalWarnings'] > 0) { |
531
|
|
|
if ($this->config->colors === true) { |
|
|
|
|
532
|
|
|
echo "\033[33m"; |
533
|
|
|
} |
534
|
|
|
|
535
|
|
|
echo 'W'; |
536
|
|
|
} else { |
537
|
|
|
echo '.'; |
538
|
|
|
} |
539
|
|
|
|
540
|
|
|
if ($this->config->colors === true) { |
|
|
|
|
541
|
|
|
echo "\033[0m"; |
542
|
|
|
} |
543
|
|
|
|
544
|
|
|
$dots++; |
545
|
|
View Code Duplication |
if ($dots === 60) { |
|
|
|
|
546
|
|
|
$padding = ($maxLength - strlen($numProcessed)); |
547
|
|
|
echo str_repeat(' ', $padding); |
548
|
|
|
$percent = round(($numProcessed / $totalBatches) * 100); |
549
|
|
|
echo " $numProcessed / $totalBatches ($percent%)".PHP_EOL; |
550
|
|
|
$dots = 0; |
551
|
|
|
} |
552
|
|
|
}//end if |
553
|
|
|
}//end if |
554
|
|
|
}//end foreach |
555
|
|
|
}//end while |
556
|
|
|
|
557
|
|
|
}//end processChildProcs() |
558
|
|
|
|
559
|
|
|
|
560
|
|
|
}//end class |
561
|
|
|
|
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.