Exemple #1
0
 /**
  * Visits a directive node
  *
  * @param DirectiveNode $node The node
  * @param VisitorArguments $arguments The arguments
  * @return DirectiveNode|null
  */
 public function visitDirective(DirectiveNode $node, VisitorArguments $arguments)
 {
     if ($node->name === '@charset') {
         if (!$node->getIsReferenced()) {
             return null;
         }
         // Only output the debug info together with subsequent @charset definitions
         // a comment (or @media statement) before the actual @charset directive would
         // be considered illegal css as it has to be on the first line
         if ($this->charset) {
             if ($node->debugInfo) {
                 $comment = new CommentNode(sprintf("/* %s */\n", str_replace("\n", '', $node->toCSS($this->getContext()))));
                 $comment->debugInfo = $node->debugInfo;
                 return $this->visit($comment);
             }
             return null;
         }
         $this->charset = true;
     }
     if (count($node->rules)) {
         // it is still true that it is only one ruleset in array
         // this is last such moment
         $this->mergeRules($node->rules[0]->rules);
         $node->accept($this);
         $arguments->visitDeeper = false;
         // the directive was directly referenced and therefore needs to be shown in the output
         if ($node->getIsReferenced()) {
             return $node;
         }
         if (!count($node->rules)) {
             return null;
         }
         // the directive was not directly referenced - we need to check whether some of its children
         // was referenced
         if ($this->hasVisibleChild($node)) {
             // marking as referenced in case the directive is stored inside another directive
             $node->markReferenced();
             return $node;
         }
         // The directive was not directly referenced and does not contain anything that
         // was referenced. Therefore it must not be shown in output.
         return null;
     } else {
         if (!$node->getIsReferenced()) {
             return null;
         }
     }
     return $node;
 }
Exemple #2
0
 /**
  * @covers variable
  */
 public function testVariable()
 {
     // FIXME: implement more!
     $d = new DirectiveNode('15', new AnonymousNode('bar'));
     $this->assertEquals(null, $d->variable('foo'));
 }