当前位置: 首页>>代码示例>>PHP>>正文


PHP Node::getType方法代码示例

本文整理汇总了PHP中Node::getType方法的典型用法代码示例。如果您正苦于以下问题:PHP Node::getType方法的具体用法?PHP Node::getType怎么用?PHP Node::getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Node的用法示例。


在下文中一共展示了Node::getType方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: render

 public function render(Node $node)
 {
     echo str_repeat('--', $node->getDepth()) . $node->getType() . "\n";
     foreach ($node->getChildren() as $child) {
         $this->render($child);
     }
 }
开发者ID:heybigname,项目名称:html-to-markdown,代码行数:7,代码来源:TextRenderer.php

示例2: dump

 /**
  * Dumps a node or array.
  *
  * @param array|Node $node Node or array to dump
  *
  * @return string Dumped value
  */
 public function dump($node)
 {
     if ($node instanceof Node) {
         $r = $node->getType() . '(';
     } elseif (is_array($node)) {
         $r = 'array(';
     } else {
         throw new \InvalidArgumentException('Can only dump nodes and arrays.');
     }
     foreach ($node as $key => $value) {
         $r .= "\n" . '    ' . $key . ': ';
         if (null === $value) {
             $r .= 'null';
         } elseif (false === $value) {
             $r .= 'false';
         } elseif (true === $value) {
             $r .= 'true';
         } elseif (is_scalar($value)) {
             $r .= $value;
         } else {
             $r .= str_replace("\n", "\n" . '    ', $this->dump($value));
         }
     }
     return $r . "\n" . ')';
 }
开发者ID:Ingothq,项目名称:multiarmedbandit,代码行数:32,代码来源:NodeDumper.php

示例3: findParent

 function findParent(Node $node, $type = null)
 {
     if ($node->getType() == $type) {
         return $node;
     } else {
         findParent($node->getParent(), $type);
     }
 }
开发者ID:recognant,项目名称:guidesite,代码行数:8,代码来源:index.php

示例4: testConstruct

 /**
  * @dataProvider provideNodes
  */
 public function testConstruct(array $attributes, Node $node)
 {
     $this->assertSame('Dummy', $node->getType());
     $this->assertSame(array('subNode1', 'subNode2'), $node->getSubNodeNames());
     $this->assertSame(10, $node->getLine());
     $this->assertSame('/** doc comment */', $node->getDocComment()->getText());
     $this->assertSame('value1', $node->subNode1);
     $this->assertSame('value2', $node->subNode2);
     $this->assertTrue(isset($node->subNode1));
     $this->assertTrue(isset($node->subNode2));
     $this->assertFalse(isset($node->subNode3));
     $this->assertSame($attributes, $node->getAttributes());
     return $node;
 }
开发者ID:EnmanuelCode,项目名称:backend-laravel,代码行数:17,代码来源:NodeAbstractTest.php

示例5: dump

 /**
  * Dumps a node or array.
  *
  * @param array|Node $node Node or array to dump
  *
  * @return string Dumped value
  */
 public function dump($node)
 {
     if ($node instanceof Node) {
         $r = $node->getType() . '(';
         foreach ($node->getSubNodeNames() as $key) {
             $r .= "\n    " . $key . ': ';
             $value = $node->{$key};
             if (null === $value) {
                 $r .= 'null';
             } elseif (false === $value) {
                 $r .= 'false';
             } elseif (true === $value) {
                 $r .= 'true';
             } elseif (is_scalar($value)) {
                 $r .= $value;
             } else {
                 $r .= str_replace("\n", "\n    ", $this->dump($value));
             }
         }
         if ($this->dumpComments && ($comments = $node->getAttribute('comments'))) {
             $r .= "\n    comments: " . str_replace("\n", "\n    ", $this->dump($comments));
         }
     } elseif (is_array($node)) {
         $r = 'array(';
         foreach ($node as $key => $value) {
             $r .= "\n    " . $key . ': ';
             if (null === $value) {
                 $r .= 'null';
             } elseif (false === $value) {
                 $r .= 'false';
             } elseif (true === $value) {
                 $r .= 'true';
             } elseif (is_scalar($value)) {
                 $r .= $value;
             } else {
                 $r .= str_replace("\n", "\n    ", $this->dump($value));
             }
         }
     } elseif ($node instanceof Comment) {
         return $node->getReformattedText();
     } else {
         throw new \InvalidArgumentException('Can only dump nodes and arrays.');
     }
     return $r . "\n)";
 }
开发者ID:drickferreira,项目名称:rastreador,代码行数:52,代码来源:NodeDumper.php

