|
23 | 23 | * |
24 | 24 | * @since 0.9.0 |
25 | 25 | * @since 0.13.0 Class name changed: this class is now namespaced. |
| 26 | + * @since 2.0.0 Defers to the upstream `$phpReservedVars` property. |
26 | 27 | * |
27 | 28 | * Last synced with base class June 2018 at commit 78ddbae97cac078f09928bf89e3ab9e53ad2ace0. |
28 | 29 | * @link https://github.com/squizlabs/PHP_CodeSniffer/blob/master/src/Standards/Squiz/Sniffs/NamingConventions/ValidVariableNameSniff.php |
|
31 | 32 | */ |
32 | 33 | class ValidVariableNameSniff extends PHPCS_AbstractVariableSniff { |
33 | 34 |
|
34 | | - /** |
35 | | - * PHP Reserved Vars. |
36 | | - * |
37 | | - * @since 0.9.0 |
38 | | - * @since 0.11.0 Changed visibility from public to protected. |
39 | | - * |
40 | | - * @var array |
41 | | - */ |
42 | | - protected $php_reserved_vars = array( |
43 | | - '_SERVER' => true, |
44 | | - '_GET' => true, |
45 | | - '_POST' => true, |
46 | | - '_REQUEST' => true, |
47 | | - '_SESSION' => true, |
48 | | - '_ENV' => true, |
49 | | - '_COOKIE' => true, |
50 | | - '_FILES' => true, |
51 | | - 'GLOBALS' => true, |
52 | | - 'http_response_header' => true, |
53 | | - 'HTTP_RAW_POST_DATA' => true, |
54 | | - 'php_errormsg' => true, |
55 | | - ); |
56 | | - |
57 | 35 | /** |
58 | 36 | * Mixed-case variables used by WordPress. |
59 | 37 | * |
@@ -131,7 +109,7 @@ protected function processVariable( File $phpcs_file, $stack_ptr ) { |
131 | 109 | $var_name = ltrim( $tokens[ $stack_ptr ]['content'], '$' ); |
132 | 110 |
|
133 | 111 | // If it's a php reserved var, then its ok. |
134 | | - if ( isset( $this->php_reserved_vars[ $var_name ] ) ) { |
| 112 | + if ( isset( $this->phpReservedVars[ $var_name ] ) ) { |
135 | 113 | return; |
136 | 114 | } |
137 | 115 |
|
@@ -254,7 +232,7 @@ protected function processVariableInString( File $phpcs_file, $stack_ptr ) { |
254 | 232 |
|
255 | 233 | foreach ( $matches[1] as $var_name ) { |
256 | 234 | // If it's a php reserved var, then its ok. |
257 | | - if ( isset( $this->php_reserved_vars[ $var_name ] ) ) { |
| 235 | + if ( isset( $this->phpReservedVars[ $var_name ] ) ) { |
258 | 236 | continue; |
259 | 237 | } |
260 | 238 |
|
|
0 commit comments