HippoPHP\Hippo\CheckContext::getTokenList PHP Method

getTokenList() public method

public getTokenList ( ) : HippoPHP\Tokenizer\TokenListIterator
return HippoPHP\Tokenizer\TokenListIterator
    public function getTokenList()
    {
        $tokenListIterator = $this->lazyFactory->get(self::CONTEXT_TOKEN_LIST, function () {
            $tokenizer = new Tokenizer();
            return $tokenizer->tokenize($this->file->getSource());
        });
        $tokenListIterator->rewind();
        return $tokenListIterator;
    }

Usage Example

 /**
  * checkFileInternal(): defined by AbstractCheck.
  *
  * @see AbstractCheck::checkFileInternal()
  *
  * @param CheckContext $checkContext
  * @param Config       $config
  */
 protected function checkFileInternal(CheckContext $checkContext, Config $config)
 {
     $file = $checkContext->getFile();
     $tokens = $checkContext->getTokenList();
     $firstToken = $tokens->rewind()->current();
     if (!$firstToken->isType(T_OPEN_TAG)) {
         $this->addViolation($file, 1, 1, 'Files must begin with the PHP open tag.');
     }
 }
All Usage Examples Of HippoPHP\Hippo\CheckContext::getTokenList