Ejemplo n.º 1
0
 /**
  * {@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));
 }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 5
0
 /**
  * {@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);
 }
Ejemplo n.º 8
0
 /**
  * {@inheritdoc}
  */
 public function isCandidate(Tokens $tokens)
 {
     return $tokens->isTokenKindFound(T_WHITESPACE);
 }
Ejemplo n.º 9
0
 /**
  * {@inheritdoc}
  */
 public function isCandidate(Tokens $tokens)
 {
     return $tokens->isTokenKindFound(T_CLOSE_TAG);
 }
Ejemplo n.º 10
0
 /**
  * {@inheritdoc}
  */
 public function isCandidate(Tokens $tokens)
 {
     return $tokens->isTokenKindFound(T_CONSTANT_ENCAPSED_STRING);
 }
Ejemplo n.º 11
0
 /**
  * {@inheritdoc}
  */
 public function isCandidate(Tokens $tokens)
 {
     return $tokens->isTokenKindFound(T_OPEN_TAG_WITH_ECHO);
 }
Ejemplo n.º 12
0
 /**
  * {@inheritdoc}
  */
 public function isCandidate(Tokens $tokens)
 {
     return $tokens->isTokenKindFound(T_START_HEREDOC);
 }
Ejemplo n.º 13
0
 /**
  * {@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);
 }
Ejemplo n.º 15
0
 /**
  * {@inheritdoc}
  */
 public function isCandidate(Tokens $tokens)
 {
     return $tokens->isTokenKindFound(CT_ARRAY_SQUARE_BRACE_OPEN);
 }