示例6: dump

 /**
  * Dumps a node or array.
  *
  * @param array|Node $node Node or array to dump
  *
  * @return string Dumped value
  */
 public function dump($node)
 {
     if ($node instanceof Node) {
         $r = "\n{\n \"title\"" . ":" . " \"" . $node->getType() . "\"," . "\n" . " \"value\": {\n";
         foreach ($node->getSubNodeNames() as $key) {
             $value = $node->{$key};
             if (null === $value) {
                 $r .= "    \"" . $key . "\"" . ":" . "null,";
             } elseif (false === $value) {
                 $r .= "    \"" . $key . "\"" . ":" . "false," . "";
             } elseif (true === $value) {
                 $r .= 'true';
             } elseif (is_scalar($value)) {
                 $r .= "    \"{$key}\"" . ":" . "\"{$value}\"" . ",";
             } else {
                 $r .= " \n\"{$key}\": " . str_replace("\n", "\n   ", $this->dump($value)) . ",";
             }
         }
         $r = rtrim($r, ",");
         $r .= "\n  }\n}";
     } elseif (is_array($node)) {
         $r = " [";
         foreach ($node as $key => $value) {
             if (null === $value) {
                 $r .= 'null';
             } elseif (false === $value) {
                 $r .= 'false';
             } elseif (true === $value) {
                 $r .= 'true';
             } elseif (is_scalar($value)) {
                 $r .= "\n\"" . $value . "\"\n";
             } else {
                 $r .= str_replace("\n", "\n   ", $this->dump($value)) . ",";
             }
         }
         $r = rtrim($r, ",");
         $r .= "\n ]";
     } else {
         throw new \InvalidArgumentException('Can only dump nodes and arrays.');
     }
     return $r . "\n";
 }
开发者ID:ronakbd30,项目名称:White-Box-Vulnerability-Detection-Tool1,代码行数:49,代码来源:NodeDumper.php

示例7: addNode

 /**
  * Create a new node and its children
  * 
  * @param object Hierarchy $newHierarchy
  * @param object Node $oldNode
  * @param optional object Id $parentId 
  * @return void
  * @access protected
  * @since 4/17/08
  */
 protected function addNode(Hierarchy $newHierarchy, Node $oldNode, Id $parentId = null)
 {
     // If it has already been created, get it and try to set its parent
     try {
         $newNode = $newHierarchy->getNode($oldNode->getId());
         if (!is_null($parentId)) {
             try {
                 $newNode->addParent($parentId);
             } catch (Exception $e) {
                 // Do nothing if the child already exists
                 if ($e->getMessage() != "A child with the given id already exists!") {
                     throw $e;
                 }
             }
         }
     } catch (UnknownIdException $e) {
         if (is_null($parentId)) {
             $newNode = $newHierarchy->createRootNode($oldNode->getId(), $oldNode->getType(), $oldNode->getDisplayName(), $oldNode->getDescription());
         } else {
             $newNode = $newHierarchy->createNode($oldNode->getId(), $parentId, $oldNode->getType(), $oldNode->getDisplayName(), $oldNode->getDescription());
         }
         $this->nodeStatus->updateStatistics();
     }
     $oldChildren = $oldNode->getChildren();
     while ($oldChildren->hasNext()) {
         $oldChild = $oldChildren->next();
         $this->addNode($newHierarchy, $oldChild, $newNode->getId());
     }
 }
开发者ID:adamfranco,项目名称:harmoni,代码行数:39,代码来源:migration.php

示例8: writeTag

 /**
  * Write the given tag to the stream.
  *
  * @param resource $fPtr Stream pointer
  * @param Node     $node Tag to write
  *
  * @return bool
  */
 private function writeTag($fPtr, Node $node)
 {
     return $this->dataHandler->putTAGByte($fPtr, $node->getType()) && $this->dataHandler->putTAGString($fPtr, $node->getName()) && $this->writeType($fPtr, $node->getType(), $node);
 }
开发者ID:rickselby,项目名称:nbt,代码行数:12,代码来源:Service.php

示例9: Log

    public static function Log(Node $user, $action, Node $node1, $summary)
    {
        $type1      = $node1->getType();
        $pk1        = $node1->pk;
        $context1   = $node1->context;

        // Escape the summary
        self::_EscapeString($summary);

        $date = date('Y-m-d G:i:s');

        $sql = "INSERT INTO node_history (user_pk, user_context, pk1, type1, context1, action, date, summary)
                VALUES ($user->pk, $user->context, $pk1, '$type1', $context1, '$action', '$date', '$summary')
                ";

        $dbc    = new DatabaseConnection();
        $rows   = $dbc->query($sql);

        return true;
    }
开发者ID:Goodgulf,项目名称:nodemesh,代码行数:20,代码来源:class.History.php


注:本文中的Node::getType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。