/**
  * @param AbstractNode $node
  *
  * @return bool
  */
 private function isChildOfTry(AbstractNode $node)
 {
     $parent = $node->getParent();
     while (is_object($parent)) {
         if ($parent->isInstanceOf('TryStatement')) {
             return true;
         }
         $parent = $parent->getParent();
     }
     return false;
 }
 /**
  * Checks whether or not a node is a children of a specific type.
  *
  * @param AbstractNode $node
  * @param string $type
  * @return boolean
  */
 private function isChildOf(AbstractNode $node, $type)
 {
     $parent = $node->getParent();
     if ($parent->isInstanceOf($type)) {
         return true;
     }
     return false;
 }
示例#3
0
 /**
  * Checks if the given node is a direct or indirect child of a node with
  * the given type.
  *
  * @param \PHPMD\AbstractNode $node
  * @param string $type
  * @return boolean
  */
 private function isChildOf(AbstractNode $node, $type)
 {
     $parent = $node->getParent();
     return $parent->isInstanceOf($type);
 }