Completed
Branch new-admin-design (796b82)
by
unknown
18:06 queued 13:57
created
vendor/squizlabs/php_codesniffer/src/Filters/ExactMatch.php 1 patch
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -16,93 +16,93 @@
 block discarded – undo
16 16
 abstract class ExactMatch extends Filter
17 17
 {
18 18
 
19
-    /**
20
-     * A list of files to exclude.
21
-     *
22
-     * @var array
23
-     */
24
-    private $blacklist = null;
25
-
26
-    /**
27
-     * A list of files to include.
28
-     *
29
-     * If the whitelist is empty, only files in the blacklist will be excluded.
30
-     *
31
-     * @var array
32
-     */
33
-    private $whitelist = null;
34
-
35
-
36
-    /**
37
-     * Check whether the current element of the iterator is acceptable.
38
-     *
39
-     * If a file is both blacklisted and whitelisted, it will be deemed unacceptable.
40
-     *
41
-     * @return bool
42
-     */
43
-    public function accept()
44
-    {
45
-        if (parent::accept() === false) {
46
-            return false;
47
-        }
48
-
49
-        if ($this->blacklist === null) {
50
-            $this->blacklist = $this->getblacklist();
51
-        }
52
-
53
-        if ($this->whitelist === null) {
54
-            $this->whitelist = $this->getwhitelist();
55
-        }
56
-
57
-        $filePath = Util\Common::realpath($this->current());
58
-
59
-        // If file is both blacklisted and whitelisted, the blacklist takes precedence.
60
-        if (isset($this->blacklist[$filePath]) === true) {
61
-            return false;
62
-        }
63
-
64
-        if (empty($this->whitelist) === true && empty($this->blacklist) === false) {
65
-            // We are only checking a blacklist, so everything else should be whitelisted.
66
-            return true;
67
-        }
68
-
69
-        return isset($this->whitelist[$filePath]);
70
-
71
-    }//end accept()
72
-
73
-
74
-    /**
75
-     * Returns an iterator for the current entry.
76
-     *
77
-     * Ensures that the blacklist and whitelist are preserved so they don't have
78
-     * to be generated each time.
79
-     *
80
-     * @return \RecursiveIterator
81
-     */
82
-    public function getChildren()
83
-    {
84
-        $children            = parent::getChildren();
85
-        $children->blacklist = $this->blacklist;
86
-        $children->whitelist = $this->whitelist;
87
-        return $children;
88
-
89
-    }//end getChildren()
90
-
91
-
92
-    /**
93
-     * Get a list of blacklisted file paths.
94
-     *
95
-     * @return array
96
-     */
97
-    abstract protected function getBlacklist();
98
-
99
-
100
-    /**
101
-     * Get a list of whitelisted file paths.
102
-     *
103
-     * @return array
104
-     */
105
-    abstract protected function getWhitelist();
19
+	/**
20
+	 * A list of files to exclude.
21
+	 *
22
+	 * @var array
23
+	 */
24
+	private $blacklist = null;
25
+
26
+	/**
27
+	 * A list of files to include.
28
+	 *
29
+	 * If the whitelist is empty, only files in the blacklist will be excluded.
30
+	 *
31
+	 * @var array
32
+	 */
33
+	private $whitelist = null;
34
+
35
+
36
+	/**
37
+	 * Check whether the current element of the iterator is acceptable.
38
+	 *
39
+	 * If a file is both blacklisted and whitelisted, it will be deemed unacceptable.
40
+	 *
41
+	 * @return bool
42
+	 */
43
+	public function accept()
44
+	{
45
+		if (parent::accept() === false) {
46
+			return false;
47
+		}
48
+
49
+		if ($this->blacklist === null) {
50
+			$this->blacklist = $this->getblacklist();
51
+		}
52
+
53
+		if ($this->whitelist === null) {
54
+			$this->whitelist = $this->getwhitelist();
55
+		}
56
+
57
+		$filePath = Util\Common::realpath($this->current());
58
+
59
+		// If file is both blacklisted and whitelisted, the blacklist takes precedence.
60
+		if (isset($this->blacklist[$filePath]) === true) {
61
+			return false;
62
+		}
63
+
64
+		if (empty($this->whitelist) === true && empty($this->blacklist) === false) {
65
+			// We are only checking a blacklist, so everything else should be whitelisted.
66
+			return true;
67
+		}
68
+
69
+		return isset($this->whitelist[$filePath]);
70
+
71
+	}//end accept()
72
+
73
+
74
+	/**
75
+	 * Returns an iterator for the current entry.
76
+	 *
77
+	 * Ensures that the blacklist and whitelist are preserved so they don't have
78
+	 * to be generated each time.
79
+	 *
80
+	 * @return \RecursiveIterator
81
+	 */
82
+	public function getChildren()
83
+	{
84
+		$children            = parent::getChildren();
85
+		$children->blacklist = $this->blacklist;
86
+		$children->whitelist = $this->whitelist;
87
+		return $children;
88
+
89
+	}//end getChildren()
90
+
91
+
92
+	/**
93
+	 * Get a list of blacklisted file paths.
94
+	 *
95
+	 * @return array
96
+	 */
97
+	abstract protected function getBlacklist();
98
+
99
+
100
+	/**
101
+	 * Get a list of whitelisted file paths.
102
+	 *
103
+	 * @return array
104
+	 */
105
+	abstract protected function getWhitelist();
106 106
 
107 107
 
108 108
 }//end class
Please login to merge, or discard this patch.
vendor/squizlabs/php_codesniffer/src/Runner.php 3 patches
Switch Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -632,19 +632,19 @@
 block discarded – undo
632 632
                 $input = trim($input);
633 633
 
634 634
                 switch ($input) {
635
-                case 's':
636
-                    break(2);
637
-                case 'q':
638
-                    throw new DeepExitException('', 0);
639
-                default:
640
-                    // Repopulate the sniffs because some of them save their state
641
-                    // and only clear it when the file changes, but we are rechecking
642
-                    // the same file.
643
-                    $file->ruleset->populateTokenListeners();
644
-                    $file->reloadContent();
645
-                    $file->process();
646
-                    $this->reporter->cacheFileReport($file, $this->config);
647
-                    break;
635
+                	case 's':
636
+                    	break(2);
637
+                	case 'q':
638
+                    	throw new DeepExitException('', 0);
639
+                	default:
640
+                    	// Repopulate the sniffs because some of them save their state
641
+                    	// and only clear it when the file changes, but we are rechecking
642
+                    	// the same file.
643
+                    	$file->ruleset->populateTokenListeners();
644
+                    	$file->reloadContent();
645
+                    	$file->process();
646
+                    	$this->reporter->cacheFileReport($file, $this->config);
647
+                    	break;
648 648
                 }
649 649
             }//end while
650 650
         }//end if
Please login to merge, or discard this patch.
Indentation   +857 added lines, -857 removed lines patch added patch discarded remove patch
@@ -24,867 +24,867 @@
 block discarded – undo
24 24
 class Runner
25 25
 {
26 26
 
27
-    /**
28
-     * The config data for the run.
29
-     *
30
-     * @var \PHP_CodeSniffer\Config
31
-     */
32
-    public $config = null;
33
-
34
-    /**
35
-     * The ruleset used for the run.
36
-     *
37
-     * @var \PHP_CodeSniffer\Ruleset
38
-     */
39
-    public $ruleset = null;
40
-
41
-    /**
42
-     * The reporter used for generating reports after the run.
43
-     *
44
-     * @var \PHP_CodeSniffer\Reporter
45
-     */
46
-    public $reporter = null;
47
-
48
-
49
-    /**
50
-     * Run the PHPCS script.
51
-     *
52
-     * @return array
53
-     */
54
-    public function runPHPCS()
55
-    {
56
-        try {
57
-            Util\Timing::startTiming();
58
-            Runner::checkRequirements();
59
-
60
-            if (defined('PHP_CODESNIFFER_CBF') === false) {
61
-                define('PHP_CODESNIFFER_CBF', false);
62
-            }
63
-
64
-            // Creating the Config object populates it with all required settings
65
-            // based on the CLI arguments provided to the script and any config
66
-            // values the user has set.
67
-            $this->config = new Config();
68
-
69
-            // Init the run and load the rulesets to set additional config vars.
70
-            $this->init();
71
-
72
-            // Print a list of sniffs in each of the supplied standards.
73
-            // We fudge the config here so that each standard is explained in isolation.
74
-            if ($this->config->explain === true) {
75
-                $standards = $this->config->standards;
76
-                foreach ($standards as $standard) {
77
-                    $this->config->standards = [$standard];
78
-                    $ruleset = new Ruleset($this->config);
79
-                    $ruleset->explain();
80
-                }
81
-
82
-                return 0;
83
-            }
84
-
85
-            // Generate documentation for each of the supplied standards.
86
-            if ($this->config->generator !== null) {
87
-                $standards = $this->config->standards;
88
-                foreach ($standards as $standard) {
89
-                    $this->config->standards = [$standard];
90
-                    $ruleset   = new Ruleset($this->config);
91
-                    $class     = 'PHP_CodeSniffer\Generators\\'.$this->config->generator;
92
-                    $generator = new $class($ruleset);
93
-                    $generator->generate();
94
-                }
95
-
96
-                return 0;
97
-            }
98
-
99
-            // Other report formats don't really make sense in interactive mode
100
-            // so we hard-code the full report here and when outputting.
101
-            // We also ensure parallel processing is off because we need to do one file at a time.
102
-            if ($this->config->interactive === true) {
103
-                $this->config->reports      = ['full' => null];
104
-                $this->config->parallel     = 1;
105
-                $this->config->showProgress = false;
106
-            }
107
-
108
-            // Disable caching if we are processing STDIN as we can't be 100%
109
-            // sure where the file came from or if it will change in the future.
110
-            if ($this->config->stdin === true) {
111
-                $this->config->cache = false;
112
-            }
113
-
114
-            $numErrors = $this->run();
115
-
116
-            // Print all the reports for this run.
117
-            $toScreen = $this->reporter->printReports();
118
-
119
-            // Only print timer output if no reports were
120
-            // printed to the screen so we don't put additional output
121
-            // in something like an XML report. If we are printing to screen,
122
-            // the report types would have already worked out who should
123
-            // print the timer info.
124
-            if ($this->config->interactive === false
125
-                && ($toScreen === false
126
-                || (($this->reporter->totalErrors + $this->reporter->totalWarnings) === 0 && $this->config->showProgress === true))
127
-            ) {
128
-                Util\Timing::printRunTime();
129
-            }
130
-        } catch (DeepExitException $e) {
131
-            echo $e->getMessage();
132
-            return $e->getCode();
133
-        }//end try
134
-
135
-        if ($numErrors === 0) {
136
-            // No errors found.
137
-            return 0;
138
-        } else if ($this->reporter->totalFixable === 0) {
139
-            // Errors found, but none of them can be fixed by PHPCBF.
140
-            return 1;
141
-        } else {
142
-            // Errors found, and some can be fixed by PHPCBF.
143
-            return 2;
144
-        }
145
-
146
-    }//end runPHPCS()
147
-
148
-
149
-    /**
150
-     * Run the PHPCBF script.
151
-     *
152
-     * @return array
153
-     */
154
-    public function runPHPCBF()
155
-    {
156
-        if (defined('PHP_CODESNIFFER_CBF') === false) {
157
-            define('PHP_CODESNIFFER_CBF', true);
158
-        }
159
-
160
-        try {
161
-            Util\Timing::startTiming();
162
-            Runner::checkRequirements();
163
-
164
-            // Creating the Config object populates it with all required settings
165
-            // based on the CLI arguments provided to the script and any config
166
-            // values the user has set.
167
-            $this->config = new Config();
168
-
169
-            // When processing STDIN, we can't output anything to the screen
170
-            // or it will end up mixed in with the file output.
171
-            if ($this->config->stdin === true) {
172
-                $this->config->verbosity = 0;
173
-            }
174
-
175
-            // Init the run and load the rulesets to set additional config vars.
176
-            $this->init();
177
-
178
-            // When processing STDIN, we only process one file at a time and
179
-            // we don't process all the way through, so we can't use the parallel
180
-            // running system.
181
-            if ($this->config->stdin === true) {
182
-                $this->config->parallel = 1;
183
-            }
184
-
185
-            // Override some of the command line settings that might break the fixes.
186
-            $this->config->generator    = null;
187
-            $this->config->explain      = false;
188
-            $this->config->interactive  = false;
189
-            $this->config->cache        = false;
190
-            $this->config->showSources  = false;
191
-            $this->config->recordErrors = false;
192
-            $this->config->reportFile   = null;
193
-            $this->config->reports      = ['cbf' => null];
194
-
195
-            // If a standard tries to set command line arguments itself, some
196
-            // may be blocked because PHPCBF is running, so stop the script
197
-            // dying if any are found.
198
-            $this->config->dieOnUnknownArg = false;
199
-
200
-            $this->run();
201
-            $this->reporter->printReports();
202
-
203
-            echo PHP_EOL;
204
-            Util\Timing::printRunTime();
205
-        } catch (DeepExitException $e) {
206
-            echo $e->getMessage();
207
-            return $e->getCode();
208
-        }//end try
209
-
210
-        if ($this->reporter->totalFixed === 0) {
211
-            // Nothing was fixed by PHPCBF.
212
-            if ($this->reporter->totalFixable === 0) {
213
-                // Nothing found that could be fixed.
214
-                return 0;
215
-            } else {
216
-                // Something failed to fix.
217
-                return 2;
218
-            }
219
-        }
220
-
221
-        if ($this->reporter->totalFixable === 0) {
222
-            // PHPCBF fixed all fixable errors.
223
-            return 1;
224
-        }
225
-
226
-        // PHPCBF fixed some fixable errors, but others failed to fix.
227
-        return 2;
228
-
229
-    }//end runPHPCBF()
230
-
231
-
232
-    /**
233
-     * Exits if the minimum requirements of PHP_CodeSniffer are not met.
234
-     *
235
-     * @return void
236
-     * @throws \PHP_CodeSniffer\Exceptions\DeepExitException If the requirements are not met.
237
-     */
238
-    public function checkRequirements()
239
-    {
240
-        // Check the PHP version.
241
-        if (PHP_VERSION_ID < 50400) {
242
-            $error = 'ERROR: PHP_CodeSniffer requires PHP version 5.4.0 or greater.'.PHP_EOL;
243
-            throw new DeepExitException($error, 3);
244
-        }
245
-
246
-        $requiredExtensions = [
247
-            'tokenizer',
248
-            'xmlwriter',
249
-            'SimpleXML',
250
-        ];
251
-        $missingExtensions  = [];
252
-
253
-        foreach ($requiredExtensions as $extension) {
254
-            if (extension_loaded($extension) === false) {
255
-                $missingExtensions[] = $extension;
256
-            }
257
-        }
258
-
259
-        if (empty($missingExtensions) === false) {
260
-            $last      = array_pop($requiredExtensions);
261
-            $required  = implode(', ', $requiredExtensions);
262
-            $required .= ' and '.$last;
263
-
264
-            if (count($missingExtensions) === 1) {
265
-                $missing = $missingExtensions[0];
266
-            } else {
267
-                $last     = array_pop($missingExtensions);
268
-                $missing  = implode(', ', $missingExtensions);
269
-                $missing .= ' and '.$last;
270
-            }
271
-
272
-            $error = 'ERROR: PHP_CodeSniffer requires the %s extensions to be enabled. Please enable %s.'.PHP_EOL;
273
-            $error = sprintf($error, $required, $missing);
274
-            throw new DeepExitException($error, 3);
275
-        }
276
-
277
-    }//end checkRequirements()
278
-
279
-
280
-    /**
281
-     * Init the rulesets and other high-level settings.
282
-     *
283
-     * @return void
284
-     * @throws \PHP_CodeSniffer\Exceptions\DeepExitException If a referenced standard is not installed.
285
-     */
286
-    public function init()
287
-    {
288
-        if (defined('PHP_CODESNIFFER_CBF') === false) {
289
-            define('PHP_CODESNIFFER_CBF', false);
290
-        }
291
-
292
-        // Ensure this option is enabled or else line endings will not always
293
-        // be detected properly for files created on a Mac with the /r line ending.
294
-        @ini_set('auto_detect_line_endings', true);
295
-
296
-        // Disable the PCRE JIT as this caused issues with parallel running.
297
-        ini_set('pcre.jit', false);
298
-
299
-        // Check that the standards are valid.
300
-        foreach ($this->config->standards as $standard) {
301
-            if (Util\Standards::isInstalledStandard($standard) === false) {
302
-                // They didn't select a valid coding standard, so help them
303
-                // out by letting them know which standards are installed.
304
-                $error = 'ERROR: the "'.$standard.'" coding standard is not installed. ';
305
-                ob_start();
306
-                Util\Standards::printInstalledStandards();
307
-                $error .= ob_get_contents();
308
-                ob_end_clean();
309
-                throw new DeepExitException($error, 3);
310
-            }
311
-        }
312
-
313
-        // Saves passing the Config object into other objects that only need
314
-        // the verbosity flag for debug output.
315
-        if (defined('PHP_CODESNIFFER_VERBOSITY') === false) {
316
-            define('PHP_CODESNIFFER_VERBOSITY', $this->config->verbosity);
317
-        }
318
-
319
-        // Create this class so it is autoloaded and sets up a bunch
320
-        // of PHP_CodeSniffer-specific token type constants.
321
-        $tokens = new Util\Tokens();
322
-
323
-        // Allow autoloading of custom files inside installed standards.
324
-        $installedStandards = Standards::getInstalledStandardDetails();
325
-        foreach ($installedStandards as $name => $details) {
326
-            Autoload::addSearchPath($details['path'], $details['namespace']);
327
-        }
328
-
329
-        // The ruleset contains all the information about how the files
330
-        // should be checked and/or fixed.
331
-        try {
332
-            $this->ruleset = new Ruleset($this->config);
333
-        } catch (RuntimeException $e) {
334
-            $error  = 'ERROR: '.$e->getMessage().PHP_EOL.PHP_EOL;
335
-            $error .= $this->config->printShortUsage(true);
336
-            throw new DeepExitException($error, 3);
337
-        }
338
-
339
-    }//end init()
340
-
341
-
342
-    /**
343
-     * Performs the run.
344
-     *
345
-     * @return int The number of errors and warnings found.
346
-     * @throws \PHP_CodeSniffer\Exceptions\DeepExitException
347
-     * @throws \PHP_CodeSniffer\Exceptions\RuntimeException
348
-     */
349
-    private function run()
350
-    {
351
-        // The class that manages all reporters for the run.
352
-        $this->reporter = new Reporter($this->config);
353
-
354
-        // Include bootstrap files.
355
-        foreach ($this->config->bootstrap as $bootstrap) {
356
-            include $bootstrap;
357
-        }
358
-
359
-        if ($this->config->stdin === true) {
360
-            $fileContents = $this->config->stdinContent;
361
-            if ($fileContents === null) {
362
-                $handle = fopen('php://stdin', 'r');
363
-                stream_set_blocking($handle, true);
364
-                $fileContents = stream_get_contents($handle);
365
-                fclose($handle);
366
-            }
367
-
368
-            $todo  = new FileList($this->config, $this->ruleset);
369
-            $dummy = new DummyFile($fileContents, $this->ruleset, $this->config);
370
-            $todo->addFile($dummy->path, $dummy);
371
-        } else {
372
-            if (empty($this->config->files) === true) {
373
-                $error  = 'ERROR: You must supply at least one file or directory to process.'.PHP_EOL.PHP_EOL;
374
-                $error .= $this->config->printShortUsage(true);
375
-                throw new DeepExitException($error, 3);
376
-            }
377
-
378
-            if (PHP_CODESNIFFER_VERBOSITY > 0) {
379
-                echo 'Creating file list... ';
380
-            }
381
-
382
-            $todo = new FileList($this->config, $this->ruleset);
383
-
384
-            if (PHP_CODESNIFFER_VERBOSITY > 0) {
385
-                $numFiles = count($todo);
386
-                echo "DONE ($numFiles files in queue)".PHP_EOL;
387
-            }
388
-
389
-            if ($this->config->cache === true) {
390
-                if (PHP_CODESNIFFER_VERBOSITY > 0) {
391
-                    echo 'Loading cache... ';
392
-                }
393
-
394
-                Cache::load($this->ruleset, $this->config);
395
-
396
-                if (PHP_CODESNIFFER_VERBOSITY > 0) {
397
-                    $size = Cache::getSize();
398
-                    echo "DONE ($size files in cache)".PHP_EOL;
399
-                }
400
-            }
401
-        }//end if
402
-
403
-        // Turn all sniff errors into exceptions.
404
-        set_error_handler([$this, 'handleErrors']);
405
-
406
-        // If verbosity is too high, turn off parallelism so the
407
-        // debug output is clean.
408
-        if (PHP_CODESNIFFER_VERBOSITY > 1) {
409
-            $this->config->parallel = 1;
410
-        }
411
-
412
-        // If the PCNTL extension isn't installed, we can't fork.
413
-        if (function_exists('pcntl_fork') === false) {
414
-            $this->config->parallel = 1;
415
-        }
416
-
417
-        $lastDir  = '';
418
-        $numFiles = count($todo);
419
-
420
-        if ($this->config->parallel === 1) {
421
-            // Running normally.
422
-            $numProcessed = 0;
423
-            foreach ($todo as $path => $file) {
424
-                if ($file->ignored === false) {
425
-                    $currDir = dirname($path);
426
-                    if ($lastDir !== $currDir) {
427
-                        if (PHP_CODESNIFFER_VERBOSITY > 0) {
428
-                            echo 'Changing into directory '.Common::stripBasepath($currDir, $this->config->basepath).PHP_EOL;
429
-                        }
430
-
431
-                        $lastDir = $currDir;
432
-                    }
433
-
434
-                    $this->processFile($file);
435
-                } else if (PHP_CODESNIFFER_VERBOSITY > 0) {
436
-                    echo 'Skipping '.basename($file->path).PHP_EOL;
437
-                }
438
-
439
-                $numProcessed++;
440
-                $this->printProgress($file, $numFiles, $numProcessed);
441
-            }
442
-        } else {
443
-            // Batching and forking.
444
-            $childProcs  = [];
445
-            $numPerBatch = ceil($numFiles / $this->config->parallel);
446
-
447
-            for ($batch = 0; $batch < $this->config->parallel; $batch++) {
448
-                $startAt = ($batch * $numPerBatch);
449
-                if ($startAt >= $numFiles) {
450
-                    break;
451
-                }
452
-
453
-                $endAt = ($startAt + $numPerBatch);
454
-                if ($endAt > $numFiles) {
455
-                    $endAt = $numFiles;
456
-                }
457
-
458
-                $childOutFilename = tempnam(sys_get_temp_dir(), 'phpcs-child');
459
-                $pid = pcntl_fork();
460
-                if ($pid === -1) {
461
-                    throw new RuntimeException('Failed to create child process');
462
-                } else if ($pid !== 0) {
463
-                    $childProcs[] = [
464
-                        'pid' => $pid,
465
-                        'out' => $childOutFilename,
466
-                    ];
467
-                } else {
468
-                    // Move forward to the start of the batch.
469
-                    $todo->rewind();
470
-                    for ($i = 0; $i < $startAt; $i++) {
471
-                        $todo->next();
472
-                    }
473
-
474
-                    // Reset the reporter to make sure only figures from this
475
-                    // file batch are recorded.
476
-                    $this->reporter->totalFiles    = 0;
477
-                    $this->reporter->totalErrors   = 0;
478
-                    $this->reporter->totalWarnings = 0;
479
-                    $this->reporter->totalFixable  = 0;
480
-                    $this->reporter->totalFixed    = 0;
481
-
482
-                    // Process the files.
483
-                    $pathsProcessed = [];
484
-                    ob_start();
485
-                    for ($i = $startAt; $i < $endAt; $i++) {
486
-                        $path = $todo->key();
487
-                        $file = $todo->current();
488
-
489
-                        if ($file->ignored === true) {
490
-                            $todo->next();
491
-                            continue;
492
-                        }
493
-
494
-                        $currDir = dirname($path);
495
-                        if ($lastDir !== $currDir) {
496
-                            if (PHP_CODESNIFFER_VERBOSITY > 0) {
497
-                                echo 'Changing into directory '.Common::stripBasepath($currDir, $this->config->basepath).PHP_EOL;
498
-                            }
499
-
500
-                            $lastDir = $currDir;
501
-                        }
502
-
503
-                        $this->processFile($file);
504
-
505
-                        $pathsProcessed[] = $path;
506
-                        $todo->next();
507
-                    }//end for
508
-
509
-                    $debugOutput = ob_get_contents();
510
-                    ob_end_clean();
511
-
512
-                    // Write information about the run to the filesystem
513
-                    // so it can be picked up by the main process.
514
-                    $childOutput = [
515
-                        'totalFiles'    => $this->reporter->totalFiles,
516
-                        'totalErrors'   => $this->reporter->totalErrors,
517
-                        'totalWarnings' => $this->reporter->totalWarnings,
518
-                        'totalFixable'  => $this->reporter->totalFixable,
519
-                        'totalFixed'    => $this->reporter->totalFixed,
520
-                    ];
521
-
522
-                    $output  = '<'.'?php'."\n".' $childOutput = ';
523
-                    $output .= var_export($childOutput, true);
524
-                    $output .= ";\n\$debugOutput = ";
525
-                    $output .= var_export($debugOutput, true);
526
-
527
-                    if ($this->config->cache === true) {
528
-                        $childCache = [];
529
-                        foreach ($pathsProcessed as $path) {
530
-                            $childCache[$path] = Cache::get($path);
531
-                        }
532
-
533
-                        $output .= ";\n\$childCache = ";
534
-                        $output .= var_export($childCache, true);
535
-                    }
536
-
537
-                    $output .= ";\n?".'>';
538
-                    file_put_contents($childOutFilename, $output);
539
-                    exit($pid);
540
-                }//end if
541
-            }//end for
542
-
543
-            $success = $this->processChildProcs($childProcs);
544
-            if ($success === false) {
545
-                throw new RuntimeException('One or more child processes failed to run');
546
-            }
547
-        }//end if
548
-
549
-        restore_error_handler();
550
-
551
-        if (PHP_CODESNIFFER_VERBOSITY === 0
552
-            && $this->config->interactive === false
553
-            && $this->config->showProgress === true
554
-        ) {
555
-            echo PHP_EOL.PHP_EOL;
556
-        }
557
-
558
-        if ($this->config->cache === true) {
559
-            Cache::save();
560
-        }
561
-
562
-        $ignoreWarnings = Config::getConfigData('ignore_warnings_on_exit');
563
-        $ignoreErrors   = Config::getConfigData('ignore_errors_on_exit');
564
-
565
-        $return = ($this->reporter->totalErrors + $this->reporter->totalWarnings);
566
-        if ($ignoreErrors !== null) {
567
-            $ignoreErrors = (bool) $ignoreErrors;
568
-            if ($ignoreErrors === true) {
569
-                $return -= $this->reporter->totalErrors;
570
-            }
571
-        }
572
-
573
-        if ($ignoreWarnings !== null) {
574
-            $ignoreWarnings = (bool) $ignoreWarnings;
575
-            if ($ignoreWarnings === true) {
576
-                $return -= $this->reporter->totalWarnings;
577
-            }
578
-        }
579
-
580
-        return $return;
581
-
582
-    }//end run()
583
-
584
-
585
-    /**
586
-     * Converts all PHP errors into exceptions.
587
-     *
588
-     * This method forces a sniff to stop processing if it is not
589
-     * able to handle a specific piece of code, instead of continuing
590
-     * and potentially getting into a loop.
591
-     *
592
-     * @param int    $code    The level of error raised.
593
-     * @param string $message The error message.
594
-     * @param string $file    The path of the file that raised the error.
595
-     * @param int    $line    The line number the error was raised at.
596
-     *
597
-     * @return void
598
-     * @throws \PHP_CodeSniffer\Exceptions\RuntimeException
599
-     */
600
-    public function handleErrors($code, $message, $file, $line)
601
-    {
602
-        if ((error_reporting() & $code) === 0) {
603
-            // This type of error is being muted.
604
-            return true;
605
-        }
606
-
607
-        throw new RuntimeException("$message in $file on line $line");
608
-
609
-    }//end handleErrors()
610
-
611
-
612
-    /**
613
-     * Processes a single file, including checking and fixing.
614
-     *
615
-     * @param \PHP_CodeSniffer\Files\File $file The file to be processed.
616
-     *
617
-     * @return void
618
-     * @throws \PHP_CodeSniffer\Exceptions\DeepExitException
619
-     */
620
-    public function processFile($file)
621
-    {
622
-        if (PHP_CODESNIFFER_VERBOSITY > 0) {
623
-            $startTime = microtime(true);
624
-            echo 'Processing '.basename($file->path).' ';
625
-            if (PHP_CODESNIFFER_VERBOSITY > 1) {
626
-                echo PHP_EOL;
627
-            }
628
-        }
629
-
630
-        try {
631
-            $file->process();
632
-
633
-            if (PHP_CODESNIFFER_VERBOSITY > 0) {
634
-                $timeTaken = ((microtime(true) - $startTime) * 1000);
635
-                if ($timeTaken < 1000) {
636
-                    $timeTaken = round($timeTaken);
637
-                    echo "DONE in {$timeTaken}ms";
638
-                } else {
639
-                    $timeTaken = round(($timeTaken / 1000), 2);
640
-                    echo "DONE in $timeTaken secs";
641
-                }
642
-
643
-                if (PHP_CODESNIFFER_CBF === true) {
644
-                    $errors = $file->getFixableCount();
645
-                    echo " ($errors fixable violations)".PHP_EOL;
646
-                } else {
647
-                    $errors   = $file->getErrorCount();
648
-                    $warnings = $file->getWarningCount();
649
-                    echo " ($errors errors, $warnings warnings)".PHP_EOL;
650
-                }
651
-            }
652
-        } catch (\Exception $e) {
653
-            $error = 'An error occurred during processing; checking has been aborted. The error message was: '.$e->getMessage();
654
-            $file->addErrorOnLine($error, 1, 'Internal.Exception');
655
-        }//end try
656
-
657
-        $this->reporter->cacheFileReport($file, $this->config);
658
-
659
-        if ($this->config->interactive === true) {
660
-            /*
27
+	/**
28
+	 * The config data for the run.
29
+	 *
30
+	 * @var \PHP_CodeSniffer\Config
31
+	 */
32
+	public $config = null;
33
+
34
+	/**
35
+	 * The ruleset used for the run.
36
+	 *
37
+	 * @var \PHP_CodeSniffer\Ruleset
38
+	 */
39
+	public $ruleset = null;
40
+
41
+	/**
42
+	 * The reporter used for generating reports after the run.
43
+	 *
44
+	 * @var \PHP_CodeSniffer\Reporter
45
+	 */
46
+	public $reporter = null;
47
+
48
+
49
+	/**
50
+	 * Run the PHPCS script.
51
+	 *
52
+	 * @return array
53
+	 */
54
+	public function runPHPCS()
55
+	{
56
+		try {
57
+			Util\Timing::startTiming();
58
+			Runner::checkRequirements();
59
+
60
+			if (defined('PHP_CODESNIFFER_CBF') === false) {
61
+				define('PHP_CODESNIFFER_CBF', false);
62
+			}
63
+
64
+			// Creating the Config object populates it with all required settings
65
+			// based on the CLI arguments provided to the script and any config
66
+			// values the user has set.
67
+			$this->config = new Config();
68
+
69
+			// Init the run and load the rulesets to set additional config vars.
70
+			$this->init();
71
+
72
+			// Print a list of sniffs in each of the supplied standards.
73
+			// We fudge the config here so that each standard is explained in isolation.
74
+			if ($this->config->explain === true) {
75
+				$standards = $this->config->standards;
76
+				foreach ($standards as $standard) {
77
+					$this->config->standards = [$standard];
78
+					$ruleset = new Ruleset($this->config);
79
+					$ruleset->explain();
80
+				}
81
+
82
+				return 0;
83
+			}
84
+
85
+			// Generate documentation for each of the supplied standards.
86
+			if ($this->config->generator !== null) {
87
+				$standards = $this->config->standards;
88
+				foreach ($standards as $standard) {
89
+					$this->config->standards = [$standard];
90
+					$ruleset   = new Ruleset($this->config);
91
+					$class     = 'PHP_CodeSniffer\Generators\\'.$this->config->generator;
92
+					$generator = new $class($ruleset);
93
+					$generator->generate();
94
+				}
95
+
96
+				return 0;
97
+			}
98
+
99
+			// Other report formats don't really make sense in interactive mode
100
+			// so we hard-code the full report here and when outputting.
101
+			// We also ensure parallel processing is off because we need to do one file at a time.
102
+			if ($this->config->interactive === true) {
103
+				$this->config->reports      = ['full' => null];
104
+				$this->config->parallel     = 1;
105
+				$this->config->showProgress = false;
106
+			}
107
+
108
+			// Disable caching if we are processing STDIN as we can't be 100%
109
+			// sure where the file came from or if it will change in the future.
110
+			if ($this->config->stdin === true) {
111
+				$this->config->cache = false;
112
+			}
113
+
114
+			$numErrors = $this->run();
115
+
116
+			// Print all the reports for this run.
117
+			$toScreen = $this->reporter->printReports();
118
+
119
+			// Only print timer output if no reports were
120
+			// printed to the screen so we don't put additional output
121
+			// in something like an XML report. If we are printing to screen,
122
+			// the report types would have already worked out who should
123
+			// print the timer info.
124
+			if ($this->config->interactive === false
125
+				&& ($toScreen === false
126
+				|| (($this->reporter->totalErrors + $this->reporter->totalWarnings) === 0 && $this->config->showProgress === true))
127
+			) {
128
+				Util\Timing::printRunTime();
129
+			}
130
+		} catch (DeepExitException $e) {
131
+			echo $e->getMessage();
132
+			return $e->getCode();
133
+		}//end try
134
+
135
+		if ($numErrors === 0) {
136
+			// No errors found.
137
+			return 0;
138
+		} else if ($this->reporter->totalFixable === 0) {
139
+			// Errors found, but none of them can be fixed by PHPCBF.
140
+			return 1;
141
+		} else {
142
+			// Errors found, and some can be fixed by PHPCBF.
143
+			return 2;
144
+		}
145
+
146
+	}//end runPHPCS()
147
+
148
+
149
+	/**
150
+	 * Run the PHPCBF script.
151
+	 *
152
+	 * @return array
153
+	 */
154
+	public function runPHPCBF()
155
+	{
156
+		if (defined('PHP_CODESNIFFER_CBF') === false) {
157
+			define('PHP_CODESNIFFER_CBF', true);
158
+		}
159
+
160
+		try {
161
+			Util\Timing::startTiming();
162
+			Runner::checkRequirements();
163
+
164
+			// Creating the Config object populates it with all required settings
165
+			// based on the CLI arguments provided to the script and any config
166
+			// values the user has set.
167
+			$this->config = new Config();
168
+
169
+			// When processing STDIN, we can't output anything to the screen
170
+			// or it will end up mixed in with the file output.
171
+			if ($this->config->stdin === true) {
172
+				$this->config->verbosity = 0;
173
+			}
174
+
175
+			// Init the run and load the rulesets to set additional config vars.
176
+			$this->init();
177
+
178
+			// When processing STDIN, we only process one file at a time and
179
+			// we don't process all the way through, so we can't use the parallel
180
+			// running system.
181
+			if ($this->config->stdin === true) {
182
+				$this->config->parallel = 1;
183
+			}
184
+
185
+			// Override some of the command line settings that might break the fixes.
186
+			$this->config->generator    = null;
187
+			$this->config->explain      = false;
188
+			$this->config->interactive  = false;
189
+			$this->config->cache        = false;
190
+			$this->config->showSources  = false;
191
+			$this->config->recordErrors = false;
192
+			$this->config->reportFile   = null;
193
+			$this->config->reports      = ['cbf' => null];
194
+
195
+			// If a standard tries to set command line arguments itself, some
196
+			// may be blocked because PHPCBF is running, so stop the script
197
+			// dying if any are found.
198
+			$this->config->dieOnUnknownArg = false;
199
+
200
+			$this->run();
201
+			$this->reporter->printReports();
202
+
203
+			echo PHP_EOL;
204
+			Util\Timing::printRunTime();
205
+		} catch (DeepExitException $e) {
206
+			echo $e->getMessage();
207
+			return $e->getCode();
208
+		}//end try
209
+
210
+		if ($this->reporter->totalFixed === 0) {
211
+			// Nothing was fixed by PHPCBF.
212
+			if ($this->reporter->totalFixable === 0) {
213
+				// Nothing found that could be fixed.
214
+				return 0;
215
+			} else {
216
+				// Something failed to fix.
217
+				return 2;
218
+			}
219
+		}
220
+
221
+		if ($this->reporter->totalFixable === 0) {
222
+			// PHPCBF fixed all fixable errors.
223
+			return 1;
224
+		}
225
+
226
+		// PHPCBF fixed some fixable errors, but others failed to fix.
227
+		return 2;
228
+
229
+	}//end runPHPCBF()
230
+
231
+
232
+	/**
233
+	 * Exits if the minimum requirements of PHP_CodeSniffer are not met.
234
+	 *
235
+	 * @return void
236
+	 * @throws \PHP_CodeSniffer\Exceptions\DeepExitException If the requirements are not met.
237
+	 */
238
+	public function checkRequirements()
239
+	{
240
+		// Check the PHP version.
241
+		if (PHP_VERSION_ID < 50400) {
242
+			$error = 'ERROR: PHP_CodeSniffer requires PHP version 5.4.0 or greater.'.PHP_EOL;
243
+			throw new DeepExitException($error, 3);
244
+		}
245
+
246
+		$requiredExtensions = [
247
+			'tokenizer',
248
+			'xmlwriter',
249
+			'SimpleXML',
250
+		];
251
+		$missingExtensions  = [];
252
+
253
+		foreach ($requiredExtensions as $extension) {
254
+			if (extension_loaded($extension) === false) {
255
+				$missingExtensions[] = $extension;
256
+			}
257
+		}
258
+
259
+		if (empty($missingExtensions) === false) {
260
+			$last      = array_pop($requiredExtensions);
261
+			$required  = implode(', ', $requiredExtensions);
262
+			$required .= ' and '.$last;
263
+
264
+			if (count($missingExtensions) === 1) {
265
+				$missing = $missingExtensions[0];
266
+			} else {
267
+				$last     = array_pop($missingExtensions);
268
+				$missing  = implode(', ', $missingExtensions);
269
+				$missing .= ' and '.$last;
270
+			}
271
+
272
+			$error = 'ERROR: PHP_CodeSniffer requires the %s extensions to be enabled. Please enable %s.'.PHP_EOL;
273
+			$error = sprintf($error, $required, $missing);
274
+			throw new DeepExitException($error, 3);
275
+		}
276
+
277
+	}//end checkRequirements()
278
+
279
+
280
+	/**
281
+	 * Init the rulesets and other high-level settings.
282
+	 *
283
+	 * @return void
284
+	 * @throws \PHP_CodeSniffer\Exceptions\DeepExitException If a referenced standard is not installed.
285
+	 */
286
+	public function init()
287
+	{
288
+		if (defined('PHP_CODESNIFFER_CBF') === false) {
289
+			define('PHP_CODESNIFFER_CBF', false);
290
+		}
291
+
292
+		// Ensure this option is enabled or else line endings will not always
293
+		// be detected properly for files created on a Mac with the /r line ending.
294
+		@ini_set('auto_detect_line_endings', true);
295
+
296
+		// Disable the PCRE JIT as this caused issues with parallel running.
297
+		ini_set('pcre.jit', false);
298
+
299
+		// Check that the standards are valid.
300
+		foreach ($this->config->standards as $standard) {
301
+			if (Util\Standards::isInstalledStandard($standard) === false) {
302
+				// They didn't select a valid coding standard, so help them
303
+				// out by letting them know which standards are installed.
304
+				$error = 'ERROR: the "'.$standard.'" coding standard is not installed. ';
305
+				ob_start();
306
+				Util\Standards::printInstalledStandards();
307
+				$error .= ob_get_contents();
308
+				ob_end_clean();
309
+				throw new DeepExitException($error, 3);
310
+			}
311
+		}
312
+
313
+		// Saves passing the Config object into other objects that only need
314
+		// the verbosity flag for debug output.
315
+		if (defined('PHP_CODESNIFFER_VERBOSITY') === false) {
316
+			define('PHP_CODESNIFFER_VERBOSITY', $this->config->verbosity);
317
+		}
318
+
319
+		// Create this class so it is autoloaded and sets up a bunch
320
+		// of PHP_CodeSniffer-specific token type constants.
321
+		$tokens = new Util\Tokens();
322
+
323
+		// Allow autoloading of custom files inside installed standards.
324
+		$installedStandards = Standards::getInstalledStandardDetails();
325
+		foreach ($installedStandards as $name => $details) {
326
+			Autoload::addSearchPath($details['path'], $details['namespace']);
327
+		}
328
+
329
+		// The ruleset contains all the information about how the files
330
+		// should be checked and/or fixed.
331
+		try {
332
+			$this->ruleset = new Ruleset($this->config);
333
+		} catch (RuntimeException $e) {
334
+			$error  = 'ERROR: '.$e->getMessage().PHP_EOL.PHP_EOL;
335
+			$error .= $this->config->printShortUsage(true);
336
+			throw new DeepExitException($error, 3);
337
+		}
338
+
339
+	}//end init()
340
+
341
+
342
+	/**
343
+	 * Performs the run.
344
+	 *
345
+	 * @return int The number of errors and warnings found.
346
+	 * @throws \PHP_CodeSniffer\Exceptions\DeepExitException
347
+	 * @throws \PHP_CodeSniffer\Exceptions\RuntimeException
348
+	 */
349
+	private function run()
350
+	{
351
+		// The class that manages all reporters for the run.
352
+		$this->reporter = new Reporter($this->config);
353
+
354
+		// Include bootstrap files.
355
+		foreach ($this->config->bootstrap as $bootstrap) {
356
+			include $bootstrap;
357
+		}
358
+
359
+		if ($this->config->stdin === true) {
360
+			$fileContents = $this->config->stdinContent;
361
+			if ($fileContents === null) {
362
+				$handle = fopen('php://stdin', 'r');
363
+				stream_set_blocking($handle, true);
364
+				$fileContents = stream_get_contents($handle);
365
+				fclose($handle);
366
+			}
367
+
368
+			$todo  = new FileList($this->config, $this->ruleset);
369
+			$dummy = new DummyFile($fileContents, $this->ruleset, $this->config);
370
+			$todo->addFile($dummy->path, $dummy);
371
+		} else {
372
+			if (empty($this->config->files) === true) {
373
+				$error  = 'ERROR: You must supply at least one file or directory to process.'.PHP_EOL.PHP_EOL;
374
+				$error .= $this->config->printShortUsage(true);
375
+				throw new DeepExitException($error, 3);
376
+			}
377
+
378
+			if (PHP_CODESNIFFER_VERBOSITY > 0) {
379
+				echo 'Creating file list... ';
380
+			}
381
+
382
+			$todo = new FileList($this->config, $this->ruleset);
383
+
384
+			if (PHP_CODESNIFFER_VERBOSITY > 0) {
385
+				$numFiles = count($todo);
386
+				echo "DONE ($numFiles files in queue)".PHP_EOL;
387
+			}
388
+
389
+			if ($this->config->cache === true) {
390
+				if (PHP_CODESNIFFER_VERBOSITY > 0) {
391
+					echo 'Loading cache... ';
392
+				}
393
+
394
+				Cache::load($this->ruleset, $this->config);
395
+
396
+				if (PHP_CODESNIFFER_VERBOSITY > 0) {
397
+					$size = Cache::getSize();
398
+					echo "DONE ($size files in cache)".PHP_EOL;
399
+				}
400
+			}
401
+		}//end if
402
+
403
+		// Turn all sniff errors into exceptions.
404
+		set_error_handler([$this, 'handleErrors']);
405
+
406
+		// If verbosity is too high, turn off parallelism so the
407
+		// debug output is clean.
408
+		if (PHP_CODESNIFFER_VERBOSITY > 1) {
409
+			$this->config->parallel = 1;
410
+		}
411
+
412
+		// If the PCNTL extension isn't installed, we can't fork.
413
+		if (function_exists('pcntl_fork') === false) {
414
+			$this->config->parallel = 1;
415
+		}
416
+
417
+		$lastDir  = '';
418
+		$numFiles = count($todo);
419
+
420
+		if ($this->config->parallel === 1) {
421
+			// Running normally.
422
+			$numProcessed = 0;
423
+			foreach ($todo as $path => $file) {
424
+				if ($file->ignored === false) {
425
+					$currDir = dirname($path);
426
+					if ($lastDir !== $currDir) {
427
+						if (PHP_CODESNIFFER_VERBOSITY > 0) {
428
+							echo 'Changing into directory '.Common::stripBasepath($currDir, $this->config->basepath).PHP_EOL;
429
+						}
430
+
431
+						$lastDir = $currDir;
432
+					}
433
+
434
+					$this->processFile($file);
435
+				} else if (PHP_CODESNIFFER_VERBOSITY > 0) {
436
+					echo 'Skipping '.basename($file->path).PHP_EOL;
437
+				}
438
+
439
+				$numProcessed++;
440
+				$this->printProgress($file, $numFiles, $numProcessed);
441
+			}
442
+		} else {
443
+			// Batching and forking.
444
+			$childProcs  = [];
445
+			$numPerBatch = ceil($numFiles / $this->config->parallel);
446
+
447
+			for ($batch = 0; $batch < $this->config->parallel; $batch++) {
448
+				$startAt = ($batch * $numPerBatch);
449
+				if ($startAt >= $numFiles) {
450
+					break;
451
+				}
452
+
453
+				$endAt = ($startAt + $numPerBatch);
454
+				if ($endAt > $numFiles) {
455
+					$endAt = $numFiles;
456
+				}
457
+
458
+				$childOutFilename = tempnam(sys_get_temp_dir(), 'phpcs-child');
459
+				$pid = pcntl_fork();
460
+				if ($pid === -1) {
461
+					throw new RuntimeException('Failed to create child process');
462
+				} else if ($pid !== 0) {
463
+					$childProcs[] = [
464
+						'pid' => $pid,
465
+						'out' => $childOutFilename,
466
+					];
467
+				} else {
468
+					// Move forward to the start of the batch.
469
+					$todo->rewind();
470
+					for ($i = 0; $i < $startAt; $i++) {
471
+						$todo->next();
472
+					}
473
+
474
+					// Reset the reporter to make sure only figures from this
475
+					// file batch are recorded.
476
+					$this->reporter->totalFiles    = 0;
477
+					$this->reporter->totalErrors   = 0;
478
+					$this->reporter->totalWarnings = 0;
479
+					$this->reporter->totalFixable  = 0;
480
+					$this->reporter->totalFixed    = 0;
481
+
482
+					// Process the files.
483
+					$pathsProcessed = [];
484
+					ob_start();
485
+					for ($i = $startAt; $i < $endAt; $i++) {
486
+						$path = $todo->key();
487
+						$file = $todo->current();
488
+
489
+						if ($file->ignored === true) {
490
+							$todo->next();
491
+							continue;
492
+						}
493
+
494
+						$currDir = dirname($path);
495
+						if ($lastDir !== $currDir) {
496
+							if (PHP_CODESNIFFER_VERBOSITY > 0) {
497
+								echo 'Changing into directory '.Common::stripBasepath($currDir, $this->config->basepath).PHP_EOL;
498
+							}
499
+
500
+							$lastDir = $currDir;
501
+						}
502
+
503
+						$this->processFile($file);
504
+
505
+						$pathsProcessed[] = $path;
506
+						$todo->next();
507
+					}//end for
508
+
509
+					$debugOutput = ob_get_contents();
510
+					ob_end_clean();
511
+
512
+					// Write information about the run to the filesystem
513
+					// so it can be picked up by the main process.
514
+					$childOutput = [
515
+						'totalFiles'    => $this->reporter->totalFiles,
516
+						'totalErrors'   => $this->reporter->totalErrors,
517
+						'totalWarnings' => $this->reporter->totalWarnings,
518
+						'totalFixable'  => $this->reporter->totalFixable,
519
+						'totalFixed'    => $this->reporter->totalFixed,
520
+					];
521
+
522
+					$output  = '<'.'?php'."\n".' $childOutput = ';
523
+					$output .= var_export($childOutput, true);
524
+					$output .= ";\n\$debugOutput = ";
525
+					$output .= var_export($debugOutput, true);
526
+
527
+					if ($this->config->cache === true) {
528
+						$childCache = [];
529
+						foreach ($pathsProcessed as $path) {
530
+							$childCache[$path] = Cache::get($path);
531
+						}
532
+
533
+						$output .= ";\n\$childCache = ";
534
+						$output .= var_export($childCache, true);
535
+					}
536
+
537
+					$output .= ";\n?".'>';
538
+					file_put_contents($childOutFilename, $output);
539
+					exit($pid);
540
+				}//end if
541
+			}//end for
542
+
543
+			$success = $this->processChildProcs($childProcs);
544
+			if ($success === false) {
545
+				throw new RuntimeException('One or more child processes failed to run');
546
+			}
547
+		}//end if
548
+
549
+		restore_error_handler();
550
+
551
+		if (PHP_CODESNIFFER_VERBOSITY === 0
552
+			&& $this->config->interactive === false
553
+			&& $this->config->showProgress === true
554
+		) {
555
+			echo PHP_EOL.PHP_EOL;
556
+		}
557
+
558
+		if ($this->config->cache === true) {
559
+			Cache::save();
560
+		}
561
+
562
+		$ignoreWarnings = Config::getConfigData('ignore_warnings_on_exit');
563
+		$ignoreErrors   = Config::getConfigData('ignore_errors_on_exit');
564
+
565
+		$return = ($this->reporter->totalErrors + $this->reporter->totalWarnings);
566
+		if ($ignoreErrors !== null) {
567
+			$ignoreErrors = (bool) $ignoreErrors;
568
+			if ($ignoreErrors === true) {
569
+				$return -= $this->reporter->totalErrors;
570
+			}
571
+		}
572
+
573
+		if ($ignoreWarnings !== null) {
574
+			$ignoreWarnings = (bool) $ignoreWarnings;
575
+			if ($ignoreWarnings === true) {
576
+				$return -= $this->reporter->totalWarnings;
577
+			}
578
+		}
579
+
580
+		return $return;
581
+
582
+	}//end run()
583
+
584
+
585
+	/**
586
+	 * Converts all PHP errors into exceptions.
587
+	 *
588
+	 * This method forces a sniff to stop processing if it is not
589
+	 * able to handle a specific piece of code, instead of continuing
590
+	 * and potentially getting into a loop.
591
+	 *
592
+	 * @param int    $code    The level of error raised.
593
+	 * @param string $message The error message.
594
+	 * @param string $file    The path of the file that raised the error.
595
+	 * @param int    $line    The line number the error was raised at.
596
+	 *
597
+	 * @return void
598
+	 * @throws \PHP_CodeSniffer\Exceptions\RuntimeException
599
+	 */
600
+	public function handleErrors($code, $message, $file, $line)
601
+	{
602
+		if ((error_reporting() & $code) === 0) {
603
+			// This type of error is being muted.
604
+			return true;
605
+		}
606
+
607
+		throw new RuntimeException("$message in $file on line $line");
608
+
609
+	}//end handleErrors()
610
+
611
+
612
+	/**
613
+	 * Processes a single file, including checking and fixing.
614
+	 *
615
+	 * @param \PHP_CodeSniffer\Files\File $file The file to be processed.
616
+	 *
617
+	 * @return void
618
+	 * @throws \PHP_CodeSniffer\Exceptions\DeepExitException
619
+	 */
620
+	public function processFile($file)
621
+	{
622
+		if (PHP_CODESNIFFER_VERBOSITY > 0) {
623
+			$startTime = microtime(true);
624
+			echo 'Processing '.basename($file->path).' ';
625
+			if (PHP_CODESNIFFER_VERBOSITY > 1) {
626
+				echo PHP_EOL;
627
+			}
628
+		}
629
+
630
+		try {
631
+			$file->process();
632
+
633
+			if (PHP_CODESNIFFER_VERBOSITY > 0) {
634
+				$timeTaken = ((microtime(true) - $startTime) * 1000);
635
+				if ($timeTaken < 1000) {
636
+					$timeTaken = round($timeTaken);
637
+					echo "DONE in {$timeTaken}ms";
638
+				} else {
639
+					$timeTaken = round(($timeTaken / 1000), 2);
640
+					echo "DONE in $timeTaken secs";
641
+				}
642
+
643
+				if (PHP_CODESNIFFER_CBF === true) {
644
+					$errors = $file->getFixableCount();
645
+					echo " ($errors fixable violations)".PHP_EOL;
646
+				} else {
647
+					$errors   = $file->getErrorCount();
648
+					$warnings = $file->getWarningCount();
649
+					echo " ($errors errors, $warnings warnings)".PHP_EOL;
650
+				}
651
+			}
652
+		} catch (\Exception $e) {
653
+			$error = 'An error occurred during processing; checking has been aborted. The error message was: '.$e->getMessage();
654
+			$file->addErrorOnLine($error, 1, 'Internal.Exception');
655
+		}//end try
656
+
657
+		$this->reporter->cacheFileReport($file, $this->config);
658
+
659
+		if ($this->config->interactive === true) {
660
+			/*
661 661
                 Running interactively.
662 662
                 Print the error report for the current file and then wait for user input.
663 663
             */
664 664
 
665
-            // Get current violations and then clear the list to make sure
666
-            // we only print violations for a single file each time.
667
-            $numErrors = null;
668
-            while ($numErrors !== 0) {
669
-                $numErrors = ($file->getErrorCount() + $file->getWarningCount());
670
-                if ($numErrors === 0) {
671
-                    continue;
672
-                }
673
-
674
-                $this->reporter->printReport('full');
675
-
676
-                echo '<ENTER> to recheck, [s] to skip or [q] to quit : ';
677
-                $input = fgets(STDIN);
678
-                $input = trim($input);
679
-
680
-                switch ($input) {
681
-                case 's':
682
-                    break(2);
683
-                case 'q':
684
-                    throw new DeepExitException('', 0);
685
-                default:
686
-                    // Repopulate the sniffs because some of them save their state
687
-                    // and only clear it when the file changes, but we are rechecking
688
-                    // the same file.
689
-                    $file->ruleset->populateTokenListeners();
690
-                    $file->reloadContent();
691
-                    $file->process();
692
-                    $this->reporter->cacheFileReport($file, $this->config);
693
-                    break;
694
-                }
695
-            }//end while
696
-        }//end if
697
-
698
-        // Clean up the file to save (a lot of) memory.
699
-        $file->cleanUp();
700
-
701
-    }//end processFile()
702
-
703
-
704
-    /**
705
-     * Waits for child processes to complete and cleans up after them.
706
-     *
707
-     * The reporting information returned by each child process is merged
708
-     * into the main reporter class.
709
-     *
710
-     * @param array $childProcs An array of child processes to wait for.
711
-     *
712
-     * @return bool
713
-     */
714
-    private function processChildProcs($childProcs)
715
-    {
716
-        $numProcessed = 0;
717
-        $totalBatches = count($childProcs);
718
-
719
-        $success = true;
720
-
721
-        while (count($childProcs) > 0) {
722
-            foreach ($childProcs as $key => $procData) {
723
-                $res = pcntl_waitpid($procData['pid'], $status, WNOHANG);
724
-                if ($res === $procData['pid']) {
725
-                    if (file_exists($procData['out']) === true) {
726
-                        include $procData['out'];
727
-
728
-                        unlink($procData['out']);
729
-                        unset($childProcs[$key]);
730
-
731
-                        $numProcessed++;
732
-
733
-                        if (isset($childOutput) === false) {
734
-                            // The child process died, so the run has failed.
735
-                            $file = new DummyFile('', $this->ruleset, $this->config);
736
-                            $file->setErrorCounts(1, 0, 0, 0);
737
-                            $this->printProgress($file, $totalBatches, $numProcessed);
738
-                            $success = false;
739
-                            continue;
740
-                        }
741
-
742
-                        $this->reporter->totalFiles    += $childOutput['totalFiles'];
743
-                        $this->reporter->totalErrors   += $childOutput['totalErrors'];
744
-                        $this->reporter->totalWarnings += $childOutput['totalWarnings'];
745
-                        $this->reporter->totalFixable  += $childOutput['totalFixable'];
746
-                        $this->reporter->totalFixed    += $childOutput['totalFixed'];
747
-
748
-                        if (isset($debugOutput) === true) {
749
-                            echo $debugOutput;
750
-                        }
751
-
752
-                        if (isset($childCache) === true) {
753
-                            foreach ($childCache as $path => $cache) {
754
-                                Cache::set($path, $cache);
755
-                            }
756
-                        }
757
-
758
-                        // Fake a processed file so we can print progress output for the batch.
759
-                        $file = new DummyFile('', $this->ruleset, $this->config);
760
-                        $file->setErrorCounts(
761
-                            $childOutput['totalErrors'],
762
-                            $childOutput['totalWarnings'],
763
-                            $childOutput['totalFixable'],
764
-                            $childOutput['totalFixed']
765
-                        );
766
-                        $this->printProgress($file, $totalBatches, $numProcessed);
767
-                    }//end if
768
-                }//end if
769
-            }//end foreach
770
-        }//end while
771
-
772
-        return $success;
773
-
774
-    }//end processChildProcs()
775
-
776
-
777
-    /**
778
-     * Print progress information for a single processed file.
779
-     *
780
-     * @param \PHP_CodeSniffer\Files\File $file         The file that was processed.
781
-     * @param int                         $numFiles     The total number of files to process.
782
-     * @param int                         $numProcessed The number of files that have been processed,
783
-     *                                                  including this one.
784
-     *
785
-     * @return void
786
-     */
787
-    public function printProgress(File $file, $numFiles, $numProcessed)
788
-    {
789
-        if (PHP_CODESNIFFER_VERBOSITY > 0
790
-            || $this->config->showProgress === false
791
-        ) {
792
-            return;
793
-        }
794
-
795
-        // Show progress information.
796
-        if ($file->ignored === true) {
797
-            echo 'S';
798
-        } else {
799
-            $errors   = $file->getErrorCount();
800
-            $warnings = $file->getWarningCount();
801
-            $fixable  = $file->getFixableCount();
802
-            $fixed    = $file->getFixedCount();
803
-
804
-            if (PHP_CODESNIFFER_CBF === true) {
805
-                // Files with fixed errors or warnings are F (green).
806
-                // Files with unfixable errors or warnings are E (red).
807
-                // Files with no errors or warnings are . (black).
808
-                if ($fixable > 0) {
809
-                    if ($this->config->colors === true) {
810
-                        echo "\033[31m";
811
-                    }
812
-
813
-                    echo 'E';
814
-
815
-                    if ($this->config->colors === true) {
816
-                        echo "\033[0m";
817
-                    }
818
-                } else if ($fixed > 0) {
819
-                    if ($this->config->colors === true) {
820
-                        echo "\033[32m";
821
-                    }
822
-
823
-                    echo 'F';
824
-
825
-                    if ($this->config->colors === true) {
826
-                        echo "\033[0m";
827
-                    }
828
-                } else {
829
-                    echo '.';
830
-                }//end if
831
-            } else {
832
-                // Files with errors are E (red).
833
-                // Files with fixable errors are E (green).
834
-                // Files with warnings are W (yellow).
835
-                // Files with fixable warnings are W (green).
836
-                // Files with no errors or warnings are . (black).
837
-                if ($errors > 0) {
838
-                    if ($this->config->colors === true) {
839
-                        if ($fixable > 0) {
840
-                            echo "\033[32m";
841
-                        } else {
842
-                            echo "\033[31m";
843
-                        }
844
-                    }
845
-
846
-                    echo 'E';
847
-
848
-                    if ($this->config->colors === true) {
849
-                        echo "\033[0m";
850
-                    }
851
-                } else if ($warnings > 0) {
852
-                    if ($this->config->colors === true) {
853
-                        if ($fixable > 0) {
854
-                            echo "\033[32m";
855
-                        } else {
856
-                            echo "\033[33m";
857
-                        }
858
-                    }
859
-
860
-                    echo 'W';
861
-
862
-                    if ($this->config->colors === true) {
863
-                        echo "\033[0m";
864
-                    }
865
-                } else {
866
-                    echo '.';
867
-                }//end if
868
-            }//end if
869
-        }//end if
870
-
871
-        $numPerLine = 60;
872
-        if ($numProcessed !== $numFiles && ($numProcessed % $numPerLine) !== 0) {
873
-            return;
874
-        }
875
-
876
-        $percent = round(($numProcessed / $numFiles) * 100);
877
-        $padding = (strlen($numFiles) - strlen($numProcessed));
878
-        if ($numProcessed === $numFiles
879
-            && $numFiles > $numPerLine
880
-            && ($numProcessed % $numPerLine) !== 0
881
-        ) {
882
-            $padding += ($numPerLine - ($numFiles - (floor($numFiles / $numPerLine) * $numPerLine)));
883
-        }
884
-
885
-        echo str_repeat(' ', $padding)." $numProcessed / $numFiles ($percent%)".PHP_EOL;
886
-
887
-    }//end printProgress()
665
+			// Get current violations and then clear the list to make sure
666
+			// we only print violations for a single file each time.
667
+			$numErrors = null;
668
+			while ($numErrors !== 0) {
669
+				$numErrors = ($file->getErrorCount() + $file->getWarningCount());
670
+				if ($numErrors === 0) {
671
+					continue;
672
+				}
673
+
674
+				$this->reporter->printReport('full');
675
+
676
+				echo '<ENTER> to recheck, [s] to skip or [q] to quit : ';
677
+				$input = fgets(STDIN);
678
+				$input = trim($input);
679
+
680
+				switch ($input) {
681
+				case 's':
682
+					break(2);
683
+				case 'q':
684
+					throw new DeepExitException('', 0);
685
+				default:
686
+					// Repopulate the sniffs because some of them save their state
687
+					// and only clear it when the file changes, but we are rechecking
688
+					// the same file.
689
+					$file->ruleset->populateTokenListeners();
690
+					$file->reloadContent();
691
+					$file->process();
692
+					$this->reporter->cacheFileReport($file, $this->config);
693
+					break;
694
+				}
695
+			}//end while
696
+		}//end if
697
+
698
+		// Clean up the file to save (a lot of) memory.
699
+		$file->cleanUp();
700
+
701
+	}//end processFile()
702
+
703
+
704
+	/**
705
+	 * Waits for child processes to complete and cleans up after them.
706
+	 *
707
+	 * The reporting information returned by each child process is merged
708
+	 * into the main reporter class.
709
+	 *
710
+	 * @param array $childProcs An array of child processes to wait for.
711
+	 *
712
+	 * @return bool
713
+	 */
714
+	private function processChildProcs($childProcs)
715
+	{
716
+		$numProcessed = 0;
717
+		$totalBatches = count($childProcs);
718
+
719
+		$success = true;
720
+
721
+		while (count($childProcs) > 0) {
722
+			foreach ($childProcs as $key => $procData) {
723
+				$res = pcntl_waitpid($procData['pid'], $status, WNOHANG);
724
+				if ($res === $procData['pid']) {
725
+					if (file_exists($procData['out']) === true) {
726
+						include $procData['out'];
727
+
728
+						unlink($procData['out']);
729
+						unset($childProcs[$key]);
730
+
731
+						$numProcessed++;
732
+
733
+						if (isset($childOutput) === false) {
734
+							// The child process died, so the run has failed.
735
+							$file = new DummyFile('', $this->ruleset, $this->config);
736
+							$file->setErrorCounts(1, 0, 0, 0);
737
+							$this->printProgress($file, $totalBatches, $numProcessed);
738
+							$success = false;
739
+							continue;
740
+						}
741
+
742
+						$this->reporter->totalFiles    += $childOutput['totalFiles'];
743
+						$this->reporter->totalErrors   += $childOutput['totalErrors'];
744
+						$this->reporter->totalWarnings += $childOutput['totalWarnings'];
745
+						$this->reporter->totalFixable  += $childOutput['totalFixable'];
746
+						$this->reporter->totalFixed    += $childOutput['totalFixed'];
747
+
748
+						if (isset($debugOutput) === true) {
749
+							echo $debugOutput;
750
+						}
751
+
752
+						if (isset($childCache) === true) {
753
+							foreach ($childCache as $path => $cache) {
754
+								Cache::set($path, $cache);
755
+							}
756
+						}
757
+
758
+						// Fake a processed file so we can print progress output for the batch.
759
+						$file = new DummyFile('', $this->ruleset, $this->config);
760
+						$file->setErrorCounts(
761
+							$childOutput['totalErrors'],
762
+							$childOutput['totalWarnings'],
763
+							$childOutput['totalFixable'],
764
+							$childOutput['totalFixed']
765
+						);
766
+						$this->printProgress($file, $totalBatches, $numProcessed);
767
+					}//end if
768
+				}//end if
769
+			}//end foreach
770
+		}//end while
771
+
772
+		return $success;
773
+
774
+	}//end processChildProcs()
775
+
776
+
777
+	/**
778
+	 * Print progress information for a single processed file.
779
+	 *
780
+	 * @param \PHP_CodeSniffer\Files\File $file         The file that was processed.
781
+	 * @param int                         $numFiles     The total number of files to process.
782
+	 * @param int                         $numProcessed The number of files that have been processed,
783
+	 *                                                  including this one.
784
+	 *
785
+	 * @return void
786
+	 */
787
+	public function printProgress(File $file, $numFiles, $numProcessed)
788
+	{
789
+		if (PHP_CODESNIFFER_VERBOSITY > 0
790
+			|| $this->config->showProgress === false
791
+		) {
792
+			return;
793
+		}
794
+
795
+		// Show progress information.
796
+		if ($file->ignored === true) {
797
+			echo 'S';
798
+		} else {
799
+			$errors   = $file->getErrorCount();
800
+			$warnings = $file->getWarningCount();
801
+			$fixable  = $file->getFixableCount();
802
+			$fixed    = $file->getFixedCount();
803
+
804
+			if (PHP_CODESNIFFER_CBF === true) {
805
+				// Files with fixed errors or warnings are F (green).
806
+				// Files with unfixable errors or warnings are E (red).
807
+				// Files with no errors or warnings are . (black).
808
+				if ($fixable > 0) {
809
+					if ($this->config->colors === true) {
810
+						echo "\033[31m";
811
+					}
812
+
813
+					echo 'E';
814
+
815
+					if ($this->config->colors === true) {
816
+						echo "\033[0m";
817
+					}
818
+				} else if ($fixed > 0) {
819
+					if ($this->config->colors === true) {
820
+						echo "\033[32m";
821
+					}
822
+
823
+					echo 'F';
824
+
825
+					if ($this->config->colors === true) {
826
+						echo "\033[0m";
827
+					}
828
+				} else {
829
+					echo '.';
830
+				}//end if
831
+			} else {
832
+				// Files with errors are E (red).
833
+				// Files with fixable errors are E (green).
834
+				// Files with warnings are W (yellow).
835
+				// Files with fixable warnings are W (green).
836
+				// Files with no errors or warnings are . (black).
837
+				if ($errors > 0) {
838
+					if ($this->config->colors === true) {
839
+						if ($fixable > 0) {
840
+							echo "\033[32m";
841
+						} else {
842
+							echo "\033[31m";
843
+						}
844
+					}
845
+
846
+					echo 'E';
847
+
848
+					if ($this->config->colors === true) {
849
+						echo "\033[0m";
850
+					}
851
+				} else if ($warnings > 0) {
852
+					if ($this->config->colors === true) {
853
+						if ($fixable > 0) {
854
+							echo "\033[32m";
855
+						} else {
856
+							echo "\033[33m";
857
+						}
858
+					}
859
+
860
+					echo 'W';
861
+
862
+					if ($this->config->colors === true) {
863
+						echo "\033[0m";
864
+					}
865
+				} else {
866
+					echo '.';
867
+				}//end if
868
+			}//end if
869
+		}//end if
870
+
871
+		$numPerLine = 60;
872
+		if ($numProcessed !== $numFiles && ($numProcessed % $numPerLine) !== 0) {
873
+			return;
874
+		}
875
+
876
+		$percent = round(($numProcessed / $numFiles) * 100);
877
+		$padding = (strlen($numFiles) - strlen($numProcessed));
878
+		if ($numProcessed === $numFiles
879
+			&& $numFiles > $numPerLine
880
+			&& ($numProcessed % $numPerLine) !== 0
881
+		) {
882
+			$padding += ($numPerLine - ($numFiles - (floor($numFiles / $numPerLine) * $numPerLine)));
883
+		}
884
+
885
+		echo str_repeat(' ', $padding)." $numProcessed / $numFiles ($percent%)".PHP_EOL;
886
+
887
+	}//end printProgress()
888 888
 
889 889
 
890 890
 }//end class
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -248,7 +248,7 @@
 block discarded – undo
248 248
             'xmlwriter',
249 249
             'SimpleXML',
250 250
         ];
251
-        $missingExtensions  = [];
251
+        $missingExtensions = [];
252 252
 
253 253
         foreach ($requiredExtensions as $extension) {
254 254
             if (extension_loaded($extension) === false) {
Please login to merge, or discard this patch.
vendor/squizlabs/php_codesniffer/src/Reports/Report.php 2 patches
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -15,50 +15,50 @@
 block discarded – undo
15 15
 {
16 16
 
17 17
 
18
-    /**
19
-     * Generate a partial report for a single processed file.
20
-     *
21
-     * Function should return TRUE if it printed or stored data about the file
22
-     * and FALSE if it ignored the file. Returning TRUE indicates that the file and
23
-     * its data should be counted in the grand totals.
24
-     *
25
-     * @param array                 $report      Prepared report data.
26
-     * @param \PHP_CodeSniffer\File $phpcsFile   The file being reported on.
27
-     * @param bool                  $showSources Show sources?
28
-     * @param int                   $width       Maximum allowed line width.
29
-     *
30
-     * @return bool
31
-     */
32
-    public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80);
18
+	/**
19
+	 * Generate a partial report for a single processed file.
20
+	 *
21
+	 * Function should return TRUE if it printed or stored data about the file
22
+	 * and FALSE if it ignored the file. Returning TRUE indicates that the file and
23
+	 * its data should be counted in the grand totals.
24
+	 *
25
+	 * @param array                 $report      Prepared report data.
26
+	 * @param \PHP_CodeSniffer\File $phpcsFile   The file being reported on.
27
+	 * @param bool                  $showSources Show sources?
28
+	 * @param int                   $width       Maximum allowed line width.
29
+	 *
30
+	 * @return bool
31
+	 */
32
+	public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80);
33 33
 
34 34
 
35
-    /**
36
-     * Generate the actual report.
37
-     *
38
-     * @param string $cachedData    Any partial report data that was returned from
39
-     *                              generateFileReport during the run.
40
-     * @param int    $totalFiles    Total number of files processed during the run.
41
-     * @param int    $totalErrors   Total number of errors found during the run.
42
-     * @param int    $totalWarnings Total number of warnings found during the run.
43
-     * @param int    $totalFixable  Total number of problems that can be fixed.
44
-     * @param bool   $showSources   Show sources?
45
-     * @param int    $width         Maximum allowed line width.
46
-     * @param bool   $interactive   Are we running in interactive mode?
47
-     * @param bool   $toScreen      Is the report being printed to screen?
48
-     *
49
-     * @return void
50
-     */
51
-    public function generate(
52
-        $cachedData,
53
-        $totalFiles,
54
-        $totalErrors,
55
-        $totalWarnings,
56
-        $totalFixable,
57
-        $showSources=false,
58
-        $width=80,
59
-        $interactive=false,
60
-        $toScreen=true
61
-    );
35
+	/**
36
+	 * Generate the actual report.
37
+	 *
38
+	 * @param string $cachedData    Any partial report data that was returned from
39
+	 *                              generateFileReport during the run.
40
+	 * @param int    $totalFiles    Total number of files processed during the run.
41
+	 * @param int    $totalErrors   Total number of errors found during the run.
42
+	 * @param int    $totalWarnings Total number of warnings found during the run.
43
+	 * @param int    $totalFixable  Total number of problems that can be fixed.
44
+	 * @param bool   $showSources   Show sources?
45
+	 * @param int    $width         Maximum allowed line width.
46
+	 * @param bool   $interactive   Are we running in interactive mode?
47
+	 * @param bool   $toScreen      Is the report being printed to screen?
48
+	 *
49
+	 * @return void
50
+	 */
51
+	public function generate(
52
+		$cachedData,
53
+		$totalFiles,
54
+		$totalErrors,
55
+		$totalWarnings,
56
+		$totalFixable,
57
+		$showSources=false,
58
+		$width=80,
59
+		$interactive=false,
60
+		$toScreen=true
61
+	);
62 62
 
63 63
 
64 64
 }//end interface
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
      *
30 30
      * @return bool
31 31
      */
32
-    public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80);
32
+    public function generateFileReport($report, File $phpcsFile, $showSources = false, $width = 80);
33 33
 
34 34
 
35 35
     /**
@@ -54,10 +54,10 @@  discard block
 block discarded – undo
54 54
         $totalErrors,
55 55
         $totalWarnings,
56 56
         $totalFixable,
57
-        $showSources=false,
58
-        $width=80,
59
-        $interactive=false,
60
-        $toScreen=true
57
+        $showSources = false,
58
+        $width = 80,
59
+        $interactive = false,
60
+        $toScreen = true
61 61
     );
62 62
 
63 63
 
Please login to merge, or discard this patch.
vendor/squizlabs/php_codesniffer/src/Reports/Junit.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
      *
32 32
      * @return bool
33 33
      */
34
-    public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80)
34
+    public function generateFileReport($report, File $phpcsFile, $showSources = false, $width = 80)
35 35
     {
36 36
         $out = new \XMLWriter;
37 37
         $out->openMemory();
@@ -103,10 +103,10 @@  discard block
 block discarded – undo
103 103
         $totalErrors,
104 104
         $totalWarnings,
105 105
         $totalFixable,
106
-        $showSources=false,
107
-        $width=80,
108
-        $interactive=false,
109
-        $toScreen=true
106
+        $showSources = false,
107
+        $width = 80,
108
+        $interactive = false,
109
+        $toScreen = true
110 110
     ) {
111 111
         // Figure out the total number of tests.
112 112
         $tests   = 0;
Please login to merge, or discard this patch.
Indentation   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -17,115 +17,115 @@
 block discarded – undo
17 17
 {
18 18
 
19 19
 
20
-    /**
21
-     * Generate a partial report for a single processed file.
22
-     *
23
-     * Function should return TRUE if it printed or stored data about the file
24
-     * and FALSE if it ignored the file. Returning TRUE indicates that the file and
25
-     * its data should be counted in the grand totals.
26
-     *
27
-     * @param array                 $report      Prepared report data.
28
-     * @param \PHP_CodeSniffer\File $phpcsFile   The file being reported on.
29
-     * @param bool                  $showSources Show sources?
30
-     * @param int                   $width       Maximum allowed line width.
31
-     *
32
-     * @return bool
33
-     */
34
-    public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80)
35
-    {
36
-        $out = new \XMLWriter;
37
-        $out->openMemory();
38
-        $out->setIndent(true);
39
-
40
-        $out->startElement('testsuite');
41
-        $out->writeAttribute('name', $report['filename']);
42
-        $out->writeAttribute('errors', 0);
43
-
44
-        if (count($report['messages']) === 0) {
45
-            $out->writeAttribute('tests', 1);
46
-            $out->writeAttribute('failures', 0);
47
-
48
-            $out->startElement('testcase');
49
-            $out->writeAttribute('name', $report['filename']);
50
-            $out->endElement();
51
-        } else {
52
-            $failures = ($report['errors'] + $report['warnings']);
53
-            $out->writeAttribute('tests', $failures);
54
-            $out->writeAttribute('failures', $failures);
55
-
56
-            foreach ($report['messages'] as $line => $lineErrors) {
57
-                foreach ($lineErrors as $column => $colErrors) {
58
-                    foreach ($colErrors as $error) {
59
-                        $out->startElement('testcase');
60
-                        $out->writeAttribute('name', $error['source'].' at '.$report['filename']." ($line:$column)");
61
-
62
-                        $error['type'] = strtolower($error['type']);
63
-                        if ($phpcsFile->config->encoding !== 'utf-8') {
64
-                            $error['message'] = iconv($phpcsFile->config->encoding, 'utf-8', $error['message']);
65
-                        }
66
-
67
-                        $out->startElement('failure');
68
-                        $out->writeAttribute('type', $error['type']);
69
-                        $out->writeAttribute('message', $error['message']);
70
-                        $out->endElement();
71
-
72
-                        $out->endElement();
73
-                    }
74
-                }
75
-            }
76
-        }//end if
77
-
78
-        $out->endElement();
79
-        echo $out->flush();
80
-        return true;
81
-
82
-    }//end generateFileReport()
83
-
84
-
85
-    /**
86
-     * Prints all violations for processed files, in a proprietary XML format.
87
-     *
88
-     * @param string $cachedData    Any partial report data that was returned from
89
-     *                              generateFileReport during the run.
90
-     * @param int    $totalFiles    Total number of files processed during the run.
91
-     * @param int    $totalErrors   Total number of errors found during the run.
92
-     * @param int    $totalWarnings Total number of warnings found during the run.
93
-     * @param int    $totalFixable  Total number of problems that can be fixed.
94
-     * @param bool   $showSources   Show sources?
95
-     * @param int    $width         Maximum allowed line width.
96
-     * @param bool   $interactive   Are we running in interactive mode?
97
-     * @param bool   $toScreen      Is the report being printed to screen?
98
-     *
99
-     * @return void
100
-     */
101
-    public function generate(
102
-        $cachedData,
103
-        $totalFiles,
104
-        $totalErrors,
105
-        $totalWarnings,
106
-        $totalFixable,
107
-        $showSources=false,
108
-        $width=80,
109
-        $interactive=false,
110
-        $toScreen=true
111
-    ) {
112
-        // Figure out the total number of tests.
113
-        $tests   = 0;
114
-        $matches = [];
115
-        preg_match_all('/tests="([0-9]+)"/', $cachedData, $matches);
116
-        if (isset($matches[1]) === true) {
117
-            foreach ($matches[1] as $match) {
118
-                $tests += $match;
119
-            }
120
-        }
121
-
122
-        $failures = ($totalErrors + $totalWarnings);
123
-        echo '<?xml version="1.0" encoding="UTF-8"?>'.PHP_EOL;
124
-        echo '<testsuites name="PHP_CodeSniffer '.Config::VERSION.'" errors="0" tests="'.$tests.'" failures="'.$failures.'">'.PHP_EOL;
125
-        echo $cachedData;
126
-        echo '</testsuites>'.PHP_EOL;
127
-
128
-    }//end generate()
20
+	/**
21
+	 * Generate a partial report for a single processed file.
22
+	 *
23
+	 * Function should return TRUE if it printed or stored data about the file
24
+	 * and FALSE if it ignored the file. Returning TRUE indicates that the file and
25
+	 * its data should be counted in the grand totals.
26
+	 *
27
+	 * @param array                 $report      Prepared report data.
28
+	 * @param \PHP_CodeSniffer\File $phpcsFile   The file being reported on.
29
+	 * @param bool                  $showSources Show sources?
30
+	 * @param int                   $width       Maximum allowed line width.
31
+	 *
32
+	 * @return bool
33
+	 */
34
+	public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80)
35
+	{
36
+		$out = new \XMLWriter;
37
+		$out->openMemory();
38
+		$out->setIndent(true);
39
+
40
+		$out->startElement('testsuite');
41
+		$out->writeAttribute('name', $report['filename']);
42
+		$out->writeAttribute('errors', 0);
43
+
44
+		if (count($report['messages']) === 0) {
45
+			$out->writeAttribute('tests', 1);
46
+			$out->writeAttribute('failures', 0);
47
+
48
+			$out->startElement('testcase');
49
+			$out->writeAttribute('name', $report['filename']);
50
+			$out->endElement();
51
+		} else {
52
+			$failures = ($report['errors'] + $report['warnings']);
53
+			$out->writeAttribute('tests', $failures);
54
+			$out->writeAttribute('failures', $failures);
55
+
56
+			foreach ($report['messages'] as $line => $lineErrors) {
57
+				foreach ($lineErrors as $column => $colErrors) {
58
+					foreach ($colErrors as $error) {
59
+						$out->startElement('testcase');
60
+						$out->writeAttribute('name', $error['source'].' at '.$report['filename']." ($line:$column)");
61
+
62
+						$error['type'] = strtolower($error['type']);
63
+						if ($phpcsFile->config->encoding !== 'utf-8') {
64
+							$error['message'] = iconv($phpcsFile->config->encoding, 'utf-8', $error['message']);
65
+						}
66
+
67
+						$out->startElement('failure');
68
+						$out->writeAttribute('type', $error['type']);
69
+						$out->writeAttribute('message', $error['message']);
70
+						$out->endElement();
71
+
72
+						$out->endElement();
73
+					}
74
+				}
75
+			}
76
+		}//end if
77
+
78
+		$out->endElement();
79
+		echo $out->flush();
80
+		return true;
81
+
82
+	}//end generateFileReport()
83
+
84
+
85
+	/**
86
+	 * Prints all violations for processed files, in a proprietary XML format.
87
+	 *
88
+	 * @param string $cachedData    Any partial report data that was returned from
89
+	 *                              generateFileReport during the run.
90
+	 * @param int    $totalFiles    Total number of files processed during the run.
91
+	 * @param int    $totalErrors   Total number of errors found during the run.
92
+	 * @param int    $totalWarnings Total number of warnings found during the run.
93
+	 * @param int    $totalFixable  Total number of problems that can be fixed.
94
+	 * @param bool   $showSources   Show sources?
95
+	 * @param int    $width         Maximum allowed line width.
96
+	 * @param bool   $interactive   Are we running in interactive mode?
97
+	 * @param bool   $toScreen      Is the report being printed to screen?
98
+	 *
99
+	 * @return void
100
+	 */
101
+	public function generate(
102
+		$cachedData,
103
+		$totalFiles,
104
+		$totalErrors,
105
+		$totalWarnings,
106
+		$totalFixable,
107
+		$showSources=false,
108
+		$width=80,
109
+		$interactive=false,
110
+		$toScreen=true
111
+	) {
112
+		// Figure out the total number of tests.
113
+		$tests   = 0;
114
+		$matches = [];
115
+		preg_match_all('/tests="([0-9]+)"/', $cachedData, $matches);
116
+		if (isset($matches[1]) === true) {
117
+			foreach ($matches[1] as $match) {
118
+				$tests += $match;
119
+			}
120
+		}
121
+
122
+		$failures = ($totalErrors + $totalWarnings);
123
+		echo '<?xml version="1.0" encoding="UTF-8"?>'.PHP_EOL;
124
+		echo '<testsuites name="PHP_CodeSniffer '.Config::VERSION.'" errors="0" tests="'.$tests.'" failures="'.$failures.'">'.PHP_EOL;
125
+		echo $cachedData;
126
+		echo '</testsuites>'.PHP_EOL;
127
+
128
+	}//end generate()
129 129
 
130 130
 
131 131
 }//end class
Please login to merge, or discard this patch.
vendor/squizlabs/php_codesniffer/src/Reports/Emacs.php 2 patches
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -15,76 +15,76 @@
 block discarded – undo
15 15
 {
16 16
 
17 17
 
18
-    /**
19
-     * Generate a partial report for a single processed file.
20
-     *
21
-     * Function should return TRUE if it printed or stored data about the file
22
-     * and FALSE if it ignored the file. Returning TRUE indicates that the file and
23
-     * its data should be counted in the grand totals.
24
-     *
25
-     * @param array                 $report      Prepared report data.
26
-     * @param \PHP_CodeSniffer\File $phpcsFile   The file being reported on.
27
-     * @param bool                  $showSources Show sources?
28
-     * @param int                   $width       Maximum allowed line width.
29
-     *
30
-     * @return bool
31
-     */
32
-    public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80)
33
-    {
34
-        if ($report['errors'] === 0 && $report['warnings'] === 0) {
35
-            // Nothing to print.
36
-            return false;
37
-        }
18
+	/**
19
+	 * Generate a partial report for a single processed file.
20
+	 *
21
+	 * Function should return TRUE if it printed or stored data about the file
22
+	 * and FALSE if it ignored the file. Returning TRUE indicates that the file and
23
+	 * its data should be counted in the grand totals.
24
+	 *
25
+	 * @param array                 $report      Prepared report data.
26
+	 * @param \PHP_CodeSniffer\File $phpcsFile   The file being reported on.
27
+	 * @param bool                  $showSources Show sources?
28
+	 * @param int                   $width       Maximum allowed line width.
29
+	 *
30
+	 * @return bool
31
+	 */
32
+	public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80)
33
+	{
34
+		if ($report['errors'] === 0 && $report['warnings'] === 0) {
35
+			// Nothing to print.
36
+			return false;
37
+		}
38 38
 
39
-        foreach ($report['messages'] as $line => $lineErrors) {
40
-            foreach ($lineErrors as $column => $colErrors) {
41
-                foreach ($colErrors as $error) {
42
-                    $message = $error['message'];
43
-                    if ($showSources === true) {
44
-                        $message .= ' ('.$error['source'].')';
45
-                    }
39
+		foreach ($report['messages'] as $line => $lineErrors) {
40
+			foreach ($lineErrors as $column => $colErrors) {
41
+				foreach ($colErrors as $error) {
42
+					$message = $error['message'];
43
+					if ($showSources === true) {
44
+						$message .= ' ('.$error['source'].')';
45
+					}
46 46
 
47
-                    $type = strtolower($error['type']);
48
-                    echo $report['filename'].':'.$line.':'.$column.': '.$type.' - '.$message.PHP_EOL;
49
-                }
50
-            }
51
-        }
47
+					$type = strtolower($error['type']);
48
+					echo $report['filename'].':'.$line.':'.$column.': '.$type.' - '.$message.PHP_EOL;
49
+				}
50
+			}
51
+		}
52 52
 
53
-        return true;
53
+		return true;
54 54
 
55
-    }//end generateFileReport()
55
+	}//end generateFileReport()
56 56
 
57 57
 
58
-    /**
59
-     * Generates an emacs report.
60
-     *
61
-     * @param string $cachedData    Any partial report data that was returned from
62
-     *                              generateFileReport during the run.
63
-     * @param int    $totalFiles    Total number of files processed during the run.
64
-     * @param int    $totalErrors   Total number of errors found during the run.
65
-     * @param int    $totalWarnings Total number of warnings found during the run.
66
-     * @param int    $totalFixable  Total number of problems that can be fixed.
67
-     * @param bool   $showSources   Show sources?
68
-     * @param int    $width         Maximum allowed line width.
69
-     * @param bool   $interactive   Are we running in interactive mode?
70
-     * @param bool   $toScreen      Is the report being printed to screen?
71
-     *
72
-     * @return void
73
-     */
74
-    public function generate(
75
-        $cachedData,
76
-        $totalFiles,
77
-        $totalErrors,
78
-        $totalWarnings,
79
-        $totalFixable,
80
-        $showSources=false,
81
-        $width=80,
82
-        $interactive=false,
83
-        $toScreen=true
84
-    ) {
85
-        echo $cachedData;
58
+	/**
59
+	 * Generates an emacs report.
60
+	 *
61
+	 * @param string $cachedData    Any partial report data that was returned from
62
+	 *                              generateFileReport during the run.
63
+	 * @param int    $totalFiles    Total number of files processed during the run.
64
+	 * @param int    $totalErrors   Total number of errors found during the run.
65
+	 * @param int    $totalWarnings Total number of warnings found during the run.
66
+	 * @param int    $totalFixable  Total number of problems that can be fixed.
67
+	 * @param bool   $showSources   Show sources?
68
+	 * @param int    $width         Maximum allowed line width.
69
+	 * @param bool   $interactive   Are we running in interactive mode?
70
+	 * @param bool   $toScreen      Is the report being printed to screen?
71
+	 *
72
+	 * @return void
73
+	 */
74
+	public function generate(
75
+		$cachedData,
76
+		$totalFiles,
77
+		$totalErrors,
78
+		$totalWarnings,
79
+		$totalFixable,
80
+		$showSources=false,
81
+		$width=80,
82
+		$interactive=false,
83
+		$toScreen=true
84
+	) {
85
+		echo $cachedData;
86 86
 
87
-    }//end generate()
87
+	}//end generate()
88 88
 
89 89
 
90 90
 }//end class
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
      *
30 30
      * @return bool
31 31
      */
32
-    public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80)
32
+    public function generateFileReport($report, File $phpcsFile, $showSources = false, $width = 80)
33 33
     {
34 34
         if ($report['errors'] === 0 && $report['warnings'] === 0) {
35 35
             // Nothing to print.
@@ -77,10 +77,10 @@  discard block
 block discarded – undo
77 77
         $totalErrors,
78 78
         $totalWarnings,
79 79
         $totalFixable,
80
-        $showSources=false,
81
-        $width=80,
82
-        $interactive=false,
83
-        $toScreen=true
80
+        $showSources = false,
81
+        $width = 80,
82
+        $interactive = false,
83
+        $toScreen = true
84 84
     ) {
85 85
         echo $cachedData;
86 86
 
Please login to merge, or discard this patch.
vendor/squizlabs/php_codesniffer/src/Reports/Xml.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
      *
31 31
      * @return bool
32 32
      */
33
-    public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80)
33
+    public function generateFileReport($report, File $phpcsFile, $showSources = false, $width = 80)
34 34
     {
35 35
         $out = new \XMLWriter;
36 36
         $out->openMemory();
@@ -105,10 +105,10 @@  discard block
 block discarded – undo
105 105
         $totalErrors,
106 106
         $totalWarnings,
107 107
         $totalFixable,
108
-        $showSources=false,
109
-        $width=80,
110
-        $interactive=false,
111
-        $toScreen=true
108
+        $showSources = false,
109
+        $width = 80,
110
+        $interactive = false,
111
+        $toScreen = true
112 112
     ) {
113 113
         echo '<?xml version="1.0" encoding="UTF-8"?>'.PHP_EOL;
114 114
         echo '<phpcs version="'.Config::VERSION.'">'.PHP_EOL;
Please login to merge, or discard this patch.
Indentation   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -16,111 +16,111 @@
 block discarded – undo
16 16
 {
17 17
 
18 18
 
19
-    /**
20
-     * Generate a partial report for a single processed file.
21
-     *
22
-     * Function should return TRUE if it printed or stored data about the file
23
-     * and FALSE if it ignored the file. Returning TRUE indicates that the file and
24
-     * its data should be counted in the grand totals.
25
-     *
26
-     * @param array                 $report      Prepared report data.
27
-     * @param \PHP_CodeSniffer\File $phpcsFile   The file being reported on.
28
-     * @param bool                  $showSources Show sources?
29
-     * @param int                   $width       Maximum allowed line width.
30
-     *
31
-     * @return bool
32
-     */
33
-    public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80)
34
-    {
35
-        $out = new \XMLWriter;
36
-        $out->openMemory();
37
-        $out->setIndent(true);
38
-        $out->setIndentString('    ');
39
-        $out->startDocument('1.0', 'UTF-8');
40
-
41
-        if ($report['errors'] === 0 && $report['warnings'] === 0) {
42
-            // Nothing to print.
43
-            return false;
44
-        }
45
-
46
-        $out->startElement('file');
47
-        $out->writeAttribute('name', $report['filename']);
48
-        $out->writeAttribute('errors', $report['errors']);
49
-        $out->writeAttribute('warnings', $report['warnings']);
50
-        $out->writeAttribute('fixable', $report['fixable']);
51
-
52
-        foreach ($report['messages'] as $line => $lineErrors) {
53
-            foreach ($lineErrors as $column => $colErrors) {
54
-                foreach ($colErrors as $error) {
55
-                    $error['type'] = strtolower($error['type']);
56
-                    if ($phpcsFile->config->encoding !== 'utf-8') {
57
-                        $error['message'] = iconv($phpcsFile->config->encoding, 'utf-8', $error['message']);
58
-                    }
59
-
60
-                    $out->startElement($error['type']);
61
-                    $out->writeAttribute('line', $line);
62
-                    $out->writeAttribute('column', $column);
63
-                    $out->writeAttribute('source', $error['source']);
64
-                    $out->writeAttribute('severity', $error['severity']);
65
-                    $out->writeAttribute('fixable', (int) $error['fixable']);
66
-                    $out->text($error['message']);
67
-                    $out->endElement();
68
-                }
69
-            }
70
-        }//end foreach
71
-
72
-        $out->endElement();
73
-
74
-        // Remove the start of the document because we will
75
-        // add that manually later. We only have it in here to
76
-        // properly set the encoding.
77
-        $content = $out->flush();
78
-        if (strpos($content, PHP_EOL) !== false) {
79
-            $content = substr($content, (strpos($content, PHP_EOL) + strlen(PHP_EOL)));
80
-        } else if (strpos($content, "\n") !== false) {
81
-            $content = substr($content, (strpos($content, "\n") + 1));
82
-        }
83
-
84
-        echo $content;
85
-
86
-        return true;
87
-
88
-    }//end generateFileReport()
89
-
90
-
91
-    /**
92
-     * Prints all violations for processed files, in a proprietary XML format.
93
-     *
94
-     * @param string $cachedData    Any partial report data that was returned from
95
-     *                              generateFileReport during the run.
96
-     * @param int    $totalFiles    Total number of files processed during the run.
97
-     * @param int    $totalErrors   Total number of errors found during the run.
98
-     * @param int    $totalWarnings Total number of warnings found during the run.
99
-     * @param int    $totalFixable  Total number of problems that can be fixed.
100
-     * @param bool   $showSources   Show sources?
101
-     * @param int    $width         Maximum allowed line width.
102
-     * @param bool   $interactive   Are we running in interactive mode?
103
-     * @param bool   $toScreen      Is the report being printed to screen?
104
-     *
105
-     * @return void
106
-     */
107
-    public function generate(
108
-        $cachedData,
109
-        $totalFiles,
110
-        $totalErrors,
111
-        $totalWarnings,
112
-        $totalFixable,
113
-        $showSources=false,
114
-        $width=80,
115
-        $interactive=false,
116
-        $toScreen=true
117
-    ) {
118
-        echo '<?xml version="1.0" encoding="UTF-8"?>'.PHP_EOL;
119
-        echo '<phpcs version="'.Config::VERSION.'">'.PHP_EOL;
120
-        echo $cachedData;
121
-        echo '</phpcs>'.PHP_EOL;
122
-
123
-    }//end generate()
19
+	/**
20
+	 * Generate a partial report for a single processed file.
21
+	 *
22
+	 * Function should return TRUE if it printed or stored data about the file
23
+	 * and FALSE if it ignored the file. Returning TRUE indicates that the file and
24
+	 * its data should be counted in the grand totals.
25
+	 *
26
+	 * @param array                 $report      Prepared report data.
27
+	 * @param \PHP_CodeSniffer\File $phpcsFile   The file being reported on.
28
+	 * @param bool                  $showSources Show sources?
29
+	 * @param int                   $width       Maximum allowed line width.
30
+	 *
31
+	 * @return bool
32
+	 */
33
+	public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80)
34
+	{
35
+		$out = new \XMLWriter;
36
+		$out->openMemory();
37
+		$out->setIndent(true);
38
+		$out->setIndentString('    ');
39
+		$out->startDocument('1.0', 'UTF-8');
40
+
41
+		if ($report['errors'] === 0 && $report['warnings'] === 0) {
42
+			// Nothing to print.
43
+			return false;
44
+		}
45
+
46
+		$out->startElement('file');
47
+		$out->writeAttribute('name', $report['filename']);
48
+		$out->writeAttribute('errors', $report['errors']);
49
+		$out->writeAttribute('warnings', $report['warnings']);
50
+		$out->writeAttribute('fixable', $report['fixable']);
51
+
52
+		foreach ($report['messages'] as $line => $lineErrors) {
53
+			foreach ($lineErrors as $column => $colErrors) {
54
+				foreach ($colErrors as $error) {
55
+					$error['type'] = strtolower($error['type']);
56
+					if ($phpcsFile->config->encoding !== 'utf-8') {
57
+						$error['message'] = iconv($phpcsFile->config->encoding, 'utf-8', $error['message']);
58
+					}
59
+
60
+					$out->startElement($error['type']);
61
+					$out->writeAttribute('line', $line);
62
+					$out->writeAttribute('column', $column);
63
+					$out->writeAttribute('source', $error['source']);
64
+					$out->writeAttribute('severity', $error['severity']);
65
+					$out->writeAttribute('fixable', (int) $error['fixable']);
66
+					$out->text($error['message']);
67
+					$out->endElement();
68
+				}
69
+			}
70
+		}//end foreach
71
+
72
+		$out->endElement();
73
+
74
+		// Remove the start of the document because we will
75
+		// add that manually later. We only have it in here to
76
+		// properly set the encoding.
77
+		$content = $out->flush();
78
+		if (strpos($content, PHP_EOL) !== false) {
79
+			$content = substr($content, (strpos($content, PHP_EOL) + strlen(PHP_EOL)));
80
+		} else if (strpos($content, "\n") !== false) {
81
+			$content = substr($content, (strpos($content, "\n") + 1));
82
+		}
83
+
84
+		echo $content;
85
+
86
+		return true;
87
+
88
+	}//end generateFileReport()
89
+
90
+
91
+	/**
92
+	 * Prints all violations for processed files, in a proprietary XML format.
93
+	 *
94
+	 * @param string $cachedData    Any partial report data that was returned from
95
+	 *                              generateFileReport during the run.
96
+	 * @param int    $totalFiles    Total number of files processed during the run.
97
+	 * @param int    $totalErrors   Total number of errors found during the run.
98
+	 * @param int    $totalWarnings Total number of warnings found during the run.
99
+	 * @param int    $totalFixable  Total number of problems that can be fixed.
100
+	 * @param bool   $showSources   Show sources?
101
+	 * @param int    $width         Maximum allowed line width.
102
+	 * @param bool   $interactive   Are we running in interactive mode?
103
+	 * @param bool   $toScreen      Is the report being printed to screen?
104
+	 *
105
+	 * @return void
106
+	 */
107
+	public function generate(
108
+		$cachedData,
109
+		$totalFiles,
110
+		$totalErrors,
111
+		$totalWarnings,
112
+		$totalFixable,
113
+		$showSources=false,
114
+		$width=80,
115
+		$interactive=false,
116
+		$toScreen=true
117
+	) {
118
+		echo '<?xml version="1.0" encoding="UTF-8"?>'.PHP_EOL;
119
+		echo '<phpcs version="'.Config::VERSION.'">'.PHP_EOL;
120
+		echo $cachedData;
121
+		echo '</phpcs>'.PHP_EOL;
122
+
123
+	}//end generate()
124 124
 
125 125
 
126 126
 }//end class
Please login to merge, or discard this patch.
vendor/squizlabs/php_codesniffer/src/Reports/Source.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
      *
31 31
      * @return bool
32 32
      */
