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

chore: Adjust OCP\Server::get annotation to work with phpstan #50908

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

susnux
Copy link
Contributor

@susnux susnux commented Feb 19, 2025

Notices \OCP\Server::get does not correctly work with my IDE, seems the previous annoations were too complex and T was not referenced directly in a parameter, only in the constraint of S, so it was not getting resolved.

This annotation is simpler and also works with phpstan

@susnux susnux added 3. to review Waiting for reviews ♻️ refactor Refactor code (not a bug fix, not a feature just refactoring) labels Feb 19, 2025
Comment on lines +29 to +30
* @psalm-param class-string<T>|string $serviceName
* @psalm-return ($serviceName is class-string<T> ? T : mixed)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* @psalm-param class-string<T>|string $serviceName
* @psalm-return ($serviceName is class-string<T> ? T : mixed)
* @psalm-param class-string<T> $serviceName
* @psalm-return T

Isn't this enough? If the class isn't found then an exception is thrown, so the return should be irrelevant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But it can also be an alias instead of just a class name, right?

Copy link
Member

Choose a reason for hiding this comment

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

True, although it might be worth a try to remove it? Maybe it will be fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews ♻️ refactor Refactor code (not a bug fix, not a feature just refactoring)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants