Пример #1
0
 /**
  * Creates a token pattern.
  *
  * @param string $str The tokens string that the pattern should match.
  *
  * @return array The pattern step.
  * @see    createSkipPattern()
  * @see    parse()
  */
 private function createTokenPattern($str)
 {
     // Don't add a space after the closing php tag as it will add a new
     // whitespace token.
     $tokenizer = new PHP('<?php ' . $str . '?>', null);
     // Remove the <?php tag from the front and the end php tag from the back.
     $tokens = $tokenizer->getTokens();
     $tokens = array_slice($tokens, 1, count($tokens) - 2);
     $patterns = array();
     foreach ($tokens as $patternInfo) {
         $patterns[] = array('type' => 'token', 'token' => $patternInfo['code'], 'value' => $patternInfo['content']);
     }
     return $patterns;
 }