SassPropertyNode::isa PHP Method

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
    public static function isa($token)
    {
        if (!is_array($token)) {
            $syntax = 'old';
        } else {
            $syntax = $token['syntax'];
            $token = $token['token'];
        }
        $matches = self::match($token, $syntax);
        if (!empty($matches)) {
            if (isset($matches[self::VALUE]) && self::isPseudoSelector($matches[self::VALUE])) {
                return false;
            }
            if ($token->level === 0) {
                # RL - if it's on the first level it's probably a false positive, not an error.
                # even if it is a genuine error, no need to kill the compiler about it.
                return false;
                // throw new SassPropertyNodeException('Properties can not be assigned at root level', $token);
            } else {
                return true;
            }
        } else {
            return false;
        }
    }

Usage Example

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
 }
All Usage Examples Of SassPropertyNode::isa