Skip to content

Commit f71122b

Browse files
Frederik SchmittFrederik Schmitt
authored andcommitted
Merge pull request #11 in CFA/coding-guidelines from ignore-globals to master
* commit 'a1bbde796e2ff1cfe0a60f45ba2aa473e1b0b638': set $superGlobals to private add SuperGlobals test add SuperGlobals test fix superGlobals Ignore super globals from lower camel case check
2 parents 22cc1c3 + a1bbde7 commit f71122b

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

custom-standards/Flyeralarm/Sniffs/Variable/LowerCamelCaseSniff.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,21 @@
88

99
class LowerCamelCaseSniff implements Sniff
1010
{
11+
/**
12+
* @var array
13+
*/
14+
private $superGlobals = [
15+
'GLOBALS',
16+
'_SERVER',
17+
'_GET',
18+
'_POST',
19+
'_FILES',
20+
'_COOKIE',
21+
'_SESSION',
22+
'_REQUEST',
23+
'_ENV',
24+
];
25+
1126
/**
1227
* @return array
1328
*/
@@ -32,6 +47,10 @@ public function process(File $phpcsFile, $stackPtr)
3247
$variableName = $tokens[$variablePtr]['content'];
3348
$variableName = substr($variableName, 1);
3449

50+
if (in_array($variableName, $this->superGlobals)) {
51+
continue;
52+
}
53+
3554
$isLowerCamelCase = Common::isCamelCaps($variableName, false, true, true);
3655
if ($isLowerCamelCase) {
3756
continue;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
// @expectedPass
4+
5+
$GLOBALS=true;
6+
$_SERVER=true;
7+
$_GET=true;
8+
$_POST=true;
9+
$_FILES=true;
10+
$_COOKIE=true;
11+
$_SESSION=true;
12+
$_REQUEST=true;
13+
$_ENV=true;

0 commit comments

Comments
 (0)