33
-    public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80)
33
+    public function generateFileReport($report, File $phpcsFile, $showSources = false, $width = 80)
34 34
     {
35 35
         if ($report['errors'] === 0 && $report['warnings'] === 0) {
36 36
             // Nothing to print.
@@ -86,10 +86,10 @@  discard block
 block discarded – undo
86 86
         $totalErrors,
87 87
         $totalWarnings,
88 88
         $totalFixable,
89
-        $showSources=false,
90
-        $width=80,
91
-        $interactive=false,
92
-        $toScreen=true
89
+        $showSources = false,
90
+        $width = 80,
91
+        $interactive = false,
92
+        $toScreen = true
93 93
     ) {
94 94
         $lines = explode(PHP_EOL, $cachedData);
95 95
         array_pop($lines);
Please login to merge, or discard this patch.
Indentation   +315 added lines, -315 removed lines patch added patch discarded remove patch
@@ -16,321 +16,321 @@
 block discarded – undo
16 16
 {
17 17
 
18 18
 
19
-    /**
20
-     * Generate a partial report for a single processed file.
21
-     *
22
-     * Function should return TRUE if it printed or stored data about the file
23
-     * and FALSE if it ignored the file. Returning TRUE indicates that the file and
24
-     * its data should be counted in the grand totals.
25
-     *
26
-     * @param array                 $report      Prepared report data.
27
-     * @param \PHP_CodeSniffer\File $phpcsFile   The file being reported on.
28
-     * @param bool                  $showSources Show sources?
29
-     * @param int                   $width       Maximum allowed line width.
30
-     *
31
-     * @return bool
32
-     */
33
-    public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80)
34
-    {
35
-        if ($report['errors'] === 0 && $report['warnings'] === 0) {
36
-            // Nothing to print.
37
-            return false;
38
-        }
39
-
40
-        $sources = [];
41
-
42
-        foreach ($report['messages'] as $line => $lineErrors) {
43
-            foreach ($lineErrors as $column => $colErrors) {
44
-                foreach ($colErrors as $error) {
45
-                    $src = $error['source'];
46
-                    if (isset($sources[$src]) === false) {
47
-                        $sources[$src] = [
48
-                            'fixable' => (int) $error['fixable'],
49
-                            'count'   => 1,
50
-                        ];
51
-                    } else {
52
-                        $sources[$src]['count']++;
53
-                    }
54
-                }
55
-            }
56
-        }
57
-
58
-        foreach ($sources as $source => $data) {
59
-            echo $source.'>>'.$data['fixable'].'>>'.$data['count'].PHP_EOL;
60
-        }
61
-
62
-        return true;
63
-
64
-    }//end generateFileReport()
65
-
66
-
67
-    /**
68
-     * Prints the source of all errors and warnings.
69
-     *
70
-     * @param string $cachedData    Any partial report data that was returned from
71
-     *                              generateFileReport during the run.
72
-     * @param int    $totalFiles    Total number of files processed during the run.
73
-     * @param int    $totalErrors   Total number of errors found during the run.
74
-     * @param int    $totalWarnings Total number of warnings found during the run.
75
-     * @param int    $totalFixable  Total number of problems that can be fixed.
76
-     * @param bool   $showSources   Show sources?
77
-     * @param int    $width         Maximum allowed line width.
78
-     * @param bool   $interactive   Are we running in interactive mode?
79
-     * @param bool   $toScreen      Is the report being printed to screen?
80
-     *
81
-     * @return void
82
-     */
83
-    public function generate(
84
-        $cachedData,
85
-        $totalFiles,
86
-        $totalErrors,
87
-        $totalWarnings,
88
-        $totalFixable,
89
-        $showSources=false,
90
-        $width=80,
91
-        $interactive=false,
92
-        $toScreen=true
93
-    ) {
94
-        $lines = explode(PHP_EOL, $cachedData);
95
-        array_pop($lines);
96
-
97
-        if (empty($lines) === true) {
98
-            return;
99
-        }
100
-
101
-        $sources   = [];
102
-        $maxLength = 0;
103
-
104
-        foreach ($lines as $line) {
105
-            $parts   = explode('>>', $line);
106
-            $source  = $parts[0];
107
-            $fixable = (bool) $parts[1];
108
-            $count   = $parts[2];
109
-
110
-            if (isset($sources[$source]) === false) {
111
-                if ($showSources === true) {
112
-                    $parts = null;
113
-                    $sniff = $source;
114
-                } else {
115
-                    $parts = explode('.', $source);
116
-                    if ($parts[0] === 'Internal') {
117
-                        $parts[2] = $parts[1];
118
-                        $parts[1] = '';
119
-                    }
120
-
121
-                    $parts[1] = $this->makeFriendlyName($parts[1]);
122
-
123
-                    $sniff = $this->makeFriendlyName($parts[2]);
124
-                    if (isset($parts[3]) === true) {
125
-                        $name    = $this->makeFriendlyName($parts[3]);
126
-                        $name[0] = strtolower($name[0]);
127
-                        $sniff  .= ' '.$name;
128
-                        unset($parts[3]);
129
-                    }
130
-
131
-                    $parts[2] = $sniff;
132
-                }//end if
133
-
134
-                $maxLength = max($maxLength, strlen($sniff));
135
-
136
-                $sources[$source] = [
137
-                    'count'   => $count,
138
-                    'fixable' => $fixable,
139
-                    'parts'   => $parts,
140
-                ];
141
-            } else {
142
-                $sources[$source]['count'] += $count;
143
-            }//end if
144
-        }//end foreach
145
-
146
-        if ($showSources === true) {
147
-            $width = min($width, ($maxLength + 11));
148
-        } else {
149
-            $width = min($width, ($maxLength + 41));
150
-        }
151
-
152
-        $width = max($width, 70);
153
-
154
-        // Sort the data based on counts and source code.
155
-        $sourceCodes = array_keys($sources);
156
-        $counts      = [];
157
-        foreach ($sources as $source => $data) {
158
-            $counts[$source] = $data['count'];
159
-        }
160
-
161
-        array_multisort($counts, SORT_DESC, $sourceCodes, SORT_ASC, SORT_NATURAL, $sources);
162
-
163
-        echo PHP_EOL."\033[1mPHP CODE SNIFFER VIOLATION SOURCE SUMMARY\033[0m".PHP_EOL;
164
-        echo str_repeat('-', $width).PHP_EOL."\033[1m";
165
-        if ($showSources === true) {
166
-            if ($totalFixable > 0) {
167
-                echo '    SOURCE'.str_repeat(' ', ($width - 15)).'COUNT'.PHP_EOL;
168
-            } else {
169
-                echo 'SOURCE'.str_repeat(' ', ($width - 11)).'COUNT'.PHP_EOL;
170
-            }
171
-        } else {
172
-            if ($totalFixable > 0) {
173
-                echo '    STANDARD  CATEGORY            SNIFF'.str_repeat(' ', ($width - 44)).'COUNT'.PHP_EOL;
174
-            } else {
175
-                echo 'STANDARD  CATEGORY            SNIFF'.str_repeat(' ', ($width - 40)).'COUNT'.PHP_EOL;
176
-            }
177
-        }
178
-
179
-        echo "\033[0m".str_repeat('-', $width).PHP_EOL;
180
-
181
-        $fixableSources = 0;
182
-
183
-        if ($showSources === true) {
184
-            $maxSniffWidth = ($width - 7);
185
-        } else {
186
-            $maxSniffWidth = ($width - 37);
187
-        }
188
-
189
-        if ($totalFixable > 0) {
190
-            $maxSniffWidth -= 4;
191
-        }
192
-
193
-        foreach ($sources as $source => $sourceData) {
194
-            if ($totalFixable > 0) {
195
-                echo '[';
196
-                if ($sourceData['fixable'] === true) {
197
-                    echo 'x';
198
-                    $fixableSources++;
199
-                } else {
200
-                    echo ' ';
201
-                }
202
-
203
-                echo '] ';
204
-            }
205
-
206
-            if ($showSources === true) {
207
-                if (strlen($source) > $maxSniffWidth) {
208
-                    $source = substr($source, 0, $maxSniffWidth);
209
-                }
210
-
211
-                echo $source;
212
-                if ($totalFixable > 0) {
213
-                    echo str_repeat(' ', ($width - 9 - strlen($source)));
214
-                } else {
215
-                    echo str_repeat(' ', ($width - 5 - strlen($source)));
216
-                }
217
-            } else {
218
-                $parts = $sourceData['parts'];
219
-
220
-                if (strlen($parts[0]) > 8) {
221
-                    $parts[0] = substr($parts[0], 0, ((strlen($parts[0]) - 8) * -1));
222
-                }
223
-
224
-                echo $parts[0].str_repeat(' ', (10 - strlen($parts[0])));
225
-
226
-                $category = $parts[1];
227
-                if (strlen($category) > 18) {
228
-                    $category = substr($category, 0, ((strlen($category) - 18) * -1));
229
-                }
230
-
231
-                echo $category.str_repeat(' ', (20 - strlen($category)));
232
-
233
-                $sniff = $parts[2];
234
-                if (strlen($sniff) > $maxSniffWidth) {
235
-                    $sniff = substr($sniff, 0, $maxSniffWidth);
236
-                }
237
-
238
-                if ($totalFixable > 0) {
239
-                    echo $sniff.str_repeat(' ', ($width - 39 - strlen($sniff)));
240
-                } else {
241
-                    echo $sniff.str_repeat(' ', ($width - 35 - strlen($sniff)));
242
-                }
243
-            }//end if
244
-
245
-            echo $sourceData['count'].PHP_EOL;
246
-        }//end foreach
247
-
248
-        echo str_repeat('-', $width).PHP_EOL;
249
-        echo "\033[1m".'A TOTAL OF '.($totalErrors + $totalWarnings).' SNIFF VIOLATION';
250
-        if (($totalErrors + $totalWarnings) > 1) {
251
-            echo 'S';
252
-        }
253
-
254
-        echo ' WERE FOUND IN '.count($sources).' SOURCE';
255
-        if (count($sources) !== 1) {
256
-            echo 'S';
257
-        }
258
-
259
-        echo "\033[0m";
260
-
261
-        if ($totalFixable > 0) {
262
-            echo PHP_EOL.str_repeat('-', $width).PHP_EOL;
263
-            echo "\033[1mPHPCBF CAN FIX THE $fixableSources MARKED SOURCES AUTOMATICALLY ($totalFixable VIOLATIONS IN TOTAL)\033[0m";
264
-        }
265
-
266
-        echo PHP_EOL.str_repeat('-', $width).PHP_EOL.PHP_EOL;
267
-
268
-        if ($toScreen === true && $interactive === false) {
269
-            Timing::printRunTime();
270
-        }
271
-
272
-    }//end generate()
273
-
274
-
275
-    /**
276
-     * Converts a camel caps name into a readable string.
277
-     *
278
-     * @param string $name The camel caps name to convert.
279
-     *
280
-     * @return string
281
-     */
282
-    public function makeFriendlyName($name)
283
-    {
284
-        if (trim($name) === '') {
285
-            return '';
286
-        }
287
-
288
-        $friendlyName = '';
289
-        $length       = strlen($name);
290
-
291
-        $lastWasUpper   = false;
292
-        $lastWasNumeric = false;
293
-        for ($i = 0; $i < $length; $i++) {
294
-            if (is_numeric($name[$i]) === true) {
295
-                if ($lastWasNumeric === false) {
296
-                    $friendlyName .= ' ';
297
-                }
298
-
299
-                $lastWasUpper   = false;
300
-                $lastWasNumeric = true;
301
-            } else {
302
-                $lastWasNumeric = false;
303
-
304
-                $char = strtolower($name[$i]);
305
-                if ($char === $name[$i]) {
306
-                    // Lowercase.
307
-                    $lastWasUpper = false;
308
-                } else {
309
-                    // Uppercase.
310
-                    if ($lastWasUpper === false) {
311
-                        $friendlyName .= ' ';
312
-                        if ($i < ($length - 1)) {
313
-                            $next = $name[($i + 1)];
314
-                            if (strtolower($next) === $next) {
315
-                                // Next char is lowercase so it is a word boundary.
316
-                                $name[$i] = strtolower($name[$i]);
317
-                            }
318
-                        }
319
-                    }
320
-
321
-                    $lastWasUpper = true;
322
-                }
323
-            }//end if
324
-
325
-            $friendlyName .= $name[$i];
326
-        }//end for
327
-
328
-        $friendlyName    = trim($friendlyName);
329
-        $friendlyName[0] = strtoupper($friendlyName[0]);
330
-
331
-        return $friendlyName;
332
-
333
-    }//end makeFriendlyName()
19
+	/**
20
+	 * Generate a partial report for a single processed file.
21
+	 *
22
+	 * Function should return TRUE if it printed or stored data about the file
23
+	 * and FALSE if it ignored the file. Returning TRUE indicates that the file and
24
+	 * its data should be counted in the grand totals.
25
+	 *
26
+	 * @param array                 $report      Prepared report data.
27
+	 * @param \PHP_CodeSniffer\File $phpcsFile   The file being reported on.
28
+	 * @param bool                  $showSources Show sources?
29
+	 * @param int                   $width       Maximum allowed line width.
30
+	 *
31
+	 * @return bool
32
+	 */
33
+	public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80)
34
+	{
35
+		if ($report['errors'] === 0 && $report['warnings'] === 0) {
36
+			// Nothing to print.
37
+			return false;
38
+		}
39
+
40
+		$sources = [];
41
+
42
+		foreach ($report['messages'] as $line => $lineErrors) {
43
+			foreach ($lineErrors as $column => $colErrors) {
44
+				foreach ($colErrors as $error) {
45
+					$src = $error['source'];
46
+					if (isset($sources[$src]) === false) {
47
+						$sources[$src] = [
48
+							'fixable' => (int) $error['fixable'],
49
+							'count'   => 1,
50
+						];
51
+					} else {
52
+						$sources[$src]['count']++;
53
+					}
54
+				}
55
+			}
56
+		}
57
+
58
+		foreach ($sources as $source => $data) {
59
+			echo $source.'>>'.$data['fixable'].'>>'.$data['count'].PHP_EOL;
60
+		}
61
+
62
+		return true;
63
+
64
+	}//end generateFileReport()
65
+
66
+
67
+	/**
68
+	 * Prints the source of all errors and warnings.
69
+	 *
70
+	 * @param string $cachedData    Any partial report data that was returned from
71
+	 *                              generateFileReport during the run.
72
+	 * @param int    $totalFiles    Total number of files processed during the run.
73
+	 * @param int    $totalErrors   Total number of errors found during the run.
74
+	 * @param int    $totalWarnings Total number of warnings found during the run.
75
+	 * @param int    $totalFixable  Total number of problems that can be fixed.
76
+	 * @param bool   $showSources   Show sources?
77
+	 * @param int    $width         Maximum allowed line width.
78
+	 * @param bool   $interactive   Are we running in interactive mode?
79
+	 * @param bool   $toScreen      Is the report being printed to screen?
80
+	 *
81
+	 * @return void
82
+	 */
83
+	public function generate(
84
+		$cachedData,
85
+		$totalFiles,
86
+		$totalErrors,
87
+		$totalWarnings,
88
+		$totalFixable,
89
+		$showSources=false,
90
+		$width=80,
91
+		$interactive=false,
92
+		$toScreen=true
93
+	) {
94
+		$lines = explode(PHP_EOL, $cachedData);
95
+		array_pop($lines);
96
+
97
+		if (empty($lines) === true) {
98
+			return;
99
+		}
100
+
101
+		$sources   = [];
102
+		$maxLength = 0;
103
+
104
+		foreach ($lines as $line) {
105
+			$parts   = explode('>>', $line);
106
+			$source  = $parts[0];
107
+			$fixable = (bool) $parts[1];
108
+			$count   = $parts[2];
109
+
110
+			if (isset($sources[$source]) === false) {
111
+				if ($showSources === true) {
112
+					$parts = null;
113
+					$sniff = $source;
114
+				} else {
115
+					$parts = explode('.', $source);
116
+					if ($parts[0] === 'Internal') {
117
+						$parts[2] = $parts[1];
118
+						$parts[1] = '';
119
+					}
120
+
121
+					$parts[1] = $this->makeFriendlyName($parts[1]);
122
+
123
+					$sniff = $this->makeFriendlyName($parts[2]);
124
+					if (isset($parts[3]) === true) {
125
+						$name    = $this->makeFriendlyName($parts[3]);
126
+						$name[0] = strtolower($name[0]);
127
+						$sniff  .= ' '.$name;
128
+						unset($parts[3]);
129
+					}
130
+
131
+					$parts[2] = $sniff;
132
+				}//end if
133
+
134
+				$maxLength = max($maxLength, strlen($sniff));
135
+
136
+				$sources[$source] = [
137
+					'count'   => $count,
138
+					'fixable' => $fixable,
139
+					'parts'   => $parts,
140
+				];
141
+			} else {
142
+				$sources[$source]['count'] += $count;
143
+			}//end if
144
+		}//end foreach
145
+
146
+		if ($showSources === true) {
147
+			$width = min($width, ($maxLength + 11));
148
+		} else {
149
+			$width = min($width, ($maxLength + 41));
150
+		}
151
+
152
+		$width = max($width, 70);
153
+
154
+		// Sort the data based on counts and source code.
155
+		$sourceCodes = array_keys($sources);
156
+		$counts      = [];
157
+		foreach ($sources as $source => $data) {
158
+			$counts[$source] = $data['count'];
159
+		}
160
+
161
+		array_multisort($counts, SORT_DESC, $sourceCodes, SORT_ASC, SORT_NATURAL, $sources);
162
+
163
+		echo PHP_EOL."\033[1mPHP CODE SNIFFER VIOLATION SOURCE SUMMARY\033[0m".PHP_EOL;
164
+		echo str_repeat('-', $width).PHP_EOL."\033[1m";
165
+		if ($showSources === true) {
166
+			if ($totalFixable > 0) {
167
+				echo '    SOURCE'.str_repeat(' ', ($width - 15)).'COUNT'.PHP_EOL;
168
+			} else {
169
+				echo 'SOURCE'.str_repeat(' ', ($width - 11)).'COUNT'.PHP_EOL;
170
+			}
171
+		} else {
172
+			if ($totalFixable > 0) {
173
+				echo '    STANDARD  CATEGORY            SNIFF'.str_repeat(' ', ($width - 44)).'COUNT'.PHP_EOL;
174
+			} else {
175
+				echo 'STANDARD  CATEGORY            SNIFF'.str_repeat(' ', ($width - 40)).'COUNT'.PHP_EOL;
176
+			}
177
+		}
178
+
179
+		echo "\033[0m".str_repeat('-', $width).PHP_EOL;
180
+
181
+		$fixableSources = 0;
182
+
183
+		if ($showSources === true) {
184
+			$maxSniffWidth = ($width - 7);
185
+		} else {
186
+			$maxSniffWidth = ($width - 37);
187
+		}
188
+
189
+		if ($totalFixable > 0) {
190
+			$maxSniffWidth -= 4;
191
+		}
192
+
193
+		foreach ($sources as $source => $sourceData) {
194
+			if ($totalFixable > 0) {
195
+				echo '[';
196
+				if ($sourceData['fixable'] === true) {
197
+					echo 'x';
198
+					$fixableSources++;
199
+				} else {
200
+					echo ' ';
201
+				}
202
+
203
+				echo '] ';
204
+			}
205
+
206
+			if ($showSources === true) {
207
+				if (strlen($source) > $maxSniffWidth) {
208
+					$source = substr($source, 0, $maxSniffWidth);
209
+				}
210
+
211
+				echo $source;
212
+				if ($totalFixable > 0) {
213
+					echo str_repeat(' ', ($width - 9 - strlen($source)));
214
+				} else {
215
+					echo str_repeat(' ', ($width - 5 - strlen($source)));
216
+				}
217
+			} else {
218
+				$parts = $sourceData['parts'];
219
+
220
+				if (strlen($parts[0]) > 8) {
221
+					$parts[0] = substr($parts[0], 0, ((strlen($parts[0]) - 8) * -1));
222
+				}
223
+
224
+				echo $parts[0].str_repeat(' ', (10 - strlen($parts[0])));
225
+
226
+				$category = $parts[1];
227
+				if (strlen($category) > 18) {
228
+					$category = substr($category, 0, ((strlen($category) - 18) * -1));
229
+				}
230
+
231
+				echo $category.str_repeat(' ', (20 - strlen($category)));
232
+
233
+				$sniff = $parts[2];
234
+				if (strlen($sniff) > $maxSniffWidth) {
235
+					$sniff = substr($sniff, 0, $maxSniffWidth);
236
+				}
237
+
238
+				if ($totalFixable > 0) {
239
+					echo $sniff.str_repeat(' ', ($width - 39 - strlen($sniff)));
240
+				} else {
241
+					echo $sniff.str_repeat(' ', ($width - 35 - strlen($sniff)));
242
+				}
243
+			}//end if
244
+
245
+			echo $sourceData['count'].PHP_EOL;
246
+		}//end foreach
247
+
248
+		echo str_repeat('-', $width).PHP_EOL;
249
+		echo "\033[1m".'A TOTAL OF '.($totalErrors + $totalWarnings).' SNIFF VIOLATION';
250
+		if (($totalErrors + $totalWarnings) > 1) {
251
+			echo 'S';
252
+		}
253
+
254
+		echo ' WERE FOUND IN '.count($sources).' SOURCE';
255
+		if (count($sources) !== 1) {
256
+			echo 'S';
257
+		}
258
+
259
+		echo "\033[0m";
260
+
261
+		if ($totalFixable > 0) {
262
+			echo PHP_EOL.str_repeat('-', $width).PHP_EOL;
263
+			echo "\033[1mPHPCBF CAN FIX THE $fixableSources MARKED SOURCES AUTOMATICALLY ($totalFixable VIOLATIONS IN TOTAL)\033[0m";
264
+		}
265
+
266
+		echo PHP_EOL.str_repeat('-', $width).PHP_EOL.PHP_EOL;
267
+
268
+		if ($toScreen === true && $interactive === false) {
269
+			Timing::printRunTime();
270
+		}
271
+
272
+	}//end generate()
273
+
274
+
275
+	/**
276
+	 * Converts a camel caps name into a readable string.
277
+	 *
278
+	 * @param string $name The camel caps name to convert.
279
+	 *
280
+	 * @return string
281
+	 */
282
+	public function makeFriendlyName($name)
283
+	{
284
+		if (trim($name) === '') {
285
+			return '';
286
+		}
287
+
288
+		$friendlyName = '';
289
+		$length       = strlen($name);
290
+
291
+		$lastWasUpper   = false;
292
+		$lastWasNumeric = false;
293
+		for ($i = 0; $i < $length; $i++) {
294
+			if (is_numeric($name[$i]) === true) {
295
+				if ($lastWasNumeric === false) {
296
+					$friendlyName .= ' ';
297
+				}
298
+
299
+				$lastWasUpper   = false;
300
+				$lastWasNumeric = true;
301
+			} else {
302
+				$lastWasNumeric = false;
303
+
304
+				$char = strtolower($name[$i]);
305
+				if ($char === $name[$i]) {
306
+					// Lowercase.
307
+					$lastWasUpper = false;
308
+				} else {
309
+					// Uppercase.
310
+					if ($lastWasUpper === false) {
311
+						$friendlyName .= ' ';
312
+						if ($i < ($length - 1)) {
313
+							$next = $name[($i + 1)];
314
+							if (strtolower($next) === $next) {
315
+								// Next char is lowercase so it is a word boundary.
316
+								$name[$i] = strtolower($name[$i]);
317
+							}
318
+						}
319
+					}
320
+
321
+					$lastWasUpper = true;
322
+				}
323
+			}//end if
324
+
325
+			$friendlyName .= $name[$i];
326
+		}//end for
327
+
328
+		$friendlyName    = trim($friendlyName);
329
+		$friendlyName[0] = strtoupper($friendlyName[0]);
330
+
331
+		return $friendlyName;
332
+
333
+	}//end makeFriendlyName()
334 334
 
335 335
 
336 336
 }//end class
Please login to merge, or discard this patch.
vendor/squizlabs/php_codesniffer/src/Reports/Notifysend.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
      *
95 95
      * @return bool
96 96
      */
