extensions/felixfbecker.php-intellisense-0.0.12/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.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)
    {
        $this->spacing = (int) $this->spacing;
        $tokens = $phpcsFile->getTokens();
        if ($tokens[($stackPtr - 1)]['code'] !== T_WHITESPACE) {
            $before = 0;
        } else {
            if ($tokens[($stackPtr - 2)]['line'] !== $tokens[$stackPtr]['line']) {
                $before = 'newline';
            } else {
                $before = $tokens[($stackPtr - 1)]['length'];
            }
        }
        if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) {
            $after = 0;
        } else {
            if ($tokens[($stackPtr + 2)]['line'] !== $tokens[$stackPtr]['line']) {
                $after = 'newline';
            } else {
                $after = $tokens[($stackPtr + 1)]['length'];
            }
        }
        $phpcsFile->recordMetric($stackPtr, 'Spacing before string concat', $before);
        $phpcsFile->recordMetric($stackPtr, 'Spacing after string concat', $after);
        if (($before === $this->spacing || ($before === 'newline' && $this->ignoreNewlines === true))
            && ($after === $this->spacing || ($after === 'newline' && $this->ignoreNewlines === true))
        ) {
            return;
        }
        if ($this->spacing === 0) {
            $message = 'Concat operator must not be surrounded by spaces';
            $data    = array();
        } else {
            if ($this->spacing > 1) {
                $message = 'Concat operator must be surrounded by %s spaces';
            } else {
                $message = 'Concat operator must be surrounded by a single space';
            }
            $data = array($this->spacing);
        }
        $fix = $phpcsFile->addFixableError($message, $stackPtr, 'PaddingFound', $data);
        if ($fix === true) {
            $padding = str_repeat(' ', $this->spacing);
            if ($before !== 'newline' || $this->ignoreNewlines === false) {
                if ($tokens[($stackPtr - 1)]['code'] === T_WHITESPACE) {
                    $phpcsFile->fixer->replaceToken(($stackPtr - 1), $padding);
                } else if ($this->spacing > 0) {
                    $phpcsFile->fixer->addContent(($stackPtr - 1), $padding);
                }
            }
            if ($after !== 'newline' || $this->ignoreNewlines === false) {
                if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) {
                    $phpcsFile->fixer->replaceToken(($stackPtr + 1), $padding);
                } else if ($this->spacing > 0) {
                    $phpcsFile->fixer->addContent($stackPtr, $padding);
                }
            }
        }
    }
public function process ( File $ phpcsFile , $ stackPtr ) { $ this -> spacing = ( int ) $ this -> spacing ; $ tokens = $ phpcsFile -> getTokens ( ) ; if ( $ tokens [ ( $ stackPtr - 1 ) ] [ 'code' ] !== T_WHITESPACE ) { $ before = 0 ; } else { if ( $ tokens [ ( $ stackPtr - 2 ) ] [ 'line' ] !== $ tokens [ $ stackPtr ] [ 'line' ] ) { $ before = 'newline' ; } else { $ before = $ tokens [ ( $ stackPtr - 1 ) ] [ 'length' ] ; } } if ( $ tokens [ ( $ stackPtr + 1 ) ] [ 'code' ] !== T_WHITESPACE ) { $ after = 0 ; } else { if ( $ tokens [ ( $ stackPtr + 2 ) ] [ 'line' ] !== $ tokens [ $ stackPtr ] [ 'line' ] ) { $ after = 'newline' ; } else { $ after = $ tokens [ ( $ stackPtr + 1 ) ] [ 'length' ] ; } } $ phpcsFile -> recordMetric ( $ stackPtr , 'Spacing before string concat' , $ before ) ; $ phpcsFile -> recordMetric ( $ stackPtr , 'Spacing after string concat' , $ after ) ; if ( ( $ before === $ this -> spacing || ( $ before === 'newline' && $ this -> ignoreNewlines === true ) ) && ( $ after === $ this -> spacing || ( $ after === 'newline' && $ this -> ignoreNewlines === true ) ) ) { return ; } if ( $ this -> spacing === 0 ) { $ message = 'Concat operator must not be surrounded by spaces' ; $ data = array ( ) ; } else { if ( $ this -> spacing > 1 ) { $ message = 'Concat operator must be surrounded by %s spaces' ; } else { $ message = 'Concat operator must be surrounded by a single space' ; } $ data = array ( $ this -> spacing ) ; } $ fix = $ phpcsFile -> addFixableError ( $ message , $ stackPtr , 'PaddingFound' , $ data ) ; if ( $ fix === true ) { $ padding = str_repeat ( ' ' , $ this -> spacing ) ; if ( $ before !== 'newline' || $ this -> ignoreNewlines === false ) { if ( $ tokens [ ( $ stackPtr - 1 ) ] [ 'code' ] === T_WHITESPACE ) { $ phpcsFile -> fixer -> replaceToken ( ( $ stackPtr - 1 ) , $ padding ) ; } else if ( $ this -> spacing > 0 ) { $ phpcsFile -> fixer -> addContent ( ( $ stackPtr - 1 ) , $ padding ) ; } } if ( $ after !== 'newline' || $ this -> ignoreNewlines === false ) { if ( $ tokens [ ( $ stackPtr + 1 ) ] [ 'code' ] === T_WHITESPACE ) { $ phpcsFile -> fixer -> replaceToken ( ( $ stackPtr + 1 ) , $ padding ) ; } else if ( $ this -> spacing > 0 ) { $ phpcsFile -> fixer -> addContent ( $ stackPtr , $ padding ) ; } } } }
Processes this test, when one of its tokens is encountered.
Processes this test when one of its tokens is encountered .