Skip to content
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

add support for class string service ids #434

Merged
merged 3 commits into from
Jul 12, 2022
Merged

add support for class string service ids #434

merged 3 commits into from
Jul 12, 2022

Conversation

laytan
Copy link

@laytan laytan commented Jun 14, 2022

According to this docs page using the fully qualified class name when interacting with services is a supported approach.

This PR adds the correct return type hint when this approach is used.

Comment on lines +81 to +88
if ($arg1 instanceof String_) {
// @todo determine what these types are.
return $arg1->value;
}

if ($arg1 instanceof ClassConstFetch && $arg1->class instanceof FullyQualified) {
return (string) $arg1->class;
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if there's anyway to leverage PHPStan type system, which may abstract away some of this logic. But it may not be as accessible in these extensions

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do I understand correctly, that you would like to ask phpstan if the argument is of type 'string' or 'class-string' instead of this?

Do you have any idea where to start looking to come up with a solution that does that (because I am not really experienced in phpstan source)?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I saw #397 which if I am not wrong, will make this plugin obsolete?

If so, in my opinion, this PR would make for good initial support of the feature. Any further (cleaner) solutions, for example in #397, using the type system would then also be checked against the tests for this feature.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can ignore that other PR, it's experimental. Let's work on this first

@mglaman mglaman merged commit 4de76b2 into mglaman:main Jul 12, 2022
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.

2 participants