diff --git a/lib/PhpParser/Node.php b/lib/PhpParser/Node.php index 843e2ea66c..fd2a9b7247 100644 --- a/lib/PhpParser/Node.php +++ b/lib/PhpParser/Node.php @@ -6,6 +6,7 @@ interface Node { /** * Gets the type of the node. * + * @psalm-return non-empty-string * @return string Type of the node */ public function getType(): string; diff --git a/lib/PhpParser/Node/Name.php b/lib/PhpParser/Node/Name.php index 26b863e40b..ef883ea0f1 100644 --- a/lib/PhpParser/Node/Name.php +++ b/lib/PhpParser/Node/Name.php @@ -5,7 +5,10 @@ use PhpParser\NodeAbstract; class Name extends NodeAbstract { - /** @var string Name as string */ + /** + * @psalm-var non-empty-string + * @var non-empty-string Name as string + */ public string $name; /** @var array */ @@ -33,6 +36,7 @@ public function getSubNodeNames(): array { /** * Get parts of name (split by the namespace separator). * + * @psalm-return non-empty-array * @return string[] Parts of name */ public function getParts(): array { @@ -103,6 +107,7 @@ public function isRelative(): bool { * Returns a string representation of the name itself, without taking the name type into * account (e.g., not including a leading backslash for fully qualified names). * + * @psalm-return non-empty-string * @return string String representation */ public function toString(): string { @@ -113,6 +118,7 @@ public function toString(): string { * Returns a string representation of the name as it would occur in code (e.g., including * leading backslash for fully qualified names. * + * @psalm-return non-empty-string * @return string String representation */ public function toCodeString(): string { @@ -123,6 +129,7 @@ public function toCodeString(): string { * Returns lowercased string representation of the name, without taking the name type into * account (e.g., no leading backslash for fully qualified names). * + * @psalm-return non-empty-string * @return string Lowercased string representation */ public function toLowerString(): string { @@ -142,6 +149,7 @@ public function isSpecialClassName(): bool { * Returns a string representation of the name by imploding the namespace parts with the * namespace separator. * + * @psalm-return non-empty-string * @return string String representation */ public function __toString(): string { @@ -237,7 +245,7 @@ public static function concat($name1, $name2, array $attributes = []) { * * @param string|string[]|self $name Name to prepare * - * @return string Prepared name + * @return non-empty-string Prepared name */ private static function prepareName($name): string { if (\is_string($name)) {