Example #1
0
 /**
  * @covers \Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer::isEndOfLoop
  */
 public function testIsEndOfLoop()
 {
     $this->parseFile();
     //We have 27 total tokens in objectsCode.php file (excluding whitespaces)
     //So the isEndOfLoop function should return true after we pick 28th non-existent token
     for ($i = 0; $i < 28; $i += 1) {
         $this->assertFalse($this->tokenizer->isEndOfLoop());
         $this->tokenizer->getNextRealToken();
     }
     $this->assertTrue($this->tokenizer->isEndOfLoop());
 }
 /**
  * @param Token $firstToken
  * @return bool
  */
 protected function extractMethodPhrase(Token $firstToken)
 {
     if ($firstToken->isEqualFunction('__')) {
         $secondToken = $this->_tokenizer->getNextRealToken();
         if ($secondToken && $secondToken->isOpenBrace()) {
             $arguments = $this->_tokenizer->getFunctionArgumentsTokens();
             $phrase = $this->_collectPhrase(array_shift($arguments));
             if (null !== $phrase) {
                 $this->_addPhrase($phrase, count($arguments), $this->_file, $firstToken->getLine());
                 return true;
             }
         }
     }
     return false;
 }