diff --git a/lib/PhpParser/Builder/Use_.php b/lib/PhpParser/Builder/Use_.php index dfccd24d01..60f8297621 100644 --- a/lib/PhpParser/Builder/Use_.php +++ b/lib/PhpParser/Builder/Use_.php @@ -10,7 +10,7 @@ class Use_ implements Builder { /** @var Node\Name */ protected Node\Name $name; - /** @var int */ + /** @var Stmt\Use_::TYPE_* */ protected int $type; /** @var string|null */ protected ?string $alias = null; @@ -18,8 +18,8 @@ class Use_ implements Builder { /** * Creates a name use (alias) builder. * - * @param Node\Name|string $name Name of the entity (namespace, class, function, constant) to alias - * @param int $type One of the Stmt\Use_::TYPE_* constants + * @param Node\Name|string $name Name of the entity (namespace, class, function, constant) to alias + * @param Stmt\Use_::TYPE_* $type One of the Stmt\Use_::TYPE_* constants */ public function __construct($name, int $type) { $this->name = BuilderHelpers::normalizeName($name); diff --git a/lib/PhpParser/NameContext.php b/lib/PhpParser/NameContext.php index 395d5d6862..2377ef9ee4 100644 --- a/lib/PhpParser/NameContext.php +++ b/lib/PhpParser/NameContext.php @@ -47,9 +47,9 @@ public function startNamespace(?Name $namespace = null): void { /** * Add an alias / import. * - * @param Name $name Original name - * @param string $aliasName Aliased name - * @param int $type One of Stmt\Use_::TYPE_* + * @param Name $name Original name + * @param string $aliasName Aliased name + * @param Stmt\Use_::TYPE_* $type One of Stmt\Use_::TYPE_* * @param array $errorAttrs Attributes to use to report an error */ public function addAlias(Name $name, string $aliasName, int $type, array $errorAttrs = []): void { @@ -93,8 +93,8 @@ public function getNamespace(): ?Name { /** * Get resolved name. * - * @param Name $name Name to resolve - * @param int $type One of Stmt\Use_::TYPE_{FUNCTION|CONSTANT} + * @param Name $name Name to resolve + * @param Stmt\Use_::TYPE_* $type One of Stmt\Use_::TYPE_{FUNCTION|CONSTANT} * * @return null|Name Resolved name, or null if static resolution is not possible */ @@ -148,8 +148,8 @@ public function getResolvedClassName(Name $name): Name { /** * Get possible ways of writing a fully qualified name (e.g., by making use of aliases). * - * @param string $name Fully-qualified name (without leading namespace separator) - * @param int $type One of Stmt\Use_::TYPE_* + * @param string $name Fully-qualified name (without leading namespace separator) + * @param Stmt\Use_::TYPE_* $type One of Stmt\Use_::TYPE_* * * @return Name[] Possible representations of the name */ @@ -204,8 +204,8 @@ public function getPossibleNames(string $name, int $type): array { /** * Get shortest representation of this fully-qualified name. * - * @param string $name Fully-qualified name (without leading namespace separator) - * @param int $type One of Stmt\Use_::TYPE_* + * @param string $name Fully-qualified name (without leading namespace separator) + * @param Stmt\Use_::TYPE_* $type One of Stmt\Use_::TYPE_* * * @return Name Shortest representation */ diff --git a/lib/PhpParser/Node/Stmt/GroupUse.php b/lib/PhpParser/Node/Stmt/GroupUse.php index 29af580f85..8be8102a60 100644 --- a/lib/PhpParser/Node/Stmt/GroupUse.php +++ b/lib/PhpParser/Node/Stmt/GroupUse.php @@ -7,7 +7,9 @@ use PhpParser\Node\UseItem; class GroupUse extends Stmt { - /** @var int Type of group use */ + /** + * @var Use_::TYPE_* Type of group use + */ public int $type; /** @var Name Prefix for uses */ public Name $prefix; @@ -17,9 +19,9 @@ class GroupUse extends Stmt { /** * Constructs a group use node. * - * @param Name $prefix Prefix for uses - * @param UseItem[] $uses Uses - * @param int $type Type of group use + * @param Name $prefix Prefix for uses + * @param UseItem[] $uses Uses + * @param Use_::TYPE_* $type Type of group use * @param array $attributes Additional attributes */ public function __construct(Name $prefix, array $uses, int $type = Use_::TYPE_NORMAL, array $attributes = []) { diff --git a/lib/PhpParser/Node/Stmt/Use_.php b/lib/PhpParser/Node/Stmt/Use_.php index 4ef856808a..399a7ef27d 100644 --- a/lib/PhpParser/Node/Stmt/Use_.php +++ b/lib/PhpParser/Node/Stmt/Use_.php @@ -19,7 +19,7 @@ class Use_ extends Stmt { /** Constant import */ public const TYPE_CONSTANT = 3; - /** @var int Type of alias */ + /** @var self::TYPE_* Type of alias */ public int $type; /** @var UseItem[] Aliases */ public array $uses; @@ -27,8 +27,8 @@ class Use_ extends Stmt { /** * Constructs an alias (use) list node. * - * @param UseItem[] $uses Aliases - * @param int $type Type of alias + * @param UseItem[] $uses Aliases + * @param Stmt\Use_::TYPE_* $type Type of alias * @param array $attributes Additional attributes */ public function __construct(array $uses, int $type = self::TYPE_NORMAL, array $attributes = []) { diff --git a/lib/PhpParser/Node/UseItem.php b/lib/PhpParser/Node/UseItem.php index fd102cb689..c2b371b2e6 100644 --- a/lib/PhpParser/Node/UseItem.php +++ b/lib/PhpParser/Node/UseItem.php @@ -6,7 +6,9 @@ use PhpParser\Node\Stmt\Use_; class UseItem extends Node\Stmt { - /** @var int One of the Stmt\Use_::TYPE_* constants. Will only differ from TYPE_UNKNOWN for mixed group uses */ + /** + * @var Use_::TYPE_* One of the Stmt\Use_::TYPE_* constants. Will only differ from TYPE_UNKNOWN for mixed group uses + */ public int $type; /** @var Node\Name Namespace, class, function or constant to alias */ public Name $name; @@ -18,8 +20,8 @@ class UseItem extends Node\Stmt { * * @param Node\Name $name Namespace/Class to alias * @param null|string|Identifier $alias Alias - * @param int $type Type of the use element (for mixed group use only) - * @param array $attributes Additional attributes + * @param Use_::TYPE_* $type Type of the use element (for mixed group use only) + * @param array $attributes Additional attributes */ public function __construct(Node\Name $name, $alias = null, int $type = Use_::TYPE_UNKNOWN, array $attributes = []) { $this->attributes = $attributes; diff --git a/lib/PhpParser/NodeVisitor/NameResolver.php b/lib/PhpParser/NodeVisitor/NameResolver.php index 160d0cbb4c..3149a6e1fd 100644 --- a/lib/PhpParser/NodeVisitor/NameResolver.php +++ b/lib/PhpParser/NodeVisitor/NameResolver.php @@ -160,6 +160,7 @@ public function enterNode(Node $node) { return null; } + /** @param Stmt\Use_::TYPE_* $type */ private function addAlias(Node\UseItem $use, int $type, ?Name $prefix = null): void { // Add prefix for group uses $name = $prefix ? Name::concat($prefix, $use->name) : $use->name; @@ -205,8 +206,8 @@ private function resolveType(?Node $node): ?Node { /** * Resolve name, according to name resolver options. * - * @param Name $name Function or constant name to resolve - * @param int $type One of Stmt\Use_::TYPE_* + * @param Name $name Function or constant name to resolve + * @param Stmt\Use_::TYPE_* $type One of Stmt\Use_::TYPE_* * * @return Name Resolved name, or original name with attribute */