!C99Shell v. 1.0 pre-release build #13!

Software: Apache. PHP/5.5.15 

uname -a: Windows NT SVR-DMZ 6.1 build 7600 (Windows Server 2008 R2 Enterprise Edition) i586 

SYSTEM 

Safe-mode: OFF (not secure)

E:\nuevo\php\pear\PHP\CodeSniffer\Standards\Squiz\Sniffs\NamingConventions\   drwxrwxrwx
Free 1012.14 MB of 239.26 GB (0.41%)
Detected drives: [ a ] [ c ] [ d ] [ e ] [ f ]
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     ValidVariableNameSniff.php (9.33 KB)      -rw-rw-rw-
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
/**
 * Squiz_Sniffs_NamingConventions_ValidVariableNameSniff.
 *
 * PHP version 5
 *
 * @category  PHP
 * @package   PHP_CodeSniffer
 * @author    Greg Sherwood <gsherwood@squiz.net>
 * @author    Marc McIntyre <mmcintyre@squiz.net>
 * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600)
 * @license   http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
 * @link      http://pear.php.net/package/PHP_CodeSniffer
 */

if (class_exists('PHP_CodeSniffer_Standards_AbstractVariableSniff'true) === false) {
    throw new 
PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractVariableSniff not found');
}

/**
 * Squiz_Sniffs_NamingConventions_ValidVariableNameSniff.
 *
 * Checks the naming of variables and member variables.
 *
 * @category  PHP
 * @package   PHP_CodeSniffer
 * @author    Greg Sherwood <gsherwood@squiz.net>
 * @author    Marc McIntyre <mmcintyre@squiz.net>
 * @copyright 2006-2011 Squiz Pty Ltd (ABN 77 084 670 600)
 * @license   http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
 * @version   Release: 1.3.3
 * @link      http://pear.php.net/package/PHP_CodeSniffer
 */
class Squiz_Sniffs_NamingConventions_ValidVariableNameSniff extends PHP_CodeSniffer_Standards_AbstractVariableSniff
{

    
/**
     * Tokens to ignore so that we can find a DOUBLE_COLON.
     *
     * @var array
     */
    
private $_ignore = array(
                        
T_WHITESPACE,
                        
T_COMMENT,
                       );


    
/**
     * 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
     */
    
protected function processVariable(PHP_CodeSniffer_File $phpcsFile$stackPtr)
    {
        
$tokens  $phpcsFile->getTokens();
        
$varName ltrim($tokens[$stackPtr]['content'], '$');

        
$phpReservedVars = array(
                            
'_SERVER',
                            
'_GET',
                            
'_POST',
                            
'_REQUEST',
                            
'_SESSION',
                            
'_ENV',
                            
'_COOKIE',
                            
'_FILES',
                            
'GLOBALS',
                           );

        
// If it's a php reserved var, then its ok.
        
if (in_array($varName$phpReservedVars) === true) {
            return;
        }

        
$objOperator $phpcsFile->findNext(array(T_WHITESPACE), ($stackPtr 1), nulltrue);
        if (
$tokens[$objOperator]['code'] === T_OBJECT_OPERATOR) {
            
// Check to see if we are using a variable from an object.
            
$var $phpcsFile->findNext(array(T_WHITESPACE), ($objOperator 1), nulltrue);
            if (
$tokens[$var]['code'] === T_STRING) {
                
$bracket $objOperator $phpcsFile->findNext(array(T_WHITESPACE), ($var 1), nulltrue);
                if (
$tokens[$bracket]['code'] !== T_OPEN_PARENTHESIS) {
                    
$objVarName $tokens[$var]['content'];

                    
// There is no way for us to know if the var is public or private,
                    // so we have to ignore a leading underscore if there is one and just
                    // check the main part of the variable name.
                    
$originalVarName $objVarName;
                    if (
substr($objVarName01) === '_') {
                        
$objVarName substr($objVarName1);
                    }

                    if (
PHP_CodeSniffer::isCamelCaps($objVarNamefalsetruefalse) === false) {
                        
$error 'Variable "%s" is not in valid camel caps format';
                        
$data  = array($originalVarName);
                        
$phpcsFile->addError($error$var'NotCamelCaps'$data);
                    }
                }
//end if
            
}//end if
        
}//end if

        // There is no way for us to know if the var is public or private,
        // so we have to ignore a leading underscore if there is one and just
        // check the main part of the variable name.
        
$originalVarName $varName;
        if (
substr($varName01) === '_') {
            
$objOperator $phpcsFile->findPrevious(array(T_WHITESPACE), ($stackPtr 1), nulltrue);
            if (
$tokens[$objOperator]['code'] === T_DOUBLE_COLON) {
                
// The variable lives within a class, and is referenced like
                // this: MyClass::$_variable, so we don't know its scope.
                
$inClass true;
            } else {
                
$inClass $phpcsFile->hasCondition($stackPtr, array(T_CLASST_INTERFACE));
            }

            if (
$inClass === true) {
                
$varName substr($varName1);
            }
        }

        if (
PHP_CodeSniffer::isCamelCaps($varNamefalsetruefalse) === false) {
            
$error 'Variable "%s" is not in valid camel caps format';
            
$data  = array($originalVarName);
            
$phpcsFile->addError($error$stackPtr'NotCamelCaps'$data);
        }

    }
//end processVariable()


