コード例 #1
0
 /**
  * @param TokenNode $node
  *
  * @return string
  */
 protected function printTokenNode(TokenNode $node)
 {
     $token = $node->getValue();
     if ($token instanceof EscapeToken) {
         // Not supported yet
         return '';
     }
     if ($token->is('T_PERIOD') && (!$node->getParent() instanceof BlockNode || $node->getParent() instanceof BlockNode && $node->getParent()->isSubPattern())) {
         $range = range('a', 'Z');
         return $range[mt_rand(0, count($range) - 1)];
     }
     return $token->getValue();
 }
コード例 #2
0
 /**
  * @param TokenNode $node
  *
  * @return \DOMElement
  */
 protected function formatTokenNode(TokenNode $node)
 {
     $token = $node->getValue();
     $xmlNode = $this->createXmlNode('token', $token->getValue());
     $xmlNode->setAttribute('type', str_replace('_', '-', strtolower(substr($token->getName(), 2))));
     if ($token instanceof EscapeToken) {
         $xmlNode->setAttribute('exclusion-sequence', $token->isExclusionSequence() ? 'true' : 'false');
     }
     return $xmlNode;
 }