extensions/felixfbecker.php-intellisense-0.0.12/vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Sniffs/Functions/ValidDefaultValueSniff.php
/**
     * 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
     */
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
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(File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();
        $argStart = $tokens[$stackPtr]['parenthesis_opener'];
        $argEnd   = $tokens[$stackPtr]['parenthesis_closer'];
        $defaultFound = false;
        $nextArg = $argStart;
        while (($nextArg = $phpcsFile->findNext(T_VARIABLE, ($nextArg + 1), $argEnd)) !== false) {
            if ($tokens[($nextArg - 1)]['code'] === T_ELLIPSIS) {
                continue;
            }
            $argHasDefault = false;
            $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($nextArg + 1), null, true);
            if ($tokens[$next]['code'] === T_EQUAL) {
                $argHasDefault = true;
            }
            if ($argHasDefault === false && $defaultFound === true) {
                $error = 'Arguments with default values must be at the end of the argument list';
                $phpcsFile->addError($error, $nextArg, 'NotAtEnd');
                return;
            }
            if ($argHasDefault === true) {
                $defaultFound = true;
                $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($next + 1), null, true);
                if ($tokens[$next]['code'] === T_NULL) {
                    $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($nextArg - 1), null, true);
                    if ($tokens[$prev]['code'] === T_STRING
                        || $tokens[$prev]['code'] === T_ARRAY_HINT
                    ) {
                        $defaultFound = false;
                    }
                }
            }
        }
    }
public function process ( File $ phpcsFile , $ stackPtr ) { $ tokens = $ phpcsFile -> getTokens ( ) ; $ argStart = $ tokens [ $ stackPtr ] [ 'parenthesis_opener' ] ; $ argEnd = $ tokens [ $ stackPtr ] [ 'parenthesis_closer' ] ; $ defaultFound = false ; $ nextArg = $ argStart ; while ( ( $ nextArg = $ phpcsFile -> findNext ( T_VARIABLE , ( $ nextArg + 1 ) , $ argEnd ) ) !== false ) { if ( $ tokens [ ( $ nextArg - 1 ) ] [ 'code' ] === T_ELLIPSIS ) { continue ; } $ argHasDefault = false ; $ next = $ phpcsFile -> findNext ( Tokens :: $ emptyTokens , ( $ nextArg + 1 ) , null , true ) ; if ( $ tokens [ $ next ] [ 'code' ] === T_EQUAL ) { $ argHasDefault = true ; } if ( $ argHasDefault === false && $ defaultFound === true ) { $ error = 'Arguments with default values must be at the end of the argument list' ; $ phpcsFile -> addError ( $ error , $ nextArg , 'NotAtEnd' ) ; return ; } if ( $ argHasDefault === true ) { $ defaultFound = true ; $ next = $ phpcsFile -> findNext ( Tokens :: $ emptyTokens , ( $ next + 1 ) , null , true ) ; if ( $ tokens [ $ next ] [ 'code' ] === T_NULL ) { $ prev = $ phpcsFile -> findPrevious ( Tokens :: $ emptyTokens , ( $ nextArg - 1 ) , null , true ) ; if ( $ tokens [ $ prev ] [ 'code' ] === T_STRING || $ tokens [ $ prev ] [ 'code' ] === T_ARRAY_HINT ) { $ defaultFound = false ; } } } } }
Processes this test, when one of its tokens is encountered.
Processes this test when one of its tokens is encountered .
// Flag for when we have found a default in our arg list. // If there is a value without a default after this, it is an error. // Check if the arg is type hinted and using NULL for the default. // This does not make the argument optional - it just allows NULL // to be passed in. //end while