PDepend\Source\Language\PHP\PHPTokenizerInternal::prev PHP Method

prev() public method

Returns the previous token type or {@link \PDepend\Source\Tokenizer\Tokenizer::T_BOF} if there is no previous token.
public prev ( ) : integer
return integer
    public function prev()
    {
        $this->tokenize();
        if ($this->index > 1) {
            return $this->tokens[$this->index - 2]->type;
        }
        return self::T_BOF;
    }

Usage Example

 /**
  * Tests that the tokenizer returns <b>T_BOF</b> if there is no previous
  * token.
  *
  * @return void
  */
 public function testInternalReturnsBOFTokenForPrevCall()
 {
     $tokenizer = new PHPTokenizerInternal();
     $tokenizer->setSourceFile(self::createCodeResourceUriForTest());
     $this->assertEquals(Tokenizer::T_BOF, $tokenizer->prev());
 }