function Name::concat
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.
Parameters
string|string[]|self|null $name1 The first name:
string|string[]|self|null $name2 The second name:
array<string, mixed> $attributes Attributes to assign to concatenated name:
Return value
static|null Concatenated name
2 calls to Name::concat()
- NameResolver::addAlias in vendor/
nikic/ php-parser/ lib/ PhpParser/ NodeVisitor/ NameResolver.php - NameResolver::addNamespacedName in vendor/
nikic/ php-parser/ lib/ PhpParser/ NodeVisitor/ NameResolver.php
File
-
vendor/
nikic/ php-parser/ lib/ PhpParser/ Node/ Name.php, line 226
Class
Namespace
PhpParser\NodeCode
public static function concat($name1, $name2, array $attributes = []) {
if (null === $name1 && null === $name2) {
return null;
}
if (null === $name1) {
return new static($name2, $attributes);
}
if (null === $name2) {
return new static($name1, $attributes);
}
else {
return new static(self::prepareName($name1) . '\\' . self::prepareName($name2), $attributes);
}
}