-
Notifications
You must be signed in to change notification settings - Fork 114
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
support ConstExprNode node to avoid crashing with 500 #47
Conversation
@ildyria Thanks for the fix! Can you please share an example of the PhpDoc that causes this fail? Thanks! |
|
Found it. This will crash. /**
* Reset the token of the currently authenticated user.
*
* @return array{'token': string}
*
* @throws UnauthenticatedException
* @throws ModelDBException
* @throws \Exception
*/
public function resetToken(): array
{...} This will pass. /**
* Reset the token of the currently authenticated user.
*
* @return array
*
* @throws UnauthenticatedException
* @throws ModelDBException
* @throws \Exception
*/
public function resetToken(): array
{...} Note that this is valid and follows https://phpstan.org/writing-php-code/phpdoc-types#array-shapes |
I see. But as far as I can tell, suggested fix will result in loosing type information. I believe that it should be a more comprehensive support of the const expressions in PhpDoc (which will result in a correct type). So the PhpDoc comment: /**
* @var $foo array{'token': string}
*/ Should become type:
With the suggested fix it will become an
|
Yeah, but the information is inferred from the code in this case, not from the comment: return ['token' => $token];
That's fine, I will do it in the next release. For now you can change PhpDoc comment to this (notice no /**
* @return array{token: string}
*/ I will add const expressions support in the next release. Thanks. |
Fixed in #59 |
This allows the AST parser to not break on a ConstExprNode when going through documentation.