isa() public static method

Returns a value indicating if the token represents this type of node.
public static isa ( object $token ) : boolean
$token object token
return boolean true if the token represents this type of node, false if not
Beispiel #1
0
 /**
  * Creates and returns the next SassNode.
  * The tpye of SassNode depends on the content of the SassToken.
  * @return SassNode a SassNode of the appropriate type. Null when no more
  * source to parse.
  */
 private function getNode($node)
 {
     $token = $this->getToken();
     if (empty($token)) {
         return null;
     }
     switch (true) {
         case SassDirectiveNode::isa($token):
             return $this->parseDirective($token, $node);
             break;
         case SassCommentNode::isa($token):
             return new SassCommentNode($token);
             break;
         case SassVariableNode::isa($token):
             return new SassVariableNode($token);
             break;
         case SassPropertyNode::isa($token, $this->property_syntax):
             return new SassPropertyNode($token, $this->property_syntax);
             break;
         case SassMixinDefinitionNode::isa($token):
             if ($this->syntax === SassFile::SCSS) {
                 throw new SassException('Mixin {which} shortcut not allowed in SCSS', array('{which}' => 'definition'), $this);
             }
             return new SassMixinDefinitionNode($token);
             break;
         case SassMixinNode::isa($token):
             if ($this->syntax === SassFile::SCSS) {
                 throw new SassException('Mixin {which} shortcut not allowed in SCSS', array('{which}' => 'include'), $this);
             }
             return new SassMixinNode($token);
             break;
         default:
             return new SassRuleNode($token);
             break;
     }
     // switch
 }
Beispiel #2
0
 /**
  * Creates and returns the next SassNode.
  * The tpye of SassNode depends on the content of the SassToken.
  * @return SassNode a SassNode of the appropriate type. Null when no more
  * source to parse.
  */
 public function getNode($node)
 {
     $token = $this->getToken();
     if (empty($token)) {
         return null;
     }
     switch (true) {
         case SassDirectiveNode::isa($token):
             return $this->parseDirective($token, $node);
         case SassCommentNode::isa($token):
             return new SassCommentNode($token);
         case SassVariableNode::isa($token):
             return new SassVariableNode($token);
         case SassPropertyNode::isa(array('token' => $token, 'syntax' => $this->property_syntax)):
             return new SassPropertyNode($token, $this->property_syntax);
         case SassFunctionDefinitionNode::isa($token):
             return new SassFunctionDefinitionNode($token);
         case SassMixinDefinitionNode::isa($token):
             if ($this->syntax === SassFile::SCSS) {
                 if ($this->debug) {
                     throw new SassException('Mixin definition shortcut not allowed in SCSS', $this);
                 }
                 return;
             } else {
                 return new SassMixinDefinitionNode($token);
             }
         case SassMixinNode::isa($token):
             if ($this->syntax === SassFile::SCSS) {
                 if ($this->debug) {
                     throw new SassException('Mixin include shortcut not allowed in SCSS', $this);
                 }
                 return;
             } else {
                 return new SassMixinNode($token);
             }
         default:
             return new SassRuleNode($token);
             break;
     }
     // switch
 }
Beispiel #3
0
 /**
  * Parse a line and its children.
  * @param array line to parse
  * @param array remaining lines
  * @param SassNode parent node
  * @return SassNode a SassNode of the appropriate type
  */
 private function parseLine($line, &$lines, $parent)
 {
     if (empty($line)) {
         return null;
     }
     switch (true) {
         case SassCommentNode::isa($line):
             return $this->parseComment($line, $lines);
             break;
         case SassDirectiveNode::isa($line):
             return $this->parseDirective($line, $lines, $parent);
             break;
         case SassMixinDefinitionNode::isa($line):
             return $this->parseMixinDefinition($line);
             break;
         case SassMixinNode::isa($line):
             return $this->parseMixin($line);
             break;
         case SassVariableNode::isa($line):
             if ($this->hasChild($line, $Lines)) {
                 throw new SassException("Illegal nesting. Nesting not allowed beneath variables.\nLine {$line['number']}: " . (is_array($line['file']) ? join(DIRECTORY_SEPARATOR, $line['file']) : ''));
             }
             return $this->parseVariable($line);
             break;
         case SassPropertyNode::isa($line, $this->options['property_syntax']):
             return $this->parseProperty($line);
             break;
         default:
             return $this->parseRule($line, $lines);
             break;
     }
     // switch
 }