Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
[TypeInfo] Add type alias support#59804
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation
34dbc2f
to14c1e1e
CompareNote that the portable syntax (= understood by phpstan & psalm & phpstorm) is this one: |
src/Symfony/Component/TypeInfo/Tests/Fixtures/DummyWithPhpDoc.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
But it is not how people usually write it I think. is it ? |
They have to if they want support from their tools... |
nicolas-grekas left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
Can you add a test case using psalm-type just to confirm phpstan's parser handles both?
hmmm IMO when this PR is merged it must not enforce one specific way of writing things with these tools. It should support both with and without |
More on this. The documentationhttps://phpstan.org/writing-php-code/phpdoc-types#local-type-aliases doesn't even mention this. I asked Ondrej a while back on symfony's slack about this but he didn't tought it was worth adding it to documentation. |
@Neirda24,@nicolas-grekas, I updated the code/tests to make it work for |
src/Symfony/Component/TypeInfo/TypeContext/TypeContextFactory.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/TypeInfo/Tests/Fixtures/DummyWithPhpDoc.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/TypeInfo/Tests/Fixtures/DummyWithTypeAliases.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Thank you@mtarld. |
77b8358
intosymfony:7.3Uh oh!
There was an error while loading.Please reload this page.
So fast ! Thank you@mtarld ! |
Uh oh!
There was an error while loading.Please reload this page.
Add type aliasing support in
TypeContext
andStringTypeResolver
, which enables the read of@phpstan-type
and@phpstan-import-type
.With this PR, the following code will be properly understood by TypeInfo (before, it used to throw an
UnhandledException
):