2011-04-18 19:02:30 +02:00
|
|
|
<?php
|
|
|
|
|
2011-06-25 17:51:17 +02:00
|
|
|
abstract class PHPParser_NodeAbstract extends ArrayObject
|
2011-04-18 19:02:30 +02:00
|
|
|
{
|
2011-06-12 17:12:47 +02:00
|
|
|
protected $line;
|
2011-07-03 16:35:45 +02:00
|
|
|
protected $docComment;
|
2011-04-18 19:02:30 +02:00
|
|
|
|
2011-05-31 16:33:11 +02:00
|
|
|
/**
|
|
|
|
* Creates a Node.
|
|
|
|
*
|
2011-07-03 16:35:45 +02:00
|
|
|
* @param array $subNodes Array of sub nodes
|
|
|
|
* @param int $line Line
|
|
|
|
* @param null|string $docComment Nearest doc comment
|
2011-05-31 16:33:11 +02:00
|
|
|
*/
|
2011-07-03 16:35:45 +02:00
|
|
|
public function __construct(array $subNodes, $line = -1, $docComment = null) {
|
2011-06-25 17:51:17 +02:00
|
|
|
parent::__construct($subNodes, ArrayObject::ARRAY_AS_PROPS);
|
2011-06-02 16:29:28 +02:00
|
|
|
|
2011-07-03 16:35:45 +02:00
|
|
|
$this->line = $line;
|
|
|
|
$this->docComment = $docComment;
|
2011-05-30 22:11:11 +02:00
|
|
|
}
|
|
|
|
|
2011-05-31 16:33:11 +02:00
|
|
|
/**
|
|
|
|
* Gets the type of this node.
|
|
|
|
*
|
|
|
|
* The type of a node is the node's class name without the
|
2011-06-05 18:40:04 +02:00
|
|
|
* PHPParser_Node_ prefix.
|
2011-05-31 16:33:11 +02:00
|
|
|
*
|
|
|
|
* @return string Type of this node
|
|
|
|
*/
|
2011-05-27 18:20:44 +02:00
|
|
|
public function getType() {
|
2011-06-05 18:40:04 +02:00
|
|
|
return substr(get_class($this), 15);
|
2011-05-27 18:20:44 +02:00
|
|
|
}
|
|
|
|
|
2011-06-12 17:12:47 +02:00
|
|
|
/**
|
2011-06-28 14:11:12 +02:00
|
|
|
* Gets line the node started in.
|
2011-06-12 17:12:47 +02:00
|
|
|
*
|
|
|
|
* @return int Line
|
|
|
|
*/
|
|
|
|
public function getLine() {
|
|
|
|
return $this->line;
|
|
|
|
}
|
2011-07-03 16:35:45 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the nearest doc comment.
|
|
|
|
*
|
|
|
|
* @return null|string Nearest doc comment or null
|
|
|
|
*/
|
|
|
|
public function getDocComment() {
|
|
|
|
return $this->docComment;
|
|
|
|
}
|
2011-04-18 19:02:30 +02:00
|
|
|
}
|