Skip to content

Commit

Permalink
Declare more precise phpdoc types
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Apr 12, 2024
1 parent 4d36e9c commit dce0f17
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/PhpParser/Node.php
Expand Up @@ -8,6 +8,7 @@ interface Node
* Gets the type of the node.
*
* @return string Type of the node
* @psalm-return non-empty-string
*/
public function getType() : string;

Expand Down
7 changes: 7 additions & 0 deletions lib/PhpParser/Node/Name.php
Expand Up @@ -8,6 +8,7 @@ class Name extends NodeAbstract
{
/**
* @var string[] Parts of the name
* @psalm-var non-empty-array<string>
* @deprecated Use getParts() instead
*/
public $parts;
Expand Down Expand Up @@ -37,6 +38,7 @@ public function getSubNodeNames() : array {
* Get parts of name (split by the namespace separator).
*
* @return string[] Parts of name
* @psalm-return non-empty-array<string>
*/
public function getParts(): array {
return $this->parts;
Expand Down Expand Up @@ -101,6 +103,7 @@ public function isRelative() : bool {
* account (e.g., not including a leading backslash for fully qualified names).
*
* @return string String representation
* @psalm-return non-empty-string
*/
public function toString() : string {
return implode('\\', $this->parts);
Expand All @@ -111,6 +114,7 @@ public function toString() : string {
* leading backslash for fully qualified names.
*
* @return string String representation
* @psalm-return non-empty-string
*/
public function toCodeString() : string {
return $this->toString();
Expand All @@ -121,6 +125,7 @@ public function toCodeString() : string {
* account (e.g., no leading backslash for fully qualified names).
*
* @return string Lowercased string representation
* @psalm-return non-empty-string
*/
public function toLowerString() : string {
return strtolower(implode('\\', $this->parts));
Expand All @@ -141,6 +146,7 @@ public function isSpecialClassName() : bool {
* namespace separator.
*
* @return string String representation
* @psalm-return non-empty-string
*/
public function __toString() : string {
return implode('\\', $this->parts);
Expand Down Expand Up @@ -225,6 +231,7 @@ public static function concat($name1, $name2, array $attributes = []) {
* @param string|string[]|self $name Name to prepare
*
* @return string[] Prepared name
* @psalm-return non-empty-array<string>
*/
private static function prepareName($name) : array {
if (\is_string($name)) {
Expand Down

0 comments on commit dce0f17

Please sign in to comment.