Skip to content
This repository has been archived by the owner on Mar 31, 2024. It is now read-only.

Commit

Permalink
Remove php.ini scanning and only process ini_set().
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Dec 22, 2010
1 parent cd03046 commit a3e488e
Showing 1 changed file with 2 additions and 32 deletions.
34 changes: 2 additions & 32 deletions Sniffs/PHP/DeprecatedIniDirectivesSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
/**
* PHP53Compatibility_Sniffs_PHP_DeprecatedIniDirectivesSniff.
*
* Discourages the use of ini directives through ini_set or
* in php.ini (searches only for the current running one, so it should be run on a php.ini
* identical to the one running on your production server)
* Discourages the use of deprecated INI directives through ini_set().
*
* @category PHP
* @package PHP53Compat
Expand All @@ -24,13 +22,6 @@
*/
class PHP53Compatibility_Sniffs_PHP_DeprecatedIniDirectivesSniff implements PHP_CodeSniffer_Sniff
{
/**
* Variable keeps status of php.ini check
*
* @var bool
*/
protected $checkedIniFile = false;

/**
* A list of deprecated INI directives
*
Expand All @@ -46,22 +37,6 @@ class PHP53Compatibility_Sniffs_PHP_DeprecatedIniDirectivesSniff implements PHP_
'magic_quotes_sybase',
);

/**
* Checks if deprecated php.ini directives are present in the currently loaded php.ini
*
* @param PHP_CodeSniffer_File $phpcsFile The currently loaded file
*/
protected function checkLoadedIniFile($phpcsFile)
{
$this->checkedIniFile = true;
foreach ($this->deprecatedIniDirectives as $directive) {
if (ini_get($directive) != '') {
$error = "The use of directive " . $directive . " in your php.ini file is discouraged";
$phpcsFile->addWarning($error, 0);
}
}
}

/**
* Returns an array of tokens this test wants to listen for.
*
Expand All @@ -73,7 +48,6 @@ public function register()

}//end register()


/**
* Processes this test, when one of its tokens is encountered.
*
Expand All @@ -85,10 +59,6 @@ public function register()
*/
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
{
if ($this->checkedIniFile === false) {
$this->checkLoadedIniFile($phpcsFile);
}

$tokens = $phpcsFile->getTokens();

$ignore = array(
Expand All @@ -112,7 +82,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
if (in_array(str_replace("'", "", $tokens[$iniToken]['content']), $this->deprecatedIniDirectives) === false) {
return;
}
$error = "The use of ini directive " . $tokens[$iniToken]['content'] . " is discouraged";
$error = "INI directive " . $tokens[$iniToken]['content'] . " is deprecated.";

$phpcsFile->addWarning($error, $stackPtr);

Expand Down

0 comments on commit a3e488e

Please sign in to comment.