-
Notifications
You must be signed in to change notification settings - Fork 235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow doctrine/lexer 2 #460
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,8 @@ | |
|
||
/** | ||
* Simple lexer for docblock annotations. | ||
* | ||
* @template-extends AbstractLexer<DocLexer::T_*> | ||
*/ | ||
final class DocLexer extends AbstractLexer | ||
{ | ||
|
@@ -39,7 +41,7 @@ final class DocLexer extends AbstractLexer | |
public const T_COLON = 112; | ||
public const T_MINUS = 113; | ||
|
||
/** @var array<string, int> */ | ||
/** @var array<string, self::T*> */ | ||
protected $noCase = [ | ||
'@' => self::T_AT, | ||
',' => self::T_COMMA, | ||
|
@@ -53,7 +55,7 @@ final class DocLexer extends AbstractLexer | |
'\\' => self::T_NAMESPACE_SEPARATOR, | ||
]; | ||
|
||
/** @var array<string, int> */ | ||
/** @var array<string, self::T*> */ | ||
protected $withCase = [ | ||
'true' => self::T_TRUE, | ||
'false' => self::T_FALSE, | ||
|
@@ -126,4 +128,12 @@ protected function getType(&$value) | |
|
||
return $type; | ||
} | ||
|
||
/** @return array{value: int|string, type:self::T_*|null, position:int} */ | ||
public function peek(): array | ||
{ | ||
$token = parent::peek(); | ||
|
||
return (array) $token; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should the array type always be forced here? In There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, we should not cast There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in #463 🎉 |
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to also override
glimpse
since it returns whateverpeek()
returns.