97
-    public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80)
97
+    public function generateFileReport($report, File $phpcsFile, $showSources = false, $width = 80)
98 98
     {
99 99
         echo $report['filename'].PHP_EOL;
100 100
 
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
         $totalErrors,
128 128
         $totalWarnings,
129 129
         $totalFixable,
130
-        $showSources=false,
131
-        $width=80,
132
-        $interactive=false,
133
-        $toScreen=true
130
+        $showSources = false,
131
+        $width = 80,
132
+        $interactive = false,
133
+        $toScreen = true
134 134
     ) {
135 135
         $checkedFiles = explode(PHP_EOL, trim($cachedData));
136 136
 
Please login to merge, or discard this patch.
Indentation   +214 added lines, -214 removed lines patch added patch discarded remove patch
@@ -23,220 +23,220 @@
 block discarded – undo
23 23
 class Notifysend implements Report
24 24
 {
25 25
 
26
-    /**
27
-     * Notification timeout in milliseconds.
28
-     *
29
-     * @var integer
30
-     */
31
-    protected $timeout = 3000;
32
-
33
-    /**
34
-     * Path to notify-send command.
35
-     *
36
-     * @var string
37
-     */
38
-    protected $path = 'notify-send';
39
-
40
-    /**
41
-     * Show "ok, all fine" messages.
42
-     *
43
-     * @var boolean
44
-     */
45
-    protected $showOk = true;
46
-
47
-    /**
48
-     * Version of installed notify-send executable.
49
-     *
50
-     * @var string
51
-     */
52
-    protected $version = null;
53
-
54
-
55
-    /**
56
-     * Load configuration data.
57
-     */
58
-    public function __construct()
59
-    {
60
-        $path = Config::getExecutablePath('notifysend');
61
-        if ($path !== null) {
62
-            $this->path = Common::escapeshellcmd($path);
63
-        }
64
-
65
-        $timeout = Config::getConfigData('notifysend_timeout');
66
-        if ($timeout !== null) {
67
-            $this->timeout = (int) $timeout;
68
-        }
69
-
70
-        $showOk = Config::getConfigData('notifysend_showok');
71
-        if ($showOk !== null) {
72
-            $this->showOk = (bool) $showOk;
73
-        }
74
-
75
-        $this->version = str_replace(
76
-            'notify-send ',
77
-            '',
78
-            exec($this->path.' --version')
79
-        );
80
-
81
-    }//end __construct()
82
-
83
-
84
-    /**
85
-     * Generate a partial report for a single processed file.
86
-     *
87
-     * Function should return TRUE if it printed or stored data about the file
88
-     * and FALSE if it ignored the file. Returning TRUE indicates that the file and
89
-     * its data should be counted in the grand totals.
90
-     *
91
-     * @param array                 $report      Prepared report data.
92
-     * @param \PHP_CodeSniffer\File $phpcsFile   The file being reported on.
93
-     * @param bool                  $showSources Show sources?
94
-     * @param int                   $width       Maximum allowed line width.
95
-     *
96
-     * @return bool
97
-     */
98
-    public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80)
99
-    {
100
-        echo $report['filename'].PHP_EOL;
101
-
102
-        // We want this file counted in the total number
103
-        // of checked files even if it has no errors.
104
-        return true;
105
-
106
-    }//end generateFileReport()
107
-
108
-
109
-    /**
110
-     * Generates a summary of errors and warnings for each file processed.
111
-     *
112
-     * @param string $cachedData    Any partial report data that was returned from
113
-     *                              generateFileReport during the run.
114
-     * @param int    $totalFiles    Total number of files processed during the run.
115
-     * @param int    $totalErrors   Total number of errors found during the run.
116
-     * @param int    $totalWarnings Total number of warnings found during the run.
117
-     * @param int    $totalFixable  Total number of problems that can be fixed.
118
-     * @param bool   $showSources   Show sources?
119
-     * @param int    $width         Maximum allowed line width.
120
-     * @param bool   $interactive   Are we running in interactive mode?
121
-     * @param bool   $toScreen      Is the report being printed to screen?
122
-     *
123
-     * @return void
124
-     */
125
-    public function generate(
126
-        $cachedData,
127
-        $totalFiles,
128
-        $totalErrors,
129
-        $totalWarnings,
130
-        $totalFixable,
131
-        $showSources=false,
132
-        $width=80,
133
-        $interactive=false,
134
-        $toScreen=true
135
-    ) {
136
-        $checkedFiles = explode(PHP_EOL, trim($cachedData));
137
-
138
-        $msg = $this->generateMessage($checkedFiles, $totalErrors, $totalWarnings);
139
-        if ($msg === null) {
140
-            if ($this->showOk === true) {
141
-                $this->notifyAllFine();
142
-            }
143
-        } else {
144
-            $this->notifyErrors($msg);
145
-        }
146
-
147
-    }//end generate()
148
-
149
-
150
-    /**
151
-     * Generate the error message to show to the user.
152
-     *
153
-     * @param string[] $checkedFiles  The files checked during the run.
154
-     * @param int      $totalErrors   Total number of errors found during the run.
155
-     * @param int      $totalWarnings Total number of warnings found during the run.
156
-     *
157
-     * @return string Error message or NULL if no error/warning found.
158
-     */
159
-    protected function generateMessage($checkedFiles, $totalErrors, $totalWarnings)
160
-    {
161
-        if ($totalErrors === 0 && $totalWarnings === 0) {
162
-            // Nothing to print.
163
-            return null;
164
-        }
165
-
166
-        $totalFiles = count($checkedFiles);
167
-
168
-        $msg = '';
169
-        if ($totalFiles > 1) {
170
-            $msg .= 'Checked '.$totalFiles.' files'.PHP_EOL;
171
-        } else {
172
-            $msg .= $checkedFiles[0].PHP_EOL;
173
-        }
174
-
175
-        if ($totalWarnings > 0) {
176
-            $msg .= $totalWarnings.' warnings'.PHP_EOL;
177
-        }
178
-
179
-        if ($totalErrors > 0) {
180
-            $msg .= $totalErrors.' errors'.PHP_EOL;
181
-        }
182
-
183
-        return $msg;
184
-
185
-    }//end generateMessage()
186
-
187
-
188
-    /**
189
-     * Tell the user that all is fine and no error/warning has been found.
190
-     *
191
-     * @return void
192
-     */
193
-    protected function notifyAllFine()
194
-    {
195
-        $cmd  = $this->getBasicCommand();
196
-        $cmd .= ' -i info';
197
-        $cmd .= ' "PHP CodeSniffer: Ok"';
198
-        $cmd .= ' "All fine"';
199
-        exec($cmd);
200
-
201
-    }//end notifyAllFine()
202
-
203
-
204
-    /**
205
-     * Tell the user that errors/warnings have been found.
206
-     *
207
-     * @param string $msg Message to display.
208
-     *
209
-     * @return void
210
-     */
211
-    protected function notifyErrors($msg)
212
-    {
213
-        $cmd  = $this->getBasicCommand();
214
-        $cmd .= ' -i error';
215
-        $cmd .= ' "PHP CodeSniffer: Error"';
216
-        $cmd .= ' '.escapeshellarg(trim($msg));
217
-        exec($cmd);
218
-
219
-    }//end notifyErrors()
220
-
221
-
222
-    /**
223
-     * Generate and return the basic notify-send command string to execute.
224
-     *
225
-     * @return string Shell command with common parameters.
226
-     */
227
-    protected function getBasicCommand()
228
-    {
229
-        $cmd  = $this->path;
230
-        $cmd .= ' --category dev.validate';
231
-        $cmd .= ' -h int:transient:1';
232
-        $cmd .= ' -t '.(int) $this->timeout;
233
-        if (version_compare($this->version, '0.7.3', '>=') === true) {
234
-            $cmd .= ' -a phpcs';
235
-        }
236
-
237
-        return $cmd;
238
-
239
-    }//end getBasicCommand()
26
+	/**
27
+	 * Notification timeout in milliseconds.
28
+	 *
29
+	 * @var integer
30
+	 */
31
+	protected $timeout = 3000;
32
+
33
+	/**
34
+	 * Path to notify-send command.
35
+	 *
36
+	 * @var string
37
+	 */
38
+	protected $path = 'notify-send';
39
+
40
+	/**
41
+	 * Show "ok, all fine" messages.
42
+	 *
43
+	 * @var boolean
44
+	 */
45
+	protected $showOk = true;
46
+
47
+	/**
48
+	 * Version of installed notify-send executable.
49
+	 *
50
+	 * @var string
51
+	 */
52
+	protected $version = null;
53
+
54
+
55
+	/**
56
+	 * Load configuration data.
57
+	 */
58
+	public function __construct()
59
+	{
60
+		$path = Config::getExecutablePath('notifysend');
61
+		if ($path !== null) {
62
+			$this->path = Common::escapeshellcmd($path);
63
+		}
64
+
65
+		$timeout = Config::getConfigData('notifysend_timeout');
66
+		if ($timeout !== null) {
67
+			$this->timeout = (int) $timeout;
68
+		}
69
+
70
+		$showOk = Config::getConfigData('notifysend_showok');
71
+		if ($showOk !== null) {
72
+			$this->showOk = (bool) $showOk;
73
+		}
74
+
75
+		$this->version = str_replace(
76
+			'notify-send ',
77
+			'',
78
+			exec($this->path.' --version')
79
+		);
80
+
81
+	}//end __construct()
82
+
83
+
84
+	/**
85
+	 * Generate a partial report for a single processed file.
86
+	 *
87
+	 * Function should return TRUE if it printed or stored data about the file
88
+	 * and FALSE if it ignored the file. Returning TRUE indicates that the file and
89
+	 * its data should be counted in the grand totals.
90
+	 *
91
+	 * @param array                 $report      Prepared report data.
92
+	 * @param \PHP_CodeSniffer\File $phpcsFile   The file being reported on.
93
+	 * @param bool                  $showSources Show sources?
94
+	 * @param int                   $width       Maximum allowed line width.
95
+	 *
96
+	 * @return bool
97
+	 */
98
+	public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80)
99
+	{
100
+		echo $report['filename'].PHP_EOL;
101
+
102
+		// We want this file counted in the total number
103
+		// of checked files even if it has no errors.
104
+		return true;
105
+
106
+	}//end generateFileReport()
107
+
108
+
109
+	/**
110
+	 * Generates a summary of errors and warnings for each file processed.
111
+	 *
112
+	 * @param string $cachedData    Any partial report data that was returned from
113
+	 *                              generateFileReport during the run.
114
+	 * @param int    $totalFiles    Total number of files processed during the run.
115
+	 * @param int    $totalErrors   Total number of errors found during the run.
116
+	 * @param int    $totalWarnings Total number of warnings found during the run.
117
+	 * @param int    $totalFixable  Total number of problems that can be fixed.
118
+	 * @param bool   $showSources   Show sources?
119
+	 * @param int    $width         Maximum allowed line width.
120
+	 * @param bool   $interactive   Are we running in interactive mode?
121
+	 * @param bool   $toScreen      Is the report being printed to screen?
122
+	 *
123
+	 * @return void
124
+	 */
125
+	public function generate(
126
+		$cachedData,
127
+		$totalFiles,
128
+		$totalErrors,
129
+		$totalWarnings,
130
+		$totalFixable,
131
+		$showSources=false,
132
+		$width=80,
133
+		$interactive=false,
134
+		$toScreen=true
135
+	) {
136
+		$checkedFiles = explode(PHP_EOL, trim($cachedData));
137
+
138
+		$msg = $this->generateMessage($checkedFiles, $totalErrors, $totalWarnings);
139
+		if ($msg === null) {
140
+			if ($this->showOk === true) {
141
+				$this->notifyAllFine();
142
+			}
143
+		} else {
144
+			$this->notifyErrors($msg);
145
+		}
146
+
147
+	}//end generate()
148
+
149
+
150
+	/**
151
+	 * Generate the error message to show to the user.
152
+	 *
153
+	 * @param string[] $checkedFiles  The files checked during the run.
154
+	 * @param int      $totalErrors   Total number of errors found during the run.
155
+	 * @param int      $totalWarnings Total number of warnings found during the run.
156
+	 *
157
+	 * @return string Error message or NULL if no error/warning found.
158
+	 */
159
+	protected function generateMessage($checkedFiles, $totalErrors, $totalWarnings)
160
+	{
161
+		if ($totalErrors === 0 && $totalWarnings === 0) {
162
+			// Nothing to print.
163
+			return null;
164
+		}
165
+
166
+		$totalFiles = count($checkedFiles);
167
+
168
+		$msg = '';
169
+		if ($totalFiles > 1) {
170
+			$msg .= 'Checked '.$totalFiles.' files'.PHP_EOL;
171
+		} else {
172
+			$msg .= $checkedFiles[0].PHP_EOL;
173
+		}
174
+
175
+		if ($totalWarnings > 0) {
176
+			$msg .= $totalWarnings.' warnings'.PHP_EOL;
177
+		}
178
+
179
+		if ($totalErrors > 0) {
180
+			$msg .= $totalErrors.' errors'.PHP_EOL;
181
+		}
182
+
183
+		return $msg;
184
+
185
+	}//end generateMessage()
186
+
187
+
188
+	/**
189
+	 * Tell the user that all is fine and no error/warning has been found.
190
+	 *
191
+	 * @return void
192
+	 */
193
+	protected function notifyAllFine()
194
+	{
195
+		$cmd  = $this->getBasicCommand();
196
+		$cmd .= ' -i info';
197
+		$cmd .= ' "PHP CodeSniffer: Ok"';
198
+		$cmd .= ' "All fine"';
199
+		exec($cmd);
200
+
201
+	}//end notifyAllFine()
202
+
203
+
204
+	/**
205
+	 * Tell the user that errors/warnings have been found.
206
+	 *
207
+	 * @param string $msg Message to display.
208
+	 *
209
+	 * @return void
210
+	 */
211
+	protected function notifyErrors($msg)
212
+	{
213
+		$cmd  = $this->getBasicCommand();
214
+		$cmd .= ' -i error';
215
+		$cmd .= ' "PHP CodeSniffer: Error"';
216
+		$cmd .= ' '.escapeshellarg(trim($msg));
217
+		exec($cmd);
218
+
219
+	}//end notifyErrors()
220
+
221
+
222
+	/**
223
+	 * Generate and return the basic notify-send command string to execute.
224
+	 *
225
+	 * @return string Shell command with common parameters.
226
+	 */
227
+	protected function getBasicCommand()
228
+	{
229
+		$cmd  = $this->path;
230
+		$cmd .= ' --category dev.validate';
231
+		$cmd .= ' -h int:transient:1';
232
+		$cmd .= ' -t '.(int) $this->timeout;
233
+		if (version_compare($this->version, '0.7.3', '>=') === true) {
234
+			$cmd .= ' -a phpcs';
235
+		}
236
+
237
+		return $cmd;
238
+
239
+	}//end getBasicCommand()
240 240
 
241 241
 
242 242
 }//end class
Please login to merge, or discard this patch.
vendor/squizlabs/php_codesniffer/src/Reports/Json.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
      *
31 31
      * @return bool
32 32
      */
33
-    public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80)
33
+    public function generateFileReport($report, File $phpcsFile, $showSources = false, $width = 80)
34 34
     {
35 35
         $filename = str_replace('\\', '\\\\', $report['filename']);
36 36
         $filename = str_replace('"', '\"', $filename);
@@ -96,10 +96,10 @@  discard block
 block discarded – undo
96 96
         $totalErrors,
97 97
         $totalWarnings,
98 98
         $totalFixable,
99
-        $showSources=false,
100
-        $width=80,
101
-        $interactive=false,
102
-        $toScreen=true
99
+        $showSources = false,
100
+        $width = 80,
101
+        $interactive = false,
102
+        $toScreen = true
103 103
     ) {
104 104
         echo '{"totals":{"errors":'.$totalErrors.',"warnings":'.$totalWarnings.',"fixable":'.$totalFixable.'},"files":{';
105 105
         echo rtrim($cachedData, ',');
Please login to merge, or discard this patch.
Indentation   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -16,91 +16,91 @@
 block discarded – undo
16 16
 {
17 17
 
18 18
 
19
-    /**
20
-     * Generate a partial report for a single processed file.
21
-     *
22
-     * Function should return TRUE if it printed or stored data about the file
23
-     * and FALSE if it ignored the file. Returning TRUE indicates that the file and
24
-     * its data should be counted in the grand totals.
25
-     *
26
-     * @param array                 $report      Prepared report data.
27
-     * @param \PHP_CodeSniffer\File $phpcsFile   The file being reported on.
28
-     * @param bool                  $showSources Show sources?
29
-     * @param int                   $width       Maximum allowed line width.
30
-     *
31
-     * @return bool
32
-     */
33
-    public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80)
34
-    {
35
-        $filename = str_replace('\\', '\\\\', $report['filename']);
36
-        $filename = str_replace('"', '\"', $filename);
37
-        $filename = str_replace('/', '\/', $filename);
38
-        echo '"'.$filename.'":{';
39
-        echo '"errors":'.$report['errors'].',"warnings":'.$report['warnings'].',"messages":[';
40
-
41
-        $messages = '';
42
-        foreach ($report['messages'] as $line => $lineErrors) {
43
-            foreach ($lineErrors as $column => $colErrors) {
44
-                foreach ($colErrors as $error) {
45
-                    $error['message'] = str_replace("\n", '\n', $error['message']);
46
-                    $error['message'] = str_replace("\r", '\r', $error['message']);
47
-                    $error['message'] = str_replace("\t", '\t', $error['message']);
48
-
49
-                    $fixable = false;
50
-                    if ($error['fixable'] === true) {
51
-                        $fixable = true;
52
-                    }
53
-
54
-                    $messagesObject          = (object) $error;
55
-                    $messagesObject->line    = $line;
56
-                    $messagesObject->column  = $column;
57
-                    $messagesObject->fixable = $fixable;
58
-
59
-                    $messages .= json_encode($messagesObject).",";
60
-                }
61
-            }
62
-        }//end foreach
63
-
64
-        echo rtrim($messages, ',');
65
-        echo ']},';
66
-
67
-        return true;
68
-
69
-    }//end generateFileReport()
70
-
71
-
72
-    /**
73
-     * Generates a JSON report.
74
-     *
75
-     * @param string $cachedData    Any partial report data that was returned from
76
-     *                              generateFileReport during the run.
77
-     * @param int    $totalFiles    Total number of files processed during the run.
78
-     * @param int    $totalErrors   Total number of errors found during the run.
79
-     * @param int    $totalWarnings Total number of warnings found during the run.
80
-     * @param int    $totalFixable  Total number of problems that can be fixed.
81
-     * @param bool   $showSources   Show sources?
82
-     * @param int    $width         Maximum allowed line width.
83
-     * @param bool   $interactive   Are we running in interactive mode?
84
-     * @param bool   $toScreen      Is the report being printed to screen?
85
-     *
86
-     * @return void
87
-     */
88
-    public function generate(
89
-        $cachedData,
90
-        $totalFiles,
91
-        $totalErrors,
92
-        $totalWarnings,
93
-        $totalFixable,
94
-        $showSources=false,
95
-        $width=80,
96
-        $interactive=false,
97
-        $toScreen=true
98
-    ) {
99
-        echo '{"totals":{"errors":'.$totalErrors.',"warnings":'.$totalWarnings.',"fixable":'.$totalFixable.'},"files":{';
100
-        echo rtrim($cachedData, ',');
101
-        echo "}}".PHP_EOL;
102
-
103
-    }//end generate()
19
+	/**
20
+	 * Generate a partial report for a single processed file.
21
+	 *
22
+	 * Function should return TRUE if it printed or stored data about the file
23
+	 * and FALSE if it ignored the file. Returning TRUE indicates that the file and
24
+	 * its data should be counted in the grand totals.
25
+	 *
26
+	 * @param array                 $report      Prepared report data.
27
+	 * @param \PHP_CodeSniffer\File $phpcsFile   The file being reported on.
28
+	 * @param bool                  $showSources Show sources?
29
+	 * @param int                   $width       Maximum allowed line width.
30
+	 *
31
+	 * @return bool
32
+	 */
33
+	public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80)
34
+	{
35
+		$filename = str_replace('\\', '\\\\', $report['filename']);
36
+		$filename = str_replace('"', '\"', $filename);
37
+		$filename = str_replace('/', '\/', $filename);
38
+		echo '"'.$filename.'":{';
39
+		echo '"errors":'.$report['errors'].',"warnings":'.$report['warnings'].',"messages":[';
40
+
41
+		$messages = '';
42
+		foreach ($report['messages'] as $line => $lineErrors) {
43
+			foreach ($lineErrors as $column => $colErrors) {
44
+				foreach ($colErrors as $error) {
45
+					$error['message'] = str_replace("\n", '\n', $error['message']);
46
+					$error['message'] = str_replace("\r", '\r', $error['message']);
47
+					$error['message'] = str_replace("\t", '\t', $error['message']);
48
+
49
+					$fixable = false;
50
+					if ($error['fixable'] === true) {
51
+						$fixable = true;
52
+					}
53
+
54
+					$messagesObject          = (object) $error;
55
+					$messagesObject->line    = $line;
56
+					$messagesObject->column  = $column;
57
+					$messagesObject->fixable = $fixable;
58
+
59
+					$messages .= json_encode($messagesObject).",";
60
+				}
61
+			}
62
+		}//end foreach
63
+
64
+		echo rtrim($messages, ',');
65
+		echo ']},';
66
+
67
+		return true;
68
+
69
+	}//end generateFileReport()
70
+
71
+
72
+	/**
73
+	 * Generates a JSON report.
74
+	 *
75
+	 * @param string $cachedData    Any partial report data that was returned from
76
+	 *                              generateFileReport during the run.
77
+	 * @param int    $totalFiles    Total number of files processed during the run.
78
+	 * @param int    $totalErrors   Total number of errors found during the run.
79
+	 * @param int    $totalWarnings Total number of warnings found during the run.
80
+	 * @param int    $totalFixable  Total number of problems that can be fixed.
81
+	 * @param bool   $showSources   Show sources?
82
+	 * @param int    $width         Maximum allowed line width.
83
+	 * @param bool   $interactive   Are we running in interactive mode?
84
+	 * @param bool   $toScreen      Is the report being printed to screen?
85
+	 *
86
+	 * @return void
87
+	 */
88
+	public function generate(
89
+		$cachedData,
90
+		$totalFiles,
91
+		$totalErrors,
92
+		$totalWarnings,
93
+		$totalFixable,
94
+		$showSources=false,
95
+		$width=80,
96
+		$interactive=false,
97
+		$toScreen=true
98
+	) {
99
+		echo '{"totals":{"errors":'.$totalErrors.',"warnings":'.$totalWarnings.',"fixable":'.$totalFixable.'},"files":{';
100
+		echo rtrim($cachedData, ',');
101
+		echo "}}".PHP_EOL;
102
+
103
+	}//end generate()
104 104
 
105 105
 
106 106
 }//end class
Please login to merge, or discard this patch.