Skip to content

Commit 933340c

Browse files
committed
Add InvalidTagException::fromCreatingTag method
1 parent 64ba1fb commit 933340c

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

Diff for: src/Exception/InvalidTagException.php

+23-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,26 @@
44

55
namespace TypeLang\PHPDoc\Exception;
66

7-
class InvalidTagException extends ParsingException {}
7+
class InvalidTagException extends ParsingException
8+
{
9+
final public const ERROR_CODE_PARSING = 0x01 + parent::CODE_LAST;
10+
11+
protected const CODE_LAST = self::ERROR_CODE_PARSING;
12+
13+
/**
14+
* Occurs when a tag contain creation error.
15+
*
16+
* @param non-empty-string $tag
17+
* @param int<0, max> $offset
18+
*/
19+
public static function fromCreatingTag(
20+
string $tag,
21+
string $source,
22+
int $offset = 0,
23+
\Throwable $prev = null,
24+
): static {
25+
$message = \sprintf('Error while parsing tag @%s', $tag);
26+
27+
return new static($source, $offset, $message, self::ERROR_CODE_PARSING, $prev);
28+
}
29+
}

0 commit comments

Comments
 (0)