Lines Matching refs:stackPtr
346 * @param int $stackPtr The position of the token in the token stack.
350 public function getTokenContent($stackPtr) argument
353 && isset($this->_changeset[$stackPtr]) === true
355 return $this->_changeset[$stackPtr];
357 return $this->_tokens[$stackPtr];
405 foreach ($this->_changeset as $stackPtr => $content) {
406 $success = $this->replaceToken($stackPtr, $content);
410 $applied[] = $stackPtr;
416 foreach ($applied as $stackPtr) {
417 $this->revertToken($stackPtr);
475 * @param int $stackPtr The position of the token in the token stack.
480 public function replaceToken($stackPtr, $content) argument
487 && isset($this->_fixedTokens[$stackPtr]) === true
496 echo "$indent* token $stackPtr has already been modified, skipping *".PHP_EOL;
514 $type = $tokens[$stackPtr]['type'];
515 $oldContent = PHP_CodeSniffer::prepareForOutput($this->_tokens[$stackPtr]);
517 … if (trim($this->_tokens[$stackPtr]) === '' && isset($this->_tokens[($stackPtr + 1)]) === true) {
519 $append = PHP_CodeSniffer::prepareForOutput($this->_tokens[($stackPtr + 1)]);
526 $this->_changeset[$stackPtr] = $content;
530 …echo "\t\tQ: $sniff (line $line) replaced token $stackPtr ($type) \"$oldContent\" => \"$newContent…
537 if (isset($this->_oldTokenValues[$stackPtr]) === false) {
538 $this->_oldTokenValues[$stackPtr] = array(
540 'prev' => $this->_tokens[$stackPtr],
544 if ($this->_oldTokenValues[$stackPtr]['prev'] === $content
545 && $this->_oldTokenValues[$stackPtr]['loop'] === ($this->loops - 1)
553 $loop = $this->_oldTokenValues[$stackPtr]['loop'];
557 …echo "$indent**** replaced token $stackPtr ($type) \"$oldContent\" => \"$newContent\" ****".PHP_EO…
560 if ($this->_oldTokenValues[$stackPtr]['loop'] >= ($this->loops - 1)) {
574 $this->_oldTokenValues[$stackPtr]['prev'] = $this->_oldTokenValues[$stackPtr]['curr'];
575 $this->_oldTokenValues[$stackPtr]['curr'] = $content;
576 $this->_oldTokenValues[$stackPtr]['loop'] = $this->loops;
579 $this->_fixedTokens[$stackPtr] = $this->_tokens[$stackPtr];
580 $this->_tokens[$stackPtr] = $content;
590 …echo "$indent$sniff (line $line) replaced token $stackPtr ($type) \"$oldContent\" => \"$newContent…
602 * @param int $stackPtr The position of the token in the token stack.
606 public function revertToken($stackPtr) argument
608 if (isset($this->_fixedTokens[$stackPtr]) === false) {
623 $type = $tokens[$stackPtr]['type'];
624 $oldContent = PHP_CodeSniffer::prepareForOutput($this->_tokens[$stackPtr]);
625 $newContent = PHP_CodeSniffer::prepareForOutput($this->_fixedTokens[$stackPtr]);
626 … if (trim($this->_tokens[$stackPtr]) === '' && isset($tokens[($stackPtr + 1)]) === true) {
628 $append = PHP_CodeSniffer::prepareForOutput($this->_tokens[($stackPtr + 1)]);
634 $this->_tokens[$stackPtr] = $this->_fixedTokens[$stackPtr];
635 unset($this->_fixedTokens[$stackPtr]);
645 …echo "$indent$sniff (line $line) reverted token $stackPtr ($type) \"$oldContent\" => \"$newContent…
657 * @param int $stackPtr The position of the token in the token stack.
664 public function substrToken($stackPtr, $start, $length=null) argument
666 $current = $this->getTokenContent($stackPtr);
674 return $this->replaceToken($stackPtr, $newContent);
682 * @param int $stackPtr The position of the token in the token stack.
686 public function addNewline($stackPtr) argument
688 $current = $this->getTokenContent($stackPtr);
689 return $this->replaceToken($stackPtr, $current.$this->_currentFile->eolChar);
697 * @param int $stackPtr The position of the token in the token stack.
701 public function addNewlineBefore($stackPtr) argument
703 $current = $this->getTokenContent($stackPtr);
704 return $this->replaceToken($stackPtr, $this->_currentFile->eolChar.$current);
712 * @param int $stackPtr The position of the token in the token stack.
717 public function addContent($stackPtr, $content) argument
719 $current = $this->getTokenContent($stackPtr);
720 return $this->replaceToken($stackPtr, $current.$content);
728 * @param int $stackPtr The position of the token in the token stack.
733 public function addContentBefore($stackPtr, $content) argument
735 $current = $this->getTokenContent($stackPtr);
736 return $this->replaceToken($stackPtr, $content.$current);