/**
  * Called when one of the token types that this sniff is listening for
  * is found.
  *
  * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where the
  *                                        token was found.
  * @param int                  $stackPtr  The position in the PHP_CodeSniffer
  *                                        file's token stack where the token
  *                                        was found.
  *
  * @return void
  */
 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
 {
     $this->_phpCsFile = $phpcsFile;
     $varRegExp = '/\\$[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*/';
     $tokens = $phpcsFile->getTokens();
     $content = $tokens[$stackPtr]['content'];
     $matches = array();
     if (preg_match_all($varRegExp, $content, $matches, PREG_OFFSET_CAPTURE) === 0) {
         return;
     }
     foreach ($matches as $match) {
         foreach ($match as $info) {
             list($var, $pos) = $info;
             if ($pos === 1 || $content[$pos - 1] !== '{') {
                 if (strpos(substr($content, 0, $pos), '{') > 0 && strpos(substr($content, 0, $pos), '}') === false) {
                     continue;
                 }
                 $this->_searchForBackslashes($content, $pos);
                 $fix = $this->_phpCsFile->addFixableError(sprintf('must surround variable %s with { }', $var), $stackPtr, 'NotSurroundedWithBraces');
                 if ($fix === true) {
                     $correctVariable = $this->_surroundVariableWithBraces($content, $pos, $var);
                     $this->_fixPhpCsFile($stackPtr, $correctVariable);
                 }
             }
             //end if
         }
         //end foreach
     }
     //end foreach
 }