Skip to content

Added support for class-string and class-string<Type> types #90

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

Merged
merged 2 commits into from
Feb 2, 2020

Conversation

othercorey
Copy link
Contributor

This adds support for parsing class-string and class-string<Type>.

@mvriel
Copy link
Member

mvriel commented Jan 19, 2020

What is class-string? I saw a reference to it in Psalm but couldn't quickly figure out what it does. My first gut instinct says it is an alias for self; which makes me wonder why to introduce a new type.

I try to err on the safe side introducing new types as each 'special' type can cause a conflict in people's codebases.

Can you provide a bit of background for this change?

@othercorey
Copy link
Contributor Author

This is annotation supported by many static analyzers like phpstan/psalm/etc. It identifies string types that can only represent class names.

TypeResolver::class

@mvriel
Copy link
Member

mvriel commented Jan 19, 2020

I just did some research and found Psalm and PHPStan to provide quite a few more pseudo-types. This does mean we may need to re-evaluate how to deal with an increasing amount of potentially conflicting pseudo-types.

I need to check whether pseudo-types currently take precedence to the imports/uses in the Context information; because if we are to add more of these it is good to declare that an import takes precedence over a pseudo-type.

I don't have the availability to do that at this moment, I will get back to this as soon as I can

@orklah
Copy link
Contributor

orklah commented Feb 1, 2020

I need to check whether pseudo-types currently take precedence to the imports/uses in the Context information; because if we are to add more of these it is good to declare that an import takes precedence over a pseudo-type.

I believe they solved this issue by adding a "-" in most pseudo types making them incompatible with actual imports.

@mvriel
Copy link
Member

mvriel commented Feb 2, 2020

Yes, indeed. Though I am not sure whether the type resolver automatically behaves in the same way. The TypeResolver was written to be more flexible than PHP itself to better support pseudo-types :)

@mvriel
Copy link
Member

mvriel commented Feb 2, 2020

Just checked everything and this is a-ok! Thanks for your patience

@mvriel mvriel merged commit 4142e22 into phpDocumentor:master Feb 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants