-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PhpDocParser - option to preserve type alias with parse error
- Loading branch information
1 parent
afb728a
commit bfec872
Showing
3 changed files
with
171 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\PhpDocParser\Ast\Type; | ||
|
||
use PHPStan\PhpDocParser\Ast\NodeAttributes; | ||
use PHPStan\PhpDocParser\Parser\ParserException; | ||
|
||
class InvalidTypeNode implements TypeNode | ||
{ | ||
|
||
use NodeAttributes; | ||
|
||
/** @var mixed[] */ | ||
private $exceptionArgs; | ||
|
||
public function __construct(ParserException $exception) | ||
{ | ||
$this->exceptionArgs = [ | ||
$exception->getCurrentTokenValue(), | ||
$exception->getCurrentTokenType(), | ||
$exception->getCurrentOffset(), | ||
$exception->getExpectedTokenType(), | ||
$exception->getExpectedTokenValue(), | ||
]; | ||
} | ||
|
||
public function getException(): ParserException | ||
{ | ||
return new ParserException(...$this->exceptionArgs); | ||
} | ||
|
||
public function __toString(): string | ||
{ | ||
return '*Invalid type*'; | ||
} | ||
|
||
} |
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