for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* PHPCompatibility_Sniffs_PHP_CaseSensitiveKeywordsSniff.
*
* PHP version 5.5
* @category PHP
* @package PHPCompatibility
* @author Juliette Reinders Folmer <[email protected]>
*/
* Prior to PHP 5.5, cases existed where the self, parent, and static keywords
* were treated in a case sensitive fashion.
class PHPCompatibility_Sniffs_PHP_CaseSensitiveKeywordsSniff extends PHPCompatibility_Sniff
You can fix this by adding a namespace to your class:
namespace YourVendor; class YourClass { }
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.
{
* Returns an array of tokens this test wants to listen for.
* @return array
public function register()
return array(
T_SELF,
T_STATIC,
T_PARENT,
);
}
* Processes this test, when one of its tokens is encountered.
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
* @param int $stackPtr The position of the current token in the
* stack passed in $tokens.
* @return void
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
if ($this->supportsBelow('5.4') === false) {
return;
$tokens = $phpcsFile->getTokens();
$tokenContentLC = strtolower($tokens[$stackPtr]['content']);
if ($tokenContentLC !== $tokens[$stackPtr]['content']) {
$phpcsFile->addError(
'The keyword \'%s\' was treated in a case-sensitive fashion in certain cases in PHP 5.4 or earlier. Use the lowercase version for consistent support.',
$stackPtr,
'NonLowercaseFound',
array($tokenContentLC)
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.