Completed
Pull Request — master (#11)
by Tomáš
03:35
created

Config::printPHPCSUsage()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 36
Code Lines 33

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 4
Bugs 0 Features 0
Metric Value
c 4
b 0
f 0
dl 0
loc 36
ccs 0
cts 0
cp 0
rs 8.8571
cc 1
eloc 33
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * Stores the configuration used to run PHPCS and PHPCBF.
4
 *
5
 * Parses the command line to determine user supplied values
6
 * and provides functions to access data stored in config files.
7
 *
8
 * @author    Greg Sherwood <[email protected]>
9
 * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
10
 * @license   https://github.com/squizlabs/Symplify\PHP7_CodeSniffer/blob/master/licence.txt BSD Licence
11
 */
12
13
namespace Symplify\PHP7_CodeSniffer;
14
15
use Symplify\PHP7_CodeSniffer\Exceptions\RuntimeException;
16
17
class Config
18
{
19
20
    /**
21
     * @var string
22
     */
23
    const VERSION = '3.0.0';
24
25
    /**
26
     * An array of settings that PHPCS and PHPCBF accept.
27
     *
28
     * This array is not meant to be accessed directly. Instead, use the settings
29
     * as if they are class member vars so the __get() and __set() magic methods
30
     * can be used to validate the values. For example, to set the verbosity level to
31
     * level 2, use $this->verbosity = 2; insteas of accessing this property directly.
32
     *
33
     * The list of settings are:
34
     *
35
     * string[] files           The files and directories to check.
36
     * string[] standards       The standards being used for checking.
37
     * int      verbosity       How verbose the output should be.
38
     *                          0: no unnecessary output
39
     *                          1: basic output for files being checked
40
     *                          2: ruleset and file parsing output
41
     *                          3: sniff execution output
42
     * bool     interactive     Enable interactive checking mode.
43
     * bool     parallel        Check files in parallel.
44
     * bool     cache           Enable the use of the file cache.
45
     * bool     explain         Explain the coding standards.
46
     * bool     local           Process local files in directories only (no recursion).
47
     * bool     showSources     Show sniff source codes in report output.
48
     * bool     showProgress    Show basic progress information while running.
49
     * int      tabWidth        How many spaces each tab is worth.
50
     * string[] sniffs          The sniffs that should be used for checking.
51
     *                          If empty, all sniffs in the supplied standards will be used.
52
     * string[] ignored         Regular expressions used to ignore files and folders during checking.
53
     * string   reportFile      A file where the report output should be written.
54
     * string   filter          The filter to use for the run.
55
     * string[] bootstrap       One of more files to include before the run begins.
56
     * int      reportWidth     The maximum number of columns that reports should use for output.
57
     *                          Set to "auto" for have this value changed to the width of the terminal.
58
     * int      errorSeverity   The minimum severity an error must have to be displayed.
59
     * int      warningSeverity The minimum severity a warning must have to be displayed.
60
     * bool     recordErrors    Record the content of error messages as well as error counts.
61
     * string   suffix          A suffix to add to fixed files.
62
     * string   basepath        A file system location to strip from the paths of files shown in reports.
63
     * bool     stdin           Read content from STDIN instead of supplied files.
64
     * string   stdinContent    Content passed directly to PHPCS on STDIN.
65
     * string   stdinPath       The path to use for content passed on STDIN.
66
     *
67
     * array<string, string>      extensions File extensions that should be checked, and what tokenizer to use.
68
     *                                       E.g., array('inc' => 'PHP');
69
     * array<string, string|null> reports    The reports to use for printing output after the run.
70
     *                                       The format of the array is:
71
     *                                           array(
72
     *                                            'reportName1' => 'outputFile',
73
     *                                            'reportName2' => null,
74
     *                                           );
75
     *                                       If the array value is NULL, the report will be written to the screen.
76
     *
77
     * @var array<string, mixed>
78
     */
79
    private $settings = array(
80
                         'files'           => null,
81
                         'standards'       => null,
82
                         'verbosity'       => null,
83
                         'interactive'     => null,
84
                         'parallel'        => null,
85
                         'explain'         => null,
86
                         'local'           => null,
87
                         'showSources'     => null,
88
                         'showProgress'    => null,
89
                         'tabWidth'        => null,
90
                         'extensions'      => null,
91
                         'sniffs'          => null,
92
                         'ignored'         => null,
93
                         'reportFile'      => null,
94
                         'filter'          => null,
95
                         'bootstrap'       => null,
96
                         'reports'         => null,
97
                         'basepath'        => null,
98
                         'reportWidth'     => null,
99
                         'errorSeverity'   => null,
100
                         'warningSeverity' => null,
101
                         'recordErrors'    => null,
102
                         'suffix'          => null,
103
                         'stdin'           => null,
104
                         'stdinContent'    => null,
105
                         'stdinPath'       => null,
106
                        );
107
108
    /**
109
     * Whether or not to kill the process when an unknown command line arg is found.
110
     *
111
     * If FALSE, arguments that are not command line options or file/directory paths
112
     * will be ignored and execution will continue.
113
     *
114
     * @var boolean
115
     */
116
    public $dieOnUnknownArg;
117
118
    /**
119
     * The current command line arguments we are processing.
120
     *
121
     * @var string[]
122
     */
123
    private $cliArgs = array();
124
125
    /**
126
     * Command line values that the user has supplied directly.
127
     *
128
     * @var array<string, TRUE>
129
     */
130
    private $overriddenDefaults = array();
131
132
    /**
133
     * Unknown arguments
134
     *
135
     * @var array<mixed>
136
     */
137
    private $values = array();
138
139
    /**
140
     * Config file data that has been loaded for the run.
141
     *
142
     * @var array<string, string>
143
     */
144
    private static $configData = null;
145
146
    /**
147
     * Automatically discovered executable utility paths.
148
     *
149
     * @var array<string, string>
150
     */
151
    private static $executablePaths = array();
152
153
154
    /**
155
     * Get the value of an inaccessible property.
156
     *
157
     * @param string $name The name of the property.
158
     *
159
     * @return mixed
160
     * @throws RuntimeException If the setting name is invalid.
161
     */
162
    public function __get($name)
163
    {
164
        if (array_key_exists($name, $this->settings) === false) {
165
            throw new RuntimeException("ERROR: unable to get value of property \"$name\"");
166
        }
167
168
        return $this->settings[$name];
169
170
    }//end __get()
171
172
173
    /**
174
     * Set the value of an inaccessible property.
175
     *
176
     * @param string $name  The name of the property.
177
     * @param mixed  $value The value of the property.
178
     *
179
     * @return void
180
     * @throws RuntimeException If the setting name is invalid.
181
     */
182 12
    public function __set($name, $value)
183
    {
184 12
        if (array_key_exists($name, $this->settings) === false) {
185 12
            throw new RuntimeException("Can't __set() $name; setting doesn't exist");
186
        }
187
188
        switch ($name) {
189 12
        case 'reportWidth' :
0 ignored issues
show
Coding Style introduced by
There must be no space before the colon in a CASE statement

As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements.

switch ($selector) {
    case "A": //right
        doSomething();
        break;
    case "B" : //wrong
        doSomethingElse();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
190
            // Support auto terminal width.
191
            if ($value === 'auto' && preg_match('|\d+ (\d+)|', shell_exec('stty size 2>&1'), $matches) === 1) {
192
                $value = (int) $matches[1];
193
            } else {
194
                $value = (int) $value;
195
            }
196
            break;
197 12
        case 'standards' :
0 ignored issues
show
Coding Style introduced by
There must be no space before the colon in a CASE statement

As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements.

switch ($selector) {
    case "A": //right
        doSomething();
        break;
    case "B" : //wrong
        doSomethingElse();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
198 12
            $cleaned = array();
199
200
            // Check if the standard name is valid, or if the case is invalid.
201 12
            $installedStandards = Util\Standards::getInstalledStandards();
202 12
            foreach ($value as $standard) {
203 12
                foreach ($installedStandards as $validStandard) {
204
                    if (strtolower($standard) === strtolower($validStandard)) {
205
                        $standard = $validStandard;
206
                        break;
207
                    }
208
                }
209
210 12
                $cleaned[] = $standard;
211
            }
212
213 12
            $value = $cleaned;
214 12
            break;
215
        default :
0 ignored issues
show
Coding Style introduced by
There must be no space before the colon in a DEFAULT statement

As per the PSR-2 coding standard, there must not be a space in front of the colon in the default statement.

switch ($expr) {
    default : //wrong
        doSomething();
        break;
}

switch ($expr) {
    default: //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
216
            // No validation required.
217 12
            break;
218
        }//end switch
219
220 12
        $this->settings[$name] = $value;
221
222 12
    }//end __set()
223
224
225
    /**
226
     * Check if the value of an inaccessible property is set.
227
     *
228
     * @param string $name The name of the property.
229
     *
230
     * @return bool
231
     */
232
    public function __isset($name)
233
    {
234
        return isset($this->settings[$name]);
235
236
    }//end __isset()
237
238
239
    /**
240
     * Unset the value of an inaccessible property.
241
     *
242
     * @param string $name The name of the property.
243
     *
244
     * @return void
245
     */
246
    public function __unset($name)
247
    {
248
        $this->settings[$name] = null;
249
250
    }//end __unset()
251
252
253
    /**
254
     * Creates a Config object and populates it with command line values.
255
     *
256
     * @param array $cliArgs         An array of values gathered from CLI args.
257
     * @param bool  $dieOnUnknownArg Whether or not to kill the process when an
258
     *                               unknown command line arg is found.
259
     *
260
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
261
     */
262 12
    public function __construct(array $cliArgs=array(), $dieOnUnknownArg=true)
0 ignored issues
show
Coding Style introduced by
__construct uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
263
    {
264 12
        if (defined('Symplify\PHP7_CodeSniffer_IN_TESTS') === true) {
265
            // Let everything through during testing so that we can
266
            // make use of PHPUnit command line arguments as well.
267
            $this->dieOnUnknownArg = false;
268
        } else {
269 12
            $this->dieOnUnknownArg = $dieOnUnknownArg;
270
        }
271
272 12
        $checkStdin = false;
273 12
        if (empty($cliArgs) === true) {
274 12
            $cliArgs = $_SERVER['argv'];
275 12
            array_shift($cliArgs);
276 12
            $checkStdin = true;
277
        }
278
279 12
        $this->restoreDefaults();
280
        $this->setCommandLineValues($cliArgs);
281
282
        if (isset($this->overriddenDefaults['standards']) === false
283
            && Config::getConfigData('default_standard') === null
284
        ) {
285
            // They did not supply a standard to use.
286
            // Look for a default ruleset in the current directory or higher.
287
            $currentDir = getcwd();
288
289
            do {
290
                $default = $currentDir.DIRECTORY_SEPARATOR.'phpcs.xml';
291
                if (is_file($default) === true) {
292
                    $this->standards = array($default);
0 ignored issues
show
Documentation introduced by
The property standards does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
293
                } else {
294
                    $default = $currentDir.DIRECTORY_SEPARATOR.'phpcs.xml.dist';
295
                    if (is_file($default) === true) {
296
                        $this->standards = array($default);
0 ignored issues
show
Documentation introduced by
The property standards does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
297
                    }
298
                }
299
300
                $lastDir    = $currentDir;
301
                $currentDir = dirname($currentDir);
302
            } while ($currentDir !== '.' && $currentDir !== $lastDir);
303
        }
304
305
        // Check for content on STDIN.
306
        if ($checkStdin === true) {
307
            $handle = fopen('php://stdin', 'r');
308
            if (stream_set_blocking($handle, false) === true) {
309
                $fileContents = '';
310
                while (($line = fgets(STDIN)) !== false) {
311
                    $fileContents .= $line;
312
                    usleep(10);
313
                }
314
315
                stream_set_blocking($handle, true);
316
                fclose($handle);
317
                if (trim($fileContents) !== '') {
318
                    $this->stdin        = true;
0 ignored issues
show
Documentation introduced by
The property stdin does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
319
                    $this->stdinContent = $fileContents;
0 ignored issues
show
Documentation introduced by
The property stdinContent does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
320
                    $this->overriddenDefaults['stdin']        = true;
321
                    $this->overriddenDefaults['stdinContent'] = true;
322
                }
323
            }
324
        }
325
326
    }//end __construct()
327
328
329
    /**
330
     * Set the command line values.
331
     *
332
     * @param array $args An array of command line arguments to set.
333
     *
334
     * @return void
335
     */
336
    public function setCommandLineValues($args)
337
    {
338
        $this->cliArgs = $args;
339
        $numArgs       = count($args);
340
341
        for ($i = 0; $i < $numArgs; $i++) {
342
            $arg = $this->cliArgs[$i];
343
            if ($arg === '') {
344
                continue;
345
            }
346
347
            if ($arg{0} === '-') {
348
                if ($arg === '-') {
349
                    // Asking to read from STDIN.
350
                    $this->stdin = true;
0 ignored issues
show
Documentation introduced by
The property stdin does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
351
                    $this->overriddenDefaults['stdin'] = true;
352
                    continue;
353
                }
354
355
                if ($arg === '--') {
356
                    // Empty argument, ignore it.
357
                    continue;
358
                }
359
360
                if ($arg{1} === '-') {
361
                    $this->processLongArgument(substr($arg, 2), $i);
362
                } else {
363
                    $switches = str_split($arg);
364
                    foreach ($switches as $switch) {
365
                        if ($switch === '-') {
366
                            continue;
367
                        }
368
369
                        $this->processShortArgument($switch, $i);
370
                    }
371
                }
372
            } else {
373
                $this->processUnknownArgument($arg, $i);
374
            }//end if
375
        }//end for
376
377
    }//end setCommandLineValues()
378
379
380
    /**
381
     * Restore default values for all possible command line arguments.
382
     *
383
     * @return array
384
     */
385 12
    public function restoreDefaults()
386
    {
387 12
        $this->files           = array();
0 ignored issues
show
Documentation introduced by
The property files does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
388 12
        $this->standards       = array('PEAR');
0 ignored issues
show
Documentation introduced by
The property standards does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
389 12
        $this->verbosity       = 0;
0 ignored issues
show
Documentation introduced by
The property verbosity does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
390 12
        $this->interactive     = false;
0 ignored issues
show
Documentation introduced by
The property interactive does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
391 12
        $this->colors          = true;
0 ignored issues
show
Documentation introduced by
The property colors does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
392
        $this->explain         = false;
0 ignored issues
show
Documentation introduced by
The property explain does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
393
        $this->local           = false;
0 ignored issues
show
Documentation introduced by
The property local does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
394
        $this->showSources     = false;
0 ignored issues
show
Documentation introduced by
The property showSources does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
395
        $this->showProgress    = false;
0 ignored issues
show
Documentation introduced by
The property showProgress does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
396
        $this->parallel        = 1;
0 ignored issues
show
Documentation introduced by
The property parallel does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
397
        $this->tabWidth        = 0;
0 ignored issues
show
Documentation introduced by
The property tabWidth does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
398
        $this->extensions      = array(
0 ignored issues
show
Documentation introduced by
The property extensions does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
399
                                  'php' => 'PHP',
400
                                  'inc' => 'PHP',
401
                                  'js'  => 'JS',
402
                                  'css' => 'CSS',
403
                                 );
404
        $this->sniffs          = array();
0 ignored issues
show
Documentation introduced by
The property sniffs does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
405
        $this->ignored         = array();
0 ignored issues
show
Documentation introduced by
The property ignored does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
406
        $this->filter          = null;
0 ignored issues
show
Documentation introduced by
The property filter does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
407
        $this->bootstrap       = array();
0 ignored issues
show
Documentation introduced by
The property bootstrap does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
408
        $this->reports         = array('full' => null);
0 ignored issues
show
Documentation introduced by
The property reports does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
409
        $this->errorSeverity   = 5;
0 ignored issues
show
Documentation introduced by
The property errorSeverity does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
410
        $this->warningSeverity = 5;
0 ignored issues
show
Documentation introduced by
The property warningSeverity does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
411
        $this->recordErrors    = true;
0 ignored issues
show
Documentation introduced by
The property recordErrors does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
412
        $this->suffix          = '';
0 ignored issues
show
Documentation introduced by
The property suffix does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
413
        $this->stdin           = false;
0 ignored issues
show
Documentation introduced by
The property stdin does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
414
        $this->stdinContent    = null;
0 ignored issues
show
Documentation introduced by
The property stdinContent does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
415
        $this->stdinPath       = null;
0 ignored issues
show
Documentation introduced by
The property stdinPath does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
416
417
        $standard = self::getConfigData('default_standard');
418
        if ($standard !== null) {
419
            $this->standards = explode(',', $standard);
0 ignored issues
show
Documentation introduced by
The property standards does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
420
        }
421
422
        $tabWidth = self::getConfigData('tab_width');
423
        if ($tabWidth !== null) {
424
            $this->tabWidth = (int) $tabWidth;
0 ignored issues
show
Documentation introduced by
The property tabWidth does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
425
        }
426
427
        $severity = self::getConfigData('severity');
428
        if ($severity !== null) {
429
            $this->errorSeverity   = (int) $severity;
0 ignored issues
show
Documentation introduced by
The property errorSeverity does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
430
            $this->warningSeverity = (int) $severity;
0 ignored issues
show
Documentation introduced by
The property warningSeverity does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
431
        }
432
433
        $severity = self::getConfigData('error_severity');
434
        if ($severity !== null) {
435
            $this->errorSeverity = (int) $severity;
0 ignored issues
show
Documentation introduced by
The property errorSeverity does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
436
        }
437
438
        $severity = self::getConfigData('warning_severity');
439
        if ($severity !== null) {
440
            $this->warningSeverity = (int) $severity;
0 ignored issues
show
Documentation introduced by
The property warningSeverity does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
441
        }
442
443
        $showWarnings = self::getConfigData('show_warnings');
444
        if ($showWarnings !== null) {
445
            $showWarnings = (bool) $showWarnings;
446
            if ($showWarnings === false) {
447
                $this->warningSeverity = 0;
0 ignored issues
show
Documentation introduced by
The property warningSeverity does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
448
            }
449
        }
450
451
        $showProgress = self::getConfigData('show_progress');
452
        if ($showProgress !== null) {
453
            $this->showProgress = (bool) $showProgress;
0 ignored issues
show
Documentation introduced by
The property showProgress does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
454
        }
455
456
        if (defined('Symplify\PHP7_CodeSniffer_IN_TESTS') === false) {
457
            $cache = self::getConfigData('cache');
458
            if ($cache !== null) {
459
                $this->cache = (bool) $cache;
0 ignored issues
show
Documentation introduced by
The property cache does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
460
            }
461
462
            $parallel = self::getConfigData('parallel');
463
            if ($parallel !== null) {
464
                $this->parallel = max((int) $parallel, 1);
0 ignored issues
show
Documentation introduced by
The property parallel does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
465
            }
466
        }
467
468
    }//end restoreDefaults()
469
470
471
    /**
472
     * Processes a short (-e) command line argument.
473
     *
474
     * @param string $arg The command line argument.
475
     * @param int    $pos The position of the argument on the command line.
476
     *
477
     * @return void
478
     */
479
    public function processShortArgument($arg, $pos)
480
    {
481
        switch ($arg) {
482
        case 'h':
483
        case '?':
484
            $this->printUsage();
485
            exit(0);
0 ignored issues
show
Coding Style Compatibility introduced by
The method processShortArgument() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
486
        case 'i' :
0 ignored issues
show
Coding Style introduced by
There must be no space before the colon in a CASE statement

As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements.

switch ($selector) {
    case "A": //right
        doSomething();
        break;
    case "B" : //wrong
        doSomethingElse();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
487
            Util\Standards::printInstalledStandards();
488
            exit(0);
0 ignored issues
show
Coding Style Compatibility introduced by
The method processShortArgument() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
489
        case 'v' :
0 ignored issues
show
Coding Style introduced by
There must be no space before the colon in a CASE statement

As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements.

switch ($selector) {
    case "A": //right
        doSomething();
        break;
    case "B" : //wrong
        doSomethingElse();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
490
            $this->verbosity++;
0 ignored issues
show
Documentation introduced by
The property verbosity does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
491
            $this->overriddenDefaults['verbosity'] = true;
492
            break;
493
        case 'l' :
0 ignored issues
show
Coding Style introduced by
There must be no space before the colon in a CASE statement

As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements.

switch ($selector) {
    case "A": //right
        doSomething();
        break;
    case "B" : //wrong
        doSomethingElse();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
494
            $this->local = true;
0 ignored issues
show
Documentation introduced by
The property local does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
495
            $this->overriddenDefaults['local'] = true;
496
            break;
497
        case 's' :
0 ignored issues
show
Coding Style introduced by
There must be no space before the colon in a CASE statement

As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements.

switch ($selector) {
    case "A": //right
        doSomething();
        break;
    case "B" : //wrong
        doSomethingElse();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
498
            $this->showSources = true;
0 ignored issues
show
Documentation introduced by
The property showSources does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
499
            $this->overriddenDefaults['showSources'] = true;
500
            break;
501
        case 'a' :
0 ignored issues
show
Coding Style introduced by
There must be no space before the colon in a CASE statement

As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements.

switch ($selector) {
    case "A": //right
        doSomething();
        break;
    case "B" : //wrong
        doSomethingElse();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
502
            $this->interactive = true;
0 ignored issues
show
Documentation introduced by
The property interactive does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
503
            $this->overriddenDefaults['interactive'] = true;
504
            break;
505
        case 'e':
506
            $this->explain = true;
0 ignored issues
show
Documentation introduced by
The property explain does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
507
            $this->overriddenDefaults['explain'] = true;
508
            break;
509
        case 'p' :
0 ignored issues
show
Coding Style introduced by
There must be no space before the colon in a CASE statement

As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements.

switch ($selector) {
    case "A": //right
        doSomething();
        break;
    case "B" : //wrong
        doSomethingElse();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
510
            $this->showProgress = true;
0 ignored issues
show
Documentation introduced by
The property showProgress does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
511
            $this->overriddenDefaults['showProgress'] = true;
512
            break;
513
        case 'm' :
0 ignored issues
show
Coding Style introduced by
There must be no space before the colon in a CASE statement

As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements.

switch ($selector) {
    case "A": //right
        doSomething();
        break;
    case "B" : //wrong
        doSomethingElse();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
514
            $this->recordErrors = false;
0 ignored issues
show
Documentation introduced by
The property recordErrors does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
515
            $this->overriddenDefaults['recordErrors'] = true;
516
            break;
517
        case 'd' :
0 ignored issues
show
Coding Style introduced by
There must be no space before the colon in a CASE statement

As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements.

switch ($selector) {
    case "A": //right
        doSomething();
        break;
    case "B" : //wrong
        doSomethingElse();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
518
            $ini = explode('=', $this->cliArgs[($pos + 1)]);
519
            $this->cliArgs[($pos + 1)] = '';
520
            if (isset($ini[1]) === true) {
521
                ini_set($ini[0], $ini[1]);
522
            } else {
523
                ini_set($ini[0], true);
524
            }
525
            break;
526 View Code Duplication
        case 'n' :
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
Coding Style introduced by
There must be no space before the colon in a CASE statement

As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements.

switch ($selector) {
    case "A": //right
        doSomething();
        break;
    case "B" : //wrong
        doSomethingElse();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
527
            if (isset($this->overriddenDefaults['warningSeverity']) === false) {
528
                $this->warningSeverity = 0;
0 ignored issues
show
Documentation introduced by
The property warningSeverity does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
529
                $this->overriddenDefaults['warningSeverity'] = true;
530
            }
531
            break;
532 View Code Duplication
        case 'w' :
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
Coding Style introduced by
There must be no space before the colon in a CASE statement

As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements.

switch ($selector) {
    case "A": //right
        doSomething();
        break;
    case "B" : //wrong
        doSomethingElse();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
533
            if (isset($this->overriddenDefaults['warningSeverity']) === false) {
534
                $this->warningSeverity = $this->errorSeverity;
0 ignored issues
show
Documentation introduced by
The property warningSeverity does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Documentation introduced by
The property errorSeverity does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
535
                $this->overriddenDefaults['warningSeverity'] = true;
536
            }
537
            break;
538
        default:
539
            if ($this->dieOnUnknownArg === false) {
540
                $this->values[$arg] = $arg;
541
            } else {
542
                $this->processUnknownArgument('-'.$arg, $pos);
543
            }
544
        }//end switch
545
546
    }//end processShortArgument()
547
548
549
    /**
550
     * Processes a long (--example) command line argument.
551
     *
552
     * @param string $arg The command line argument.
553
     * @param int    $pos The position of the argument on the command line.
554
     *
555
     * @return void
556
     */
557
    public function processLongArgument($arg, $pos)
558
    {
559
        switch ($arg) {
560
        case 'help':
561
            $this->printUsage();
562
            exit(0);
0 ignored issues
show
Coding Style Compatibility introduced by
The method processLongArgument() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
563
        case 'version':
564
            echo 'Symplify\PHP7_CodeSniffer version '.self::VERSION;
565
            exit(0);
0 ignored issues
show
Coding Style Compatibility introduced by
The method processLongArgument() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
566
        case 'cache':
567
            if (defined('Symplify\PHP7_CodeSniffer_IN_TESTS') === false) {
568
                $this->cache = true;
0 ignored issues
show
Documentation introduced by
The property cache does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
569
                $this->overriddenDefaults['cache'] = true;
570
            }
571
            break;
572
        case 'no-cache':
573
            $this->cache = false;
0 ignored issues
show
Documentation introduced by
The property cache does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
574
            $this->overriddenDefaults['cache'] = true;
575
            break;
576
        default:
577
            if (substr($arg, 0, 7) === 'sniffs=') {
578
                $sniffs = explode(',', substr($arg, 7));
579
                foreach ($sniffs as $sniff) {
580
                    if (substr_count($sniff, '.') !== 2) {
581
                        echo 'ERROR: The specified sniff code "'.$sniff.'" is invalid'.PHP_EOL.PHP_EOL;
582
                        $this->printUsage();
583
                        exit(2);
0 ignored issues
show
Coding Style Compatibility introduced by
The method processLongArgument() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
584
                    }
585
                }
586
587
                $this->sniffs = $sniffs;
0 ignored issues
show
Documentation introduced by
The property sniffs does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
588
                $this->overriddenDefaults['sniffs'] = true;
589
            } else if (substr($arg, 0, 10) === 'bootstrap=') {
590
                $files     = explode(',', substr($arg, 10));
591
                $bootstrap = array();
592
                foreach ($files as $file) {
593
                    $path = Util\Common::realpath($file);
594
                    if ($path === false) {
595
                        echo 'ERROR: The specified bootstrap file "'.$file.'" does not exist'.PHP_EOL.PHP_EOL;
596
                        $this->printUsage();
597
                        exit(2);
0 ignored issues
show
Coding Style Compatibility introduced by
The method processLongArgument() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
598
                    }
599
600
                    $bootstrap[] = $path;
601
                }
602
603
                $this->bootstrap = array_merge($this->bootstrap, $bootstrap);
0 ignored issues
show
Documentation introduced by
The property bootstrap does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Documentation introduced by
The property bootstrap does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
604
                $this->overriddenDefaults['bootstrap'] = true;
605
            } else if (substr($arg, 0, 11) === 'stdin-path=') {
606
                $this->stdinPath = Util\Common::realpath(substr($arg, 11));
0 ignored issues
show
Documentation introduced by
The property stdinPath does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
607
608
                // It may not exist and return false instead, so use whatever they gave us.
609
                if ($this->stdinPath === false) {
0 ignored issues
show
Documentation introduced by
The property stdinPath does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
610
                    $this->stdinPath = trim(substr($arg, 11));
0 ignored issues
show
Documentation introduced by
The property stdinPath does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
611
                }
612
613
                $this->overriddenDefaults['stdinPath'] = true;
614
            } else if (substr($arg, 0, 9) === 'basepath=') {
615
                if (isset($this->overriddenDefaults['basepath']) === true) {
616
                    break;
617
                }
618
619
                $this->basepath = Util\Common::realpath(substr($arg, 9));
0 ignored issues
show
Documentation introduced by
The property basepath does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
620
621
                // It may not exist and return false instead.
622
                if ($this->basepath === false) {
0 ignored issues
show
Documentation introduced by
The property basepath does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
623
                    $this->basepath = substr($arg, 9);
0 ignored issues
show
Documentation introduced by
The property basepath does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
624
                }
625
626
                $this->overriddenDefaults['basepath'] = true;
627
628
                if (is_dir($this->basepath) === false) {
0 ignored issues
show
Documentation introduced by
The property basepath does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
629
                    echo 'ERROR: The specified basepath "'.$this->basepath.'" points to a non-existent directory'.PHP_EOL.PHP_EOL;
0 ignored issues
show
Documentation introduced by
The property basepath does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
630
                    $this->printUsage();
631
                    exit(2);
0 ignored issues
show
Coding Style Compatibility introduced by
The method processLongArgument() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
632
                }
633
            } else if (substr($arg, 0, 7) === 'filter=') {
634
                if (isset($this->overriddenDefaults['filter']) === true) {
635
                    break;
636
                }
637
638
                $this->filter = substr($arg, 7);
0 ignored issues
show
Documentation introduced by
The property filter does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
639
                $this->overriddenDefaults['filter'] = true;
640
            } else if (substr($arg, 0, 9) === 'standard=') {
641
                $standards = trim(substr($arg, 9));
642
                if ($standards !== '') {
643
                    $this->standards = explode(',', $standards);
0 ignored issues
show
Documentation introduced by
The property standards does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
644
                }
645
646
                $this->overriddenDefaults['standards'] = true;
647
            } else if (substr($arg, 0, 11) === 'extensions=') {
648
                $extensions    = explode(',', substr($arg, 11));
649
                $newExtensions = array();
650
                foreach ($extensions as $ext) {
651
                    $slash = strpos($ext, '/');
652
                    if ($slash !== false) {
653
                        // They specified the tokenizer too.
654
                        list($ext, $tokenizer) = explode('/', $ext);
655
                        $newExtensions[$ext]   = strtoupper($tokenizer);
656
                        continue;
657
                    }
658
659
                    if (isset($this->extensions[$ext]) === true) {
0 ignored issues
show
Documentation introduced by
The property extensions does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
660
                        $newExtensions[$ext] = $this->extensions[$ext];
0 ignored issues
show
Documentation introduced by
The property extensions does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
661
                    } else {
662
                        $newExtensions[$ext] = 'PHP';
663
                    }
664
                }
665
666
                $this->extensions = $newExtensions;
0 ignored issues
show
Documentation introduced by
The property extensions does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
667
                $this->overriddenDefaults['extensions'] = true;
668
            } else if (substr($arg, 0, 7) === 'suffix=') {
669
                $this->suffix = explode(',', substr($arg, 7));
0 ignored issues
show
Documentation introduced by
The property suffix does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
670
                $this->overriddenDefaults['suffix'] = true;
671
            } else if (substr($arg, 0, 9) === 'parallel=') {
672
                $this->parallel = max((int) substr($arg, 9), 1);
0 ignored issues
show
Documentation introduced by
The property parallel does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
673
                $this->overriddenDefaults['parallel'] = true;
674
            } else if (substr($arg, 0, 9) === 'severity=') {
675
                $this->errorSeverity   = (int) substr($arg, 9);
0 ignored issues
show
Documentation introduced by
The property errorSeverity does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
676
                $this->warningSeverity = $this->errorSeverity;
0 ignored issues
show
Documentation introduced by
The property warningSeverity does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Documentation introduced by
The property errorSeverity does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
677
                $this->overriddenDefaults['errorSeverity']   = true;
678
                $this->overriddenDefaults['warningSeverity'] = true;
679
            } else if (substr($arg, 0, 15) === 'error-severity=') {
680
                $this->errorSeverity = (int) substr($arg, 15);
0 ignored issues
show
Documentation introduced by
The property errorSeverity does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
681
                $this->overriddenDefaults['errorSeverity'] = true;
682
            } else if (substr($arg, 0, 17) === 'warning-severity=') {
683
                $this->warningSeverity = (int) substr($arg, 17);
0 ignored issues
show
Documentation introduced by
The property warningSeverity does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
684
                $this->overriddenDefaults['warningSeverity'] = true;
685
            } else if (substr($arg, 0, 7) === 'ignore=') {
686
                // Split the ignore string on commas, unless the comma is escaped
687
                // using 1 or 3 slashes (\, or \\\,).
0 ignored issues
show
Unused Code Comprehensibility introduced by
39% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
688
                $patterns = preg_split(
689
                    '/(?<=(?<!\\\\)\\\\\\\\),|(?<!\\\\),/',
690
                    substr($arg, 7)
691
                );
692
693
                $ignored = array();
694
                foreach ($patterns as $pattern) {
695
                    $pattern = trim($pattern);
696
                    if ($pattern === '') {
697
                        continue;
698
                    }
699
700
                    $ignored[$pattern] = 'absolute';
701
                }
702
703
                $this->ignored = $ignored;
0 ignored issues
show
Documentation introduced by
The property ignored does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
704
                $this->overriddenDefaults['ignored'] = true;
705
            } else if (substr($arg, 0, 10) === 'tab-width=') {
706
                $this->tabWidth = (int) substr($arg, 10);
0 ignored issues
show
Documentation introduced by
The property tabWidth does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
707
                $this->overriddenDefaults['tabWidth'] = true;
708
            } else {
709
                if ($this->dieOnUnknownArg === false) {
710
                    $eqPos = strpos($arg, '=');
711
                    if ($eqPos === false) {
712
                        $this->values[$arg] = $arg;
713
                    } else {
714
                        $value = substr($arg, ($eqPos + 1));
715
                        $arg   = substr($arg, 0, $eqPos);
716
                        $this->values[$arg] = $value;
717
                    }
718
                } else {
719
                    $this->processUnknownArgument('--'.$arg, $pos);
720
                }
721
            }//end if
722
723
            break;
724
        }//end switch
725
726
    }//end processLongArgument()
727
728
729
    /**
730
     * Processes an unknown command line argument.
731
     *
732
     * Assumes all unknown arguments are files and folders to check.
733
     *
734
     * @param string $arg The command line argument.
735
     * @param int    $pos The position of the argument on the command line.
736
     *
737
     * @return void
738
     */
739
    public function processUnknownArgument($arg, $pos)
0 ignored issues
show
Unused Code introduced by
The parameter $pos is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
740
    {
741
        // If we are processing STDIN, don't record any files to check.
742
        if ($this->stdin === true) {
0 ignored issues
show
Documentation introduced by
The property stdin does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
743
            return;
744
        }
745
746
        // We don't know about any additional switches; just files.
747
        if ($arg{0} === '-') {
748
            if ($this->dieOnUnknownArg === false) {
749
                return;
750
            }
751
752
            echo "ERROR: option \"$arg\" not known".PHP_EOL.PHP_EOL;
753
            $this->printUsage();
754
            exit(2);
0 ignored issues
show
Coding Style Compatibility introduced by
The method processUnknownArgument() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
755
        }
756
757
        $file = Util\Common::realpath($arg);
758
        if (file_exists($file) === false) {
759
            if ($this->dieOnUnknownArg === false) {
760
                return;
761
            }
762
763
            echo 'ERROR: The file "'.$arg.'" does not exist.'.PHP_EOL.PHP_EOL;
764
            $this->printUsage();
765
            exit(2);
0 ignored issues
show
Coding Style Compatibility introduced by
The method processUnknownArgument() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
766
        } else {
767
            $files       = $this->files;
0 ignored issues
show
Documentation introduced by
The property files does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
768
            $files[]     = $file;
769
            $this->files = $files;
0 ignored issues
show
Documentation introduced by
The property files does not exist on object<Symplify\PHP7_CodeSniffer\Config>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
770
            $this->overriddenDefaults['files'] = true;
771
        }
772
773
    }//end processUnknownArgument()
774
775
776
    /**
777
     * Prints out the usage information for this script.
778
     *
779
     * @return void
780
     */
781
    public function printUsage()
782
    {
783
        if (PHP_CodeSniffer_CBF === true) {
784
            $this->printPHPCBFUsage();
785
        } else {
786
            $this->printPHPCSUsage();
787
        }
788
789
    }//end printUsage()
790
791
792
    /**
793
     * Prints out the usage information for PHPCS.
794
     *
795
     * @return void
796
     */
797
    public function printPHPCSUsage()
798
    {
799
        echo 'Usage: phpcs [-nwlsaepvi] [-d key[=value]]'.PHP_EOL;
800
        echo '    [--basepath=<basepath>] [--tab-width=<tabWidth>]'.PHP_EOL;
801
        echo '    [--severity=<severity>] [--error-severity=<severity>] [--warning-severity=<severity>]'.PHP_EOL;
802
        echo '    [--standard=<standard>] [--sniffs=<sniffs>] [--parallel=<processes>]'.PHP_EOL;
803
        echo '    [--extensions=<extensions>] [--ignore=<patterns>] <file> - ...'.PHP_EOL;
804
        echo '        -             Check STDIN instead of local files and directories'.PHP_EOL;
805
        echo '        -n            Do not print warnings (shortcut for --warning-severity=0)'.PHP_EOL;
806
        echo '        -w            Print both warnings and errors (this is the default)'.PHP_EOL;
807
        echo '        -s            Show sniff codes in all reports'.PHP_EOL;
808
        echo '        -a            Run interactively'.PHP_EOL;
809
        echo '        -e            Explain a standard by showing the sniffs it includes'.PHP_EOL;
810
        echo '        -p            Show progress of the run'.PHP_EOL;
811
        echo '        -m            Stop error messages from being recorded'.PHP_EOL;
812
        echo '                      (saves a lot of memory, but stops many reports from being used)'.PHP_EOL;
813
        echo '        -v[v][v]      Print verbose output'.PHP_EOL;
814
        echo '        -i            Show a list of installed coding standards'.PHP_EOL;
815
        echo '        -d            Set the [key] php.ini value to [value] or [true] if value is omitted'.PHP_EOL;
816
        echo '        --help        Print this help message'.PHP_EOL;
817
        echo '        --version     Print version information'.PHP_EOL;
818
        echo '        <basepath>    A path to strip from the front of file paths inside reports'.PHP_EOL;
819
        echo '        <file>        One or more files and/or directories to check'.PHP_EOL;
820
        echo '        <extensions>  A comma separated list of file extensions to check'.PHP_EOL;
821
        echo '                      (extension filtering only valid when checking a directory)'.PHP_EOL;
822
        echo '                      The type of the file can be specified using: ext/type'.PHP_EOL;
823
        echo '                      e.g., module/php,es/js'.PHP_EOL;
824
        echo '        <patterns>    A comma separated list of patterns to ignore files and directories'.PHP_EOL;
825
        echo '        <processes>   How many files should be checked simultaneously (default is 1)'.PHP_EOL;
826
        echo '        <sniffs>      A comma separated list of sniff codes to limit the check to'.PHP_EOL;
827
        echo '                      (all sniffs must be part of the specified standard)'.PHP_EOL;
828
        echo '        <severity>    The minimum severity required to display an error or warning'.PHP_EOL;
829
        echo '        <standard>    The name or path of the coding standard to use'.PHP_EOL;
830
        echo '        <tabWidth>    The number of spaces each tab represents'.PHP_EOL;
831
832
    }//end printPHPCSUsage()
833
834
835
    /**
836
     * Prints out the usage information for PHPCBF.
837
     *
838
     * @return void
839
     */
840
    public function printPHPCBFUsage()
841
    {
842
        echo 'Usage: phpcbf [-nwli] [-d key[=value]]'.PHP_EOL;
843
        echo '    [--standard=<standard>] [--sniffs=<sniffs>] [--suffix=<suffix>]'.PHP_EOL;
844
        echo '    [--severity=<severity>] [--error-severity=<severity>] [--warning-severity=<severity>]'.PHP_EOL;
845
        echo '    [--tab-width=<tabWidth>] [--parallel=<processes>]'.PHP_EOL;
846
        echo '    [--basepath=<basepath>] [--extensions=<extensions>] [--ignore=<patterns>] <file> - ...'.PHP_EOL;
847
        echo '        -             Fix STDIN instead of local files and directories'.PHP_EOL;
848
        echo '        -n            Do not fix warnings (shortcut for --warning-severity=0)'.PHP_EOL;
849
        echo '        -w            Fix both warnings and errors (on by default)'.PHP_EOL;
850
        echo '        -i            Show a list of installed coding standards'.PHP_EOL;
851
        echo '        -d            Set the [key] php.ini value to [value] or [true] if value is omitted'.PHP_EOL;
852
        echo '        --help        Print this help message'.PHP_EOL;
853
        echo '        --version     Print version information'.PHP_EOL;
854
        echo '        <basepath>    A path to strip from the front of file paths inside reports'.PHP_EOL;
855
        echo '        <file>        One or more files and/or directories to fix'.PHP_EOL;
856
        echo '        <extensions>  A comma separated list of file extensions to fix'.PHP_EOL;
857
        echo '                      (extension filtering only valid when checking a directory)'.PHP_EOL;
858
        echo '                      The type of the file can be specified using: ext/type'.PHP_EOL;
859
        echo '                      e.g., module/php,es/js'.PHP_EOL;
860
        echo '        <patterns>    A comma separated list of patterns to ignore files and directories'.PHP_EOL;
861
        echo '        <processes>   How many files should be fixed simultaneously (default is 1)'.PHP_EOL;
862
        echo '        <sniffs>      A comma separated list of sniff codes to limit the fixes to'.PHP_EOL;
863
        echo '                      (all sniffs must be part of the specified standard)'.PHP_EOL;
864
        echo '        <severity>    The minimum severity required to fix an error or warning'.PHP_EOL;
865
        echo '        <standard>    The name or path of the coding standard to use'.PHP_EOL;
866
        echo '        <suffix>      Write modified files to a filename using this suffix'.PHP_EOL;
867
        echo '                      ("diff" and "patch" are not used in this mode)'.PHP_EOL;
868
        echo '        <tabWidth>    The number of spaces each tab represents'.PHP_EOL;
869
870
    }//end printPHPCBFUsage()
871
872
873
    /**
874
     * Get a single config value.
875
     *
876
     * @param string $key The name of the config value.
877
     *
878
     * @return string|null
879
     * @see    setConfigData()
880
     * @see    getAllConfigData()
881
     */
882 12
    public static function getConfigData($key)
883
    {
884 12
        $phpCodeSnifferConfig = self::getAllConfigData();
885
886 12
        if ($phpCodeSnifferConfig === null) {
887
            return null;
888
        }
889
890 12
        if (isset($phpCodeSnifferConfig[$key]) === false) {
891 12
            return null;
892
        }
893
894
        return $phpCodeSnifferConfig[$key];
895
896
    }//end getConfigData()
897
898
899
    /**
900
     * Get the path to an executable utility.
901
     *
902
     * @param string $name The name of the executable utility.
903
     *
904
     * @return string|null
905
     * @see    getConfigData()
906
     */
907
    public static function getExecutablePath($name)
908
    {
909
        $data = self::getConfigData($name.'_path');
910
        if ($data !== null) {
911
            return $data;
912
        }
913
914
        if (array_key_exists($name, self::$executablePaths) === true) {
915
            return self::$executablePaths[$name];
916
        }
917
918
        if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
919
            $cmd = 'where '.escapeshellarg($name).' 2> nul';
920
        } else {
921
            $cmd = 'which '.escapeshellarg($name);
922
        }
923
924
        $result = exec($cmd, $output, $retVal);
925
        if ($retVal !== 0) {
926
            $result = null;
927
        }
928
929
        self::$executablePaths[$name] = $result;
930
        return $result;
931
932
    }//end getExecutablePath()
933
934
935
    /**
936
     * Set a single config value.
937
     *
938
     * @param string      $key   The name of the config value.
939
     * @param string|null $value The value to set. If null, the config
940
     *                           entry is deleted, reverting it to the
941
     *                           default value.
942
     * @param boolean     $temp  Set this config data temporarily for this
943
     *                           script run. This will not write the config
944
     *                           data to the config file.
945
     *
946
     * @return bool
947
     * @see    getConfigData()
948
     * @throws RuntimeException If the config file can not be written.
949
     */
950
    public static function setConfigData($key, $value, $temp=false)
951
    {
952
        if ($temp === false) {
953
            $configFile = dirname(__FILE__).'/../CodeSniffer.conf';
954
            if (is_file($configFile) === false
955
                && strpos('@data_dir@', '@data_dir') === false
956
            ) {
957
                // If data_dir was replaced, this is a PEAR install and we can
958
                // use the PEAR data dir to store the conf file.
959
                $configFile = '@data_dir@/Symplify\PHP7_CodeSniffer/CodeSniffer.conf';
960
            }
961
962
            if (is_file($configFile) === true
963
                && is_writable($configFile) === false
964
            ) {
965
                $error = 'Config file '.$configFile.' is not writable';
966
                throw new RuntimeException($error);
967
            }
968
        }
969
970
        $phpCodeSnifferConfig = self::getAllConfigData();
971
972
        if ($value === null) {
973
            if (isset($phpCodeSnifferConfig[$key]) === true) {
974
                unset($phpCodeSnifferConfig[$key]);
975
            }
976
        } else {
977
            $phpCodeSnifferConfig[$key] = $value;
978
        }
979
980
        if ($temp === false) {
981
            $output  = '<'.'?php'."\n".' $phpCodeSnifferConfig = ';
982
            $output .= var_export($phpCodeSnifferConfig, true);
983
            $output .= "\n?".'>';
984
985
            if (file_put_contents($configFile, $output) === false) {
0 ignored issues
show
Bug introduced by
The variable $configFile does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
986
                return false;
987
            }
988
        }
989
990
        self::$configData = $phpCodeSnifferConfig;
991
992
        return true;
993
994
    }//end setConfigData()
995
996
997
    /**
998
     * Get all config data.
999
     *
1000
     * @return array<string, string>
0 ignored issues
show
Documentation introduced by
The doc-type array<string, could not be parsed: Expected ">" at position 5, but found "end of type". (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
1001
     * @see    getConfigData()
1002
     */
1003 12
    public static function getAllConfigData()
1004
    {
1005 12
        if (self::$configData !== null) {
1006 11
            return self::$configData;
1007
        }
1008
1009 1
        $configFile = dirname(__FILE__).'/../CodeSniffer.conf';
1010 1
        if (is_file($configFile) === false) {
1011
            $configFile = '@data_dir@/Symplify\PHP7_CodeSniffer/CodeSniffer.conf';
1012
        }
1013
1014 1
        if (is_file($configFile) === false) {
1015
            self::$configData = array();
1016
            return array();
1017
        }
1018
1019 1
        include $configFile;
1020 1
        self::$configData = $phpCodeSnifferConfig;
0 ignored issues
show
Bug introduced by
The variable $phpCodeSnifferConfig does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
1021 1
        return self::$configData;
1022
1023
    }//end getAllConfigData()
1024
1025
1026
    /**
1027
     * Prints out the gathered config data.
1028
     *
1029
     * @param array $data The config data to print.
1030
     *
1031
     * @return void
1032
     */
1033
    public function printConfigData($data)
1034
    {
1035
        $max  = 0;
1036
        $keys = array_keys($data);
1037
        foreach ($keys as $key) {
1038
            $len = strlen($key);
1039
            if (strlen($key) > $max) {
1040
                $max = $len;
1041
            }
1042
        }
1043
1044
        if ($max === 0) {
1045
            return;
1046
        }
1047
1048
        $max += 2;
1049
        ksort($data);
1050
        foreach ($data as $name => $value) {
1051
            echo str_pad($name.': ', $max).$value.PHP_EOL;
1052
        }
1053
1054
    }//end printConfigData()
1055
1056
1057
}//end class
1058