extensions/felixfbecker.php-intellisense-0.0.12/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/ControlStructures/InlineIfDeclarationSniff.php
/**
     * Processes this sniff, 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 sniff, 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 sniff 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();
        $openBracket  = null;
        $closeBracket = null;
        if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) {
            $parens       = $tokens[$stackPtr]['nested_parenthesis'];
            $openBracket  = array_pop($parens);
            $closeBracket = $tokens[$openBracket]['parenthesis_closer'];
        }
        $else         = $phpcsFile->findNext(T_INLINE_ELSE, ($stackPtr + 1));
        $statementEnd = $phpcsFile->findNext(array(T_SEMICOLON, T_COMMA), ($else + 1), $closeBracket);
        if ($statementEnd === false) {
            $statementEnd = $phpcsFile->findPrevious(T_WHITESPACE, ($closeBracket - 1), null, true);
        }
        if ($tokens[$statementEnd]['line'] !== $tokens[$stackPtr]['line']) {
            $error = 'Inline shorthand IF statement must be declared on a single line';
            $phpcsFile->addError($error, $stackPtr, 'NotSingleLine');
            return;
        }
        $contentBefore = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
        $contentAfter  = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
        if ($tokens[$contentBefore]['code'] !== T_CLOSE_PARENTHESIS) {
            $error = 'Inline shorthand IF statement requires brackets around comparison';
            $phpcsFile->addError($error, $stackPtr, 'NoBrackets');
            return;
        }
        $spaceBefore = ($tokens[$stackPtr]['column'] - ($tokens[$contentBefore]['column'] + $tokens[$contentBefore]['length']));
        if ($spaceBefore !== 1) {
            $error = 'Inline shorthand IF statement requires 1 space before THEN; %s found';
            $data  = array($spaceBefore);
            $phpcsFile->addError($error, $stackPtr, 'SpacingBeforeThen', $data);
        }
        $spaceAfter = (($tokens[$contentAfter]['column']) - ($tokens[$stackPtr]['column'] + 1));
        if ($spaceAfter !== 1) {
            $error = 'Inline shorthand IF statement requires 1 space after THEN; %s found';
            $data  = array($spaceAfter);
            $phpcsFile->addError($error, $stackPtr, 'SpacingAfterThen', $data);
        }
        $inlineElse    = $phpcsFile->findNext(T_INLINE_ELSE, ($stackPtr + 1), $statementEnd, false);
        $contentBefore = $phpcsFile->findPrevious(T_WHITESPACE, ($inlineElse - 1), null, true);
        $contentAfter  = $phpcsFile->findNext(T_WHITESPACE, ($inlineElse + 1), null, true);
        $spaceBefore = ($tokens[$inlineElse]['column'] - ($tokens[$contentBefore]['column'] + $tokens[$contentBefore]['length']));
        if ($spaceBefore !== 1) {
            $error = 'Inline shorthand IF statement requires 1 space before ELSE; %s found';
            $data  = array($spaceBefore);
            $phpcsFile->addError($error, $inlineElse, 'SpacingBeforeElse', $data);
        }
        $spaceAfter = (($tokens[$contentAfter]['column']) - ($tokens[$inlineElse]['column'] + 1));
        if ($spaceAfter !== 1) {
            $error = 'Inline shorthand IF statement requires 1 space after ELSE; %s found';
            $data  = array($spaceAfter);
            $phpcsFile->addError($error, $inlineElse, 'SpacingAfterElse', $data);
        }
    }
public function process ( File $ phpcsFile , $ stackPtr ) { $ tokens = $ phpcsFile -> getTokens ( ) ; $ openBracket = null ; $ closeBracket = null ; if ( isset ( $ tokens [ $ stackPtr ] [ 'nested_parenthesis' ] ) === true ) { $ parens = $ tokens [ $ stackPtr ] [ 'nested_parenthesis' ] ; $ openBracket = array_pop ( $ parens ) ; $ closeBracket = $ tokens [ $ openBracket ] [ 'parenthesis_closer' ] ; } $ else = $ phpcsFile -> findNext ( T_INLINE_ELSE , ( $ stackPtr + 1 ) ) ; $ statementEnd = $ phpcsFile -> findNext ( array ( T_SEMICOLON , T_COMMA ) , ( $ else + 1 ) , $ closeBracket ) ; if ( $ statementEnd === false ) { $ statementEnd = $ phpcsFile -> findPrevious ( T_WHITESPACE , ( $ closeBracket - 1 ) , null , true ) ; } if ( $ tokens [ $ statementEnd ] [ 'line' ] !== $ tokens [ $ stackPtr ] [ 'line' ] ) { $ error = 'Inline shorthand IF statement must be declared on a single line' ; $ phpcsFile -> addError ( $ error , $ stackPtr , 'NotSingleLine' ) ; return ; } $ contentBefore = $ phpcsFile -> findPrevious ( T_WHITESPACE , ( $ stackPtr - 1 ) , null , true ) ; $ contentAfter = $ phpcsFile -> findNext ( T_WHITESPACE , ( $ stackPtr + 1 ) , null , true ) ; if ( $ tokens [ $ contentBefore ] [ 'code' ] !== T_CLOSE_PARENTHESIS ) { $ error = 'Inline shorthand IF statement requires brackets around comparison' ; $ phpcsFile -> addError ( $ error , $ stackPtr , 'NoBrackets' ) ; return ; } $ spaceBefore = ( $ tokens [ $ stackPtr ] [ 'column' ] - ( $ tokens [ $ contentBefore ] [ 'column' ] + $ tokens [ $ contentBefore ] [ 'length' ] ) ) ; if ( $ spaceBefore !== 1 ) { $ error = 'Inline shorthand IF statement requires 1 space before THEN; %s found' ; $ data = array ( $ spaceBefore ) ; $ phpcsFile -> addError ( $ error , $ stackPtr , 'SpacingBeforeThen' , $ data ) ; } $ spaceAfter = ( ( $ tokens [ $ contentAfter ] [ 'column' ] ) - ( $ tokens [ $ stackPtr ] [ 'column' ] + 1 ) ) ; if ( $ spaceAfter !== 1 ) { $ error = 'Inline shorthand IF statement requires 1 space after THEN; %s found' ; $ data = array ( $ spaceAfter ) ; $ phpcsFile -> addError ( $ error , $ stackPtr , 'SpacingAfterThen' , $ data ) ; } $ inlineElse = $ phpcsFile -> findNext ( T_INLINE_ELSE , ( $ stackPtr + 1 ) , $ statementEnd , false ) ; $ contentBefore = $ phpcsFile -> findPrevious ( T_WHITESPACE , ( $ inlineElse - 1 ) , null , true ) ; $ contentAfter = $ phpcsFile -> findNext ( T_WHITESPACE , ( $ inlineElse + 1 ) , null , true ) ; $ spaceBefore = ( $ tokens [ $ inlineElse ] [ 'column' ] - ( $ tokens [ $ contentBefore ] [ 'column' ] + $ tokens [ $ contentBefore ] [ 'length' ] ) ) ; if ( $ spaceBefore !== 1 ) { $ error = 'Inline shorthand IF statement requires 1 space before ELSE; %s found' ; $ data = array ( $ spaceBefore ) ; $ phpcsFile -> addError ( $ error , $ inlineElse , 'SpacingBeforeElse' , $ data ) ; } $ spaceAfter = ( ( $ tokens [ $ contentAfter ] [ 'column' ] ) - ( $ tokens [ $ inlineElse ] [ 'column' ] + 1 ) ) ; if ( $ spaceAfter !== 1 ) { $ error = 'Inline shorthand IF statement requires 1 space after ELSE; %s found' ; $ data = array ( $ spaceAfter ) ; $ phpcsFile -> addError ( $ error , $ inlineElse , 'SpacingAfterElse' , $ data ) ; } }
Processes this sniff, when one of its tokens is encountered.
Processes this sniff when one of its tokens is encountered .
// Find the beginning of the statement. If we don't find a // semicolon (end of statement) or comma (end of array value) // then assume the content before the closing parenthesis is the end. // Make sure it's all on the same line. // Make sure there are spaces around the question mark. // Make sure the ELSE has the correct spacing.