예제 #1
0
 /**
  * @covers Twig_Node_Expression_Function::__construct
  */
 public function testConstructor()
 {
     $name = 'function';
     $args = new Twig_Node();
     $node = new Twig_Node_Expression_Function($name, $args, 0);
     $this->assertEquals($name, $node->getAttribute('name'));
     $this->assertEquals($args, $node->getNode('arguments'));
 }
예제 #2
0
 /**
  * Processes a Function node.
  * 
  * @param Twig_Node_Expression_Function $node
  */
 protected function processFunctionNode(Twig_Node_Expression_Function $node)
 {
     switch ($node->getAttribute('name')) {
         case '_':
         case 'gettext':
             $this->pushFunction($node, self::MSGID);
             break;
         case '_p':
         case 'pgettext':
             $this->pushFunction($node, self::CONTEXT, self::MSGID);
             break;
         case '_n':
         case 'ngettext':
             $this->pushFunction($node, self::MSGID, self::MSGID_PLURAL, self::VARIABLE);
             break;
         case '_np':
         case 'npgettext':
             $this->pushFunction($node, self::CONTEXT, self::MSGID, self::MSGID_PLURAL, self::VARIABLE);
             break;
         case '_d':
         case 'dgettext':
             $this->pushFunction($node, self::DOMAIN, self::MSGID);
             break;
         case '_dp':
         case 'dpgettext':
             $this->pushFunction($node, self::CONTEXT, self::DOMAIN, self::MSGID);
             break;
         case '_dn':
         case 'dngettext':
             $this->pushFunction($node, self::DOMAIN, self::MSGID, self::MSGID_PLURAL, self::VARIABLE);
             break;
         case '_dnp':
         case 'dnpgettext':
             $this->pushFunction($node, self::CONTEXT, self::DOMAIN, self::MSGID, self::MSGID_PLURAL, self::VARIABLE);
             break;
         case '_dc':
         case 'dcgettext':
             $this->pushFunction($node, self::DOMAIN, self::MSGID, self::CATEGORY);
             break;
         case '_dcp':
         case 'dcpgettext':
             $this->pushFunction($node, self::CONTEXT, self::DOMAIN, self::MSGID, self::CATEGORY);
             break;
         case '_dcn':
         case 'dcngettext':
             $this->pushFunction($node, self::DOMAIN, self::MSGID, self::MSGID_PLURAL, self::VARIABLE, self::CATEGORY);
             break;
         case '_dcnp':
         case 'dcnpgettext':
             $this->pushFunction($node, self::CONTEXT, self::DOMAIN, self::MSGID, self::MSGID_PLURAL, self::VARIABLE, self::CATEGORY);
             break;
     }
 }