/** * This method tests that the parser does not substitute keyword tokens in * a class or object operator chain. * * @param string $sourceFile Name of the text file. * @param array(integer) $tokenTypes List of all expected token types. * * @return void * @dataProvider dataProviderTokenizerKeywordSubstitutionInOperatorChain */ public function testTokenizerKeywordSubstitutionInOperatorChain($sourceFile, array $tokenTypes) { $tokenizer = new PHPTokenizerInternal(); $tokenizer->setSourceFile($this->createCodeResourceURI($sourceFile)); $actual = array(); while (is_object($token = $tokenizer->next())) { $actual[] = $token->type; } $this->assertEquals($tokenTypes, $actual); }
/** * Tests that the parser detects the classname scalar. * * <code> * $className = stdClass::class; * </code> * * @return void */ public function testClassNameScalarKeyword() { $tokenizer = new PHPTokenizerInternal(); $tokenizer->setSourceFile($this->createCodeResourceURI('bugs/124/testClassNameScalarKeyword.php')); $actual = array(); while (is_object($token = $tokenizer->next())) { $actual[] = $token->type; } $tokenTypes = array(Tokens::T_OPEN_TAG, Tokens::T_VARIABLE, Tokens::T_EQUAL, Tokens::T_STRING, Tokens::T_DOUBLE_COLON, Tokens::T_CLASS_FQN, Tokens::T_SEMICOLON); $this->assertEquals($tokenTypes, $actual); }
/** * Returns an array with the token types found in a file associated with * the currently running test. * * @return array(integer) */ private function _getTokenTypesForTest() { $tokenizer = new PHPTokenizerInternal(); $tokenizer->setSourceFile(self::createCodeResourceUriForTest()); $types = array(); while (is_object($token = $tokenizer->next())) { $types[] = $token->type; } return $types; }