forked from microsoft/tolerant-php-parser
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathResolvedName.php
More file actions
44 lines (37 loc) · 1.31 KB
/
ResolvedName.php
File metadata and controls
44 lines (37 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
namespace Microsoft\PhpParser;
class ResolvedName {
private $parts = [];
/**
* @param Token[] $tokens
*/
public static function buildName(array $tokens, $content) : ResolvedName {
$name = new ResolvedName();
foreach ($tokens as $token) {
if ($token->kind === TokenKind::Name) {
$name->parts[] = $token->getText($content);
}
}
return $name;
}
public function addNameParts(array $parts, $content) {
foreach ($parts as $part) {
if ($part->kind === TokenKind::Name && !($part instanceof MissingToken)) {
$this->parts[] = $part->getText($content);
}
}
}
public function getNameParts() {
return $this->parts;
}
public function getFullyQualifiedNameText() : string {
return join("\\", $this->parts);
}
public function __toString() {
return $this->getFullyQualifiedNameText();
}
}