extensions/felixfbecker.php-intellisense-0.0.12/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.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();
        $openTag = $tokens[$stackPtr];
        $content = $openTag['content'];
        if (trim($content) === '') {
            return;
        }
        if ($openTag['code'] === T_OPEN_TAG) {
            if ($content === '<%') {
                $error     = 'ASP style opening tag used; expected "<?php" but found "%s"';
                $closer    = $this->findClosingTag($phpcsFile, $tokens, $stackPtr, '%>');
                $errorCode = 'ASPOpenTagFound';
            } else if (strpos($content, '<script ') !== false) {
                $error     = 'Script style opening tag used; expected "<?php" but found "%s"';
                $closer    = $this->findClosingTag($phpcsFile, $tokens, $stackPtr, '</script>');
                $errorCode = 'ScriptOpenTagFound';
            }
            if (isset($error, $closer, $errorCode) === true) {
                $data = array($content);
                if ($closer === false) {
                    $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
                } else {
                    $fix = $phpcsFile->addFixableError($error, $stackPtr, $errorCode, $data);
                    if ($fix === true) {
                        $this->addChangeset($phpcsFile, $tokens, $stackPtr, $closer);
                    }
                }
            }
            return;
        }
        if ($openTag['code'] === T_OPEN_TAG_WITH_ECHO && $content === '<%=') {
            $error   = 'ASP style opening tag used with echo; expected "<?php echo %s ..." but found "%s %s ..."';
            $nextVar = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
            $snippet = $this->getSnippet($tokens[$nextVar]['content']);
            $data    = array(
                        $snippet,
                        $content,
                        $snippet,
                       );
            $closer = $this->findClosingTag($phpcsFile, $tokens, $stackPtr, '%>');
            if ($closer === false) {
                $phpcsFile->addError($error, $stackPtr, 'ASPShortOpenTagFound', $data);
            } else {
                $fix = $phpcsFile->addFixableError($error, $stackPtr, 'ASPShortOpenTagFound', $data);
                if ($fix === true) {
                    $this->addChangeset($phpcsFile, $tokens, $stackPtr, $closer, true);
                }
            }
            return;
        }
        if ($openTag['code'] === T_INLINE_HTML
            && preg_match('`((?:<s)?cript (?:[^>]+)?language=[\'"]?php[\'"]?(?:[^>]+)?>)`i', $content, $match) === 1
        ) {
            $error   = 'Script style opening tag used; expected "<?php" but found "%s"';
            $snippet = $this->getSnippet($content, $match[1]);
            $data    = array($match[1].$snippet);
            $phpcsFile->addError($error, $stackPtr, 'ScriptOpenTagFound', $data);
            return;
        }
        if ($openTag['code'] === T_INLINE_HTML && $this->aspTags === false) {
            if (strpos($content, '<%=') !== false) {
                $error   = 'Possible use of ASP style short opening tags detected. Needs manual inspection. Found: %s';
                $snippet = $this->getSnippet($content, '<%=');
                $data    = array('<%='.$snippet);
                $phpcsFile->addWarning($error, $stackPtr, 'MaybeASPShortOpenTagFound', $data);
            } else if (strpos($content, '<%') !== false) {
                $error   = 'Possible use of ASP style opening tags detected. Needs manual inspection. Found: %s';
                $snippet = $this->getSnippet($content, '<%');
                $data    = array('<%'.$snippet);
                $phpcsFile->addWarning($error, $stackPtr, 'MaybeASPOpenTagFound', $data);
            }
        }
    }
