Skip to content

Commit

Permalink
improved phpDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Aug 29, 2023
1 parent 290bbb7 commit 163c5e9
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/PhpGenerator/Extractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,10 @@ private function addEnumCaseToClass(EnumType $class, Node\Stmt\EnumCase $node):
}


private function addCommentAndAttributes($element, Node $node): void
private function addCommentAndAttributes(
PhpFile|ClassLike|Constant|Property|GlobalFunction|Method|Parameter|EnumCase|TraitUse $element,
Node $node,
): void
{
if ($node->getDocComment()) {
$comment = $node->getDocComment()->getReformattedText();
Expand Down
1 change: 1 addition & 0 deletions src/PhpGenerator/Parameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public function setType(?string $type): static
}


/** @return ($asObject is true ? ?Type : ?string) */
public function getType(bool $asObject = false): Type|string|null
{
return $asObject && $this->type
Expand Down
2 changes: 1 addition & 1 deletion src/PhpGenerator/PhpFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function getNamespaces(): array
}


/** @return ClassLike[] */
/** @return (ClassType|InterfaceType|TraitType|EnumType)[] */
public function getClasses(): array
{
$classes = [];
Expand Down
6 changes: 3 additions & 3 deletions src/PhpGenerator/PhpNamespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ final class PhpNamespace
self::NameConstant => [],
];

/** @var ClassLike[] */
/** @var (ClassType|InterfaceType|TraitType|EnumType)[] */
private array $classes = [];

/** @var GlobalFunction[] */
Expand Down Expand Up @@ -253,7 +253,7 @@ public function simplifyName(string $name, string $of = self::NameNormal): strin
}


public function add(ClassLike $class): static
public function add(ClassType|InterfaceType|TraitType|EnumType $class): static
{
$name = $class->getName();
if ($name === null) {
Expand Down Expand Up @@ -327,7 +327,7 @@ public function removeFunction(string $name): static
}


/** @return ClassLike[] */
/** @return (ClassType|InterfaceType|TraitType|EnumType)[] */
public function getClasses(): array
{
$res = [];
Expand Down
1 change: 1 addition & 0 deletions src/PhpGenerator/Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public function setType(?string $type): static
}


/** @return ($asObject is true ? ?Type : ?string) */
public function getType(bool $asObject = false): Type|string|null
{
return $asObject && $this->type
Expand Down
1 change: 1 addition & 0 deletions src/PhpGenerator/Traits/FunctionLike.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ public function setReturnType(?string $type): static
}


/** @return ($asObject is true ? ?Type : ?string) */
public function getReturnType(bool $asObject = false): Type|string|null
{
return $asObject && $this->returnType
Expand Down

0 comments on commit 163c5e9

Please sign in to comment.