    /**
     * Processes class member variables.
     *
     * @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
     */
    
protected function processMemberVar(PHP_CodeSniffer_File $phpcsFile$stackPtr)
    {
        
$tokens $phpcsFile->getTokens();

        
$varName     ltrim($tokens[$stackPtr]['content'], '$');
        
$memberProps $phpcsFile->getMemberProperties($stackPtr);
        if (empty(
$memberProps) === true) {
            
// Couldn't get any info about this variable, which
            // generally means it is invalid or possibly has a parse
            // error. Any errors will be reported by the core, so
            // we can ignore it.
            
return;
        }

        
$public    = ($memberProps['scope'] !== 'private');
        
$errorData = array($varName);

        if (
$public === true) {
            if (
substr($varName01) === '_') {
                
$error '%s member variable "%s" must not contain a leading underscore';
                
$data  = array(
                          
ucfirst($memberProps['scope']),
                          
$errorData[0],
                         );
                
$phpcsFile->addError($error$stackPtr'PublicHasUnderscore'$data);
                return;
            }
        } else {
            if (
substr($varName01) !== '_') {
                
$error 'Private member variable "%s" must contain a leading underscore';
                
$phpcsFile->addError($error$stackPtr'PrivateNoUnderscore'$errorData);
                return;
            }
        }

        if (
PHP_CodeSniffer::isCamelCaps($varNamefalse$publicfalse) === false) {
            
$error 'Variable "%s" is not in valid camel caps format';
            
$phpcsFile->addError($error$stackPtr'MemberNotCamelCaps'$errorData);
        }

    }
//end processMemberVar()


    /**
     * Processes the variable found within a double quoted string.
     *
     * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
     * @param int                  $stackPtr  The position of the double quoted
     *                                        string.
     *
     * @return void
     */
    
protected function processVariableInString(PHP_CodeSniffer_File $phpcsFile$stackPtr)
    {
        
$tokens $phpcsFile->getTokens();

        
$phpReservedVars = array(
                            
'_SERVER',
                            
'_GET',
                            
'_POST',
                            
'_REQUEST',
                            
'_SESSION',
                            
'_ENV',
                            
'_COOKIE',
                            
'_FILES',
                            
'GLOBALS',
                           );
        if (
preg_match_all('|[^\\\]\${?([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)|'$tokens[$stackPtr]['content'], $matches) !== 0) {
            foreach (
$matches[1] as $varName) {
                
// If it's a php reserved var, then its ok.
                
if (in_array($varName$phpReservedVars) === true) {
                    continue;
                }

                
// There is no way for us to know if the var is public or private,
                // so we have to ignore a leading underscore if there is one and just
                // check the main part of the variable name.
                
$originalVarName $varName;
                if (
substr($varName01) === '_') {
                    if (
$phpcsFile->hasCondition($stackPtr, array(T_CLASST_INTERFACE)) === true) {
                        
$varName substr($varName1);
                    }
                }

                if (
PHP_CodeSniffer::isCamelCaps($varNamefalsetruefalse) === false) {
                    
$varName $matches[0];
                    
$error 'Variable "%s" is not in valid camel caps format';
                    
$data  = array($originalVarName);
                    
$phpcsFile->addError($error$stackPtr'StringNotCamelCaps'$data);
                    
                }
            }
        }
//end if

    
}//end processVariableInString()


}//end class

?>

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ ok ]

:: Make Dir ::
 
[ ok ]
:: Make File ::
 
[ ok ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 1.0 pre-release build #13 powered by Captain Crunch Security Team | http://ccteam.ru | Generation time: 0.0312 ]--