mirror of
https://github.com/danog/PHP-Parser.git
synced 2024-11-27 04:14:44 +01:00
Add getLast and toString (and __toString) methods to Node_Name
This commit is contained in:
parent
dd2404b57a
commit
217280c9ba
@ -13,4 +13,34 @@ class PHPParser_Node_Name extends PHPParser_NodeAbstract
|
||||
public function resolveType($type) {
|
||||
$this->resolveType = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the last part of the name, i.e. everything after the last namespace separator.
|
||||
*
|
||||
* @return string Last part of the name
|
||||
*/
|
||||
public function getLast() {
|
||||
return $this->parts[count($this->parts) - 1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the name by imploding the namespace parts with a separator.
|
||||
*
|
||||
* @param string $separator The separator to use (defaults to the namespace separator \)
|
||||
*
|
||||
* @return string String representation
|
||||
*/
|
||||
public function toString($separator = '\\') {
|
||||
return implode($separator, $this->parts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the name by imploding the namespace parts with the
|
||||
* namespace separator \ (backslash).
|
||||
*
|
||||
* @return string String representation
|
||||
*/
|
||||
public function __toString() {
|
||||
return $this->toString('\\');
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user