PHP Class PhpParser\Node\Name

Inheritance: extends PhpParser\NodeAbstract
Afficher le fichier Open project: nikic/php-parser Class Usage Examples

Méthodes publiques

Свойство Type Description
$parts Parts of the name

Méthodes publiques

Méthode Description
__construct ( string | array | self $name, array $attributes = [] ) Constructs a name node.
__toString ( ) : string Returns a string representation of the name by imploding the namespace parts with the namespace separator.
concat ( string | array | self | null $name1, string | array | self | null $name2, array $attributes = [] ) : static | null Concatenate two names, yielding a new Name instance.
getFirst ( ) : string Gets the first part of the name, i.e. everything before the first namespace separator.
getLast ( ) : string Gets the last part of the name, i.e. everything after the last namespace separator.
getSubNodeNames ( )
isFullyQualified ( ) : boolean Checks whether the name is fully qualified. (E.g. \Name)
isQualified ( ) : boolean Checks whether the name is qualified. (E.g. Name\Name)
isRelative ( ) : boolean Checks whether the name is explicitly relative to the current namespace. (E.g. namespace\Name)
isUnqualified ( ) : boolean Checks whether the name is unqualified. (E.g. Name)
slice ( integer $offset, integer | null $length = null ) : static | null Gets a slice of a name (similar to array_slice).
toString ( ) : string Returns a string representation of the name by imploding the namespace parts with the namespace separator.

Private Methods

Méthode Description
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.

Method Details

__construct() public méthode

Constructs a name node.
public __construct ( string | array | self $name, array $attributes = [] )
$name string | array | self Name as string, part array or Name instance (copy ctor)
$attributes array Additional attributes

__toString() public méthode

Returns a string representation of the name by imploding the namespace parts with the namespace separator.
public __toString ( ) : string
Résultat string String representation

concat() public static méthode

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.
public static concat ( string | array | self | null $name1, string | array | self | null $name2, array $attributes = [] ) : static | null
$name1 string | array | self | null The first name
$name2 string | array | self | null The second name
$attributes array Attributes to assign to concatenated name
Résultat static | null Concatenated name

getFirst() public méthode

Gets the first part of the name, i.e. everything before the first namespace separator.
public getFirst ( ) : string
Résultat string First part of the name

getLast() public méthode

Gets the last part of the name, i.e. everything after the last namespace separator.
public getLast ( ) : string
Résultat string Last part of the name

getSubNodeNames() public méthode

public getSubNodeNames ( )

isFullyQualified() public méthode

Checks whether the name is fully qualified. (E.g. \Name)
public isFullyQualified ( ) : boolean
Résultat boolean Whether the name is fully qualified

isQualified() public méthode

Checks whether the name is qualified. (E.g. Name\Name)
public isQualified ( ) : boolean
Résultat boolean Whether the name is qualified

isRelative() public méthode

Checks whether the name is explicitly relative to the current namespace. (E.g. namespace\Name)
public isRelative ( ) : boolean
Résultat boolean Whether the name is relative

isUnqualified() public méthode

Checks whether the name is unqualified. (E.g. Name)
public isUnqualified ( ) : boolean
Résultat boolean Whether the name is unqualified

slice() public méthode

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().
public slice ( integer $offset, integer | null $length = null ) : static | null
$offset integer Offset to start the slice at (may be negative)
$length integer | null Length of the slice (may be negative)
Résultat static | null Sliced name

toString() public méthode

Returns a string representation of the name by imploding the namespace parts with the namespace separator.
public toString ( ) : string
Résultat string String representation

Property Details

$parts public_oe property

Parts of the name
Deprecation: Avoid directly accessing $parts, use methods instead.
public $parts