$parts
$parts : array<mixed,string>
slice(integer $offset, integer|null $length = null) : static|null
Gets a slice of a name (similar to array_slice).
This method returns a new instance of the same type as the original and with the same attributes.
If the slice is empty, null is returned. The null value will be correctly handled in concatenations using concat().
Offset and length have the same meaning as in array_slice().
integer | $offset | Offset to start the slice at (may be negative) |
integer|null | $length | Length of the slice (may be negative) |
Sliced name
concat(string|array|self|null $name1, string|array|self|null $name2, array $attributes = array()) : static|null
Concatenate two names, yielding a new Name instance.
The type of the generated instance depends on which class this method is called on, for example Name\FullyQualified::concat() will yield a Name\FullyQualified instance.
If one of the arguments is null, a new instance of the other name will be returned. If both arguments are null, null will be returned. As such, writing Name::concat($namespace, $shortName) where $namespace is a Name node or null will work as expected.
string|array|self|null | $name1 | The first name |
string|array|self|null | $name2 | The second name |
array | $attributes | Attributes to assign to concatenated name |
Concatenated name
getDocComment() : null|\PhpParser\Comment\Doc
Gets the doc comment of the node.
The doc comment has to be the last comment associated with the node.
Doc comment object or null
None found |
setDocComment(\PhpParser\Comment\Doc $docComment)
Sets the doc comment of the node.
This will either replace an existing doc comment or add it to the comments array.
\PhpParser\Comment\Doc | $docComment | Doc comment to set |
None found |
setAttribute(string $key, mixed $value)
Sets an attribute on a node.
string | $key | |
mixed | $value |
None found |
hasAttribute(string $key) : boolean
Returns whether an attribute exists.
string | $key |
None found |
getAttribute(string $key, mixed $default = null) : mixed
Returns the value of an attribute.
string | $key | |
mixed | $default |
None found |
None found |
None found |
prepareName(string|array|self $name) : array
Prepares a (string, array or Name node) name for use in name changing methods by converting it to an array.
string|array|self | $name | Name to prepare |
Prepared name
None found |