/** * {@inheritdoc} */ public function isCandidate(Tokens $tokens) { # handle `T_ELSE T_WHITESPACE T_IF` treated as single `T_ELSEIF` by HHVM # see https://github.com/facebook/hhvm/issues/4796 if (defined('HHVM_VERSION') && $tokens->isTokenKindFound(T_ELSEIF)) { return true; } return $tokens->isAllTokenKindsFound(array(T_IF, T_ELSE)); }
private function assertTokens(Tokens $expectedTokens, Tokens $inputTokens) { foreach ($expectedTokens as $index => $expectedToken) { $inputToken = $inputTokens[$index]; $this->assertTrue($expectedToken->equals($inputToken), sprintf('The token at index %d must be %s, got %s', $index, $expectedToken->toJson(), $inputToken->toJson())); } $this->assertSame($expectedTokens->count(), $inputTokens->count(), 'The collection must have the same length than the expected one.'); $foundTokenKinds = array_keys(AccessibleObject::create($expectedTokens)->foundTokenKinds); foreach ($foundTokenKinds as $tokenKind) { $this->assertTrue($inputTokens->isTokenKindFound($tokenKind), sprintf('The token kind %s must be found in fixed tokens collection.', $tokenKind)); } }
private function assertTokens(Tokens $expectedTokens, Tokens $inputTokens) { foreach ($expectedTokens as $index => $expectedToken) { $inputToken = $inputTokens[$index]; $this->assertTrue($expectedToken->equals($inputToken), sprintf('The token at index %d must be %s, got %s', $index, $expectedToken->toJson(), $inputToken->toJson())); } $this->assertSame($expectedTokens->count(), $inputTokens->count(), 'The collection must have the same length than the expected one.'); $tokensReflection = new \ReflectionClass($expectedTokens); $propertyReflection = $tokensReflection->getProperty('foundTokenKinds'); $propertyReflection->setAccessible(true); $foundTokenKinds = array_keys($propertyReflection->getValue($expectedTokens)); foreach ($foundTokenKinds as $tokenKind) { $this->assertTrue($inputTokens->isTokenKindFound($tokenKind), sprintf('The token kind %s must be found in fixed tokens collection.', $tokenKind)); } }
/** * {@inheritdoc} */ public function isCandidate(Tokens $tokens) { return $tokens->isTokenKindFound(T_DOC_COMMENT); }
/** * {@inheritdoc} */ public function isCandidate(Tokens $tokens) { return $tokens->isTokenKindFound(T_STRING); }
/** * {@inheritdoc} */ public function isCandidate(Tokens $tokens) { return $tokens->isTokenKindFound(T_DOUBLE_ARROW); }
/** * {@inheritdoc} */ public function isCandidate(Tokens $tokens) { return $tokens->isTokenKindFound(T_FUNCTION); }
/** * {@inheritdoc} */ public function isCandidate(Tokens $tokens) { return $tokens->isTokenKindFound(T_WHITESPACE); }
/** * {@inheritdoc} */ public function isCandidate(Tokens $tokens) { return $tokens->isTokenKindFound(T_CLOSE_TAG); }
/** * {@inheritdoc} */ public function isCandidate(Tokens $tokens) { return $tokens->isTokenKindFound(T_CONSTANT_ENCAPSED_STRING); }
/** * {@inheritdoc} */ public function isCandidate(Tokens $tokens) { return $tokens->isTokenKindFound(T_OPEN_TAG_WITH_ECHO); }
/** * {@inheritdoc} */ public function isCandidate(Tokens $tokens) { return $tokens->isTokenKindFound(T_START_HEREDOC); }
/** * {@inheritdoc} */ public function isCandidate(Tokens $tokens) { return $tokens->isTokenKindFound(T_OBJECT_OPERATOR); }
/** * {@inheritdoc} */ public function isCandidate(Tokens $tokens) { return $tokens->isTokenKindFound(T_IS_NOT_EQUAL); }
/** * {@inheritdoc} */ public function isCandidate(Tokens $tokens) { return $tokens->isTokenKindFound(CT_ARRAY_SQUARE_BRACE_OPEN); }