-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
516b84f
commit a10a69c
Showing
6 changed files
with
74 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace TypeLang\PHPDoc\Tag; | ||
|
||
final class InvalidTag extends Tag | ||
{ | ||
/** | ||
* @var non-empty-string | ||
*/ | ||
public const DEFAULT_UNKNOWN_TAG_NAME = '<unknown>'; | ||
|
||
/** | ||
* @param non-empty-string $name | ||
*/ | ||
public function __construct( | ||
protected readonly \Throwable $reason, | ||
\Stringable|string|null $description = null, | ||
string $name = self::DEFAULT_UNKNOWN_TAG_NAME, | ||
) { | ||
parent::__construct($name, $description); | ||
} | ||
|
||
public function getReason(): \Throwable | ||
{ | ||
return $this->reason; | ||
} | ||
|
||
public function __toString(): string | ||
{ | ||
$name = $this->name === self::DEFAULT_UNKNOWN_TAG_NAME ? '' : $this->name; | ||
|
||
if ($this->description === null) { | ||
return \sprintf('@%s', $name); | ||
} | ||
|
||
return \rtrim(\vsprintf('@%s %s', [ | ||
$name, | ||
(string) $this->description, | ||
])); | ||
} | ||
} |