public function process ( File $ phpcsFile , $ stackPtr ) { $ tokens = $ phpcsFile -> getTokens ( ) ; $ openTag = $ tokens [ $ stackPtr ] ; $ content = $ openTag [ 'content' ] ; if ( trim ( $ content ) === '' ) { return ; } if ( $ openTag [ 'code' ] === T_OPEN_TAG ) { if ( $ content === '<%' ) { $ error = 'ASP style opening tag used; expected "<?php" but found "%s"' ; $ closer = $ this -> findClosingTag ( $ phpcsFile , $ tokens , $ stackPtr , '%>' ) ; $ errorCode = 'ASPOpenTagFound' ; } else if ( strpos ( $ content , '<script ' ) !== false ) { $ error = 'Script style opening tag used; expected "<?php" but found "%s"' ; $ closer = $ this -> findClosingTag ( $ phpcsFile , $ tokens , $ stackPtr , '</script>' ) ; $ errorCode = 'ScriptOpenTagFound' ; } if ( isset ( $ error , $ closer , $ errorCode ) === true ) { $ data = array ( $ content ) ; if ( $ closer === false ) { $ phpcsFile -> addError ( $ error , $ stackPtr , $ errorCode , $ data ) ; } else { $ fix = $ phpcsFile -> addFixableError ( $ error , $ stackPtr , $ errorCode , $ data ) ; if ( $ fix === true ) { $ this -> addChangeset ( $ phpcsFile , $ tokens , $ stackPtr , $ closer ) ; } } } return ; } if ( $ openTag [ 'code' ] === T_OPEN_TAG_WITH_ECHO && $ content === '<%=' ) { $ error = 'ASP style opening tag used with echo; expected "<?php echo %s ..." but found "%s %s ..."' ; $ nextVar = $ phpcsFile -> findNext ( T_WHITESPACE , ( $ stackPtr + 1 ) , null , true ) ; $ snippet = $ this -> getSnippet ( $ tokens [ $ nextVar ] [ 'content' ] ) ; $ data = array ( $ snippet , $ content , $ snippet , ) ; $ closer = $ this -> findClosingTag ( $ phpcsFile , $ tokens , $ stackPtr , '%>' ) ; if ( $ closer === false ) { $ phpcsFile -> addError ( $ error , $ stackPtr , 'ASPShortOpenTagFound' , $ data ) ; } else { $ fix = $ phpcsFile -> addFixableError ( $ error , $ stackPtr , 'ASPShortOpenTagFound' , $ data ) ; if ( $ fix === true ) { $ this -> addChangeset ( $ phpcsFile , $ tokens , $ stackPtr , $ closer , true ) ; } } return ; } if ( $ openTag [ 'code' ] === T_INLINE_HTML && preg_match ( '`((?:<s)?cript (?:[^>]+)?language=[\'"]?php[\'"]?(?:[^>]+)?>)`i' , $ content , $ match ) === 1 ) { $ error = 'Script style opening tag used; expected "<?php" but found "%s"' ; $ snippet = $ this -> getSnippet ( $ content , $ match [ 1 ] ) ; $ data = array ( $ match [ 1 ] . $ snippet ) ; $ phpcsFile -> addError ( $ error , $ stackPtr , 'ScriptOpenTagFound' , $ data ) ; return ; } if ( $ openTag [ 'code' ] === T_INLINE_HTML && $ this -> aspTags === false ) { if ( strpos ( $ content , '<%=' ) !== false ) { $ error = 'Possible use of ASP style short opening tags detected. Needs manual inspection. Found: %s' ; $ snippet = $ this -> getSnippet ( $ content , '<%=' ) ; $ data = array ( '<%=' . $ snippet ) ; $ phpcsFile -> addWarning ( $ error , $ stackPtr , 'MaybeASPShortOpenTagFound' , $ data ) ; } else if ( strpos ( $ content , '<%' ) !== false ) { $ error = 'Possible use of ASP style opening tags detected. Needs manual inspection. Found: %s' ; $ snippet = $ this -> getSnippet ( $ content , '<%' ) ; $ data = array ( '<%' . $ snippet ) ; $ phpcsFile -> addWarning ( $ error , $ stackPtr , 'MaybeASPOpenTagFound' , $ data ) ; } } }
Processes this test, when one of its tokens is encountered.
Processes this test when one of its tokens is encountered .
//end if //end if // Account for incorrect script open tags. // The "(?:<s)?" in the regex is to work-around a bug in PHP 5.2.