-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Fix templated phpdoc return type #10849
Conversation
I regenerated the psalm baseline locally, but the CI is still failing. Please regenerate it before merge. |
I don't believe that this change is correct. Can you elaborate what issue you're trying to fix here? |
phpstan cannot otherwise infer the resulting type for @derrabus why do you think this change is not correct? see other methods phpdocs in [1] and in my usecase, I needed to add |
See all the new Psalm errors that pop up after your change. 🙂 |
@derrabus looking into the psalm errors -> code: https://github.com/doctrine/orm/blob/2.15.4/lib/Doctrine/ORM/Cache.php#L42 it seems the are many places that accept a class name but are annotated as I am not paid to maintain this project so I would be happy if this PR can be accepted and the psalm baseline regenerated (I tried myself on Windows, but the updated baseline did not fix all errors). |
Neither am I. 🤷🏻♂️
I cannot merge a PR with a red CI and I won't fix other people's PRs in my freetime. |
@mvorisek What kind of problems do you have that you want to fix with this PR? Your last comment doesn't sound like that this is relevant to your daily work with ORM but more of an aid. We appreciate the effort people put into PRs as users (hopefully) appreciate the time we spent into the Doctrine project repositories on a regular basis. We would like to know how this should be handled, because, as @derrabus already mentioned, this would rather be a hinderance to our also unpaid freetime if the failed build doesn't get fixed. I'd like to ask you to go the second half of what you've started. |
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.
All 4 of your commit messages are unhelpful, or sometimes even plain wrong, it seems. As I probably have already told you in the past, you should read the contribution guidelines to figure out what to write, they're fairly extensive on the topic.
As for the the CI build, if you want to contribute to Doctrine, you should setup a proper development environment.
@@ -335,7 +335,8 @@ public function hasFilters(); | |||
/** | |||
* {@inheritDoc} | |||
* | |||
* @psalm-param string|class-string<T> $className | |||
* @param string $className | |||
* @psalm-param class-string<T> $className |
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.
EntityManager::getClassMetadata()
also supports aliased names and needs to do so until Persistence 2 support is removed:
orm/lib/Doctrine/ORM/EntityManager.php
Lines 305 to 316 in f7e4b61
* The class name must be the fully-qualified class name without a leading backslash | |
* (as it is returned by get_class($obj)) or an aliased class name. | |
* | |
* Examples: | |
* MyProject\Domain\User | |
* sales:PriceRequest | |
* | |
* Internal note: Performance-sensitive method. | |
* | |
* {@inheritDoc} | |
*/ | |
public function getClassMetadata($className) |
Should the same be expected of any EntityManagerInterface
implementation? If yes I'd say you're not so much fixing stuff as you are breaking it.
Fix templated phpdoc return type
Did you mean to write "parameter type" here?
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.
@greg0ire see #10849 (comment) for repro, I meant "return type", as the "return type" is currently not correctly narrowed as the "parameter type" does allow any string
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.
Related: #10853
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.
* @param string $className
* @psalm-param class-string<T> $className
Might be a good way to deprecate string param for static analysis user
and solve phpstan/phpstan#5175
here is a phpstan repro: https://phpstan.org/r/b2cbe847-a748-4094-bc49-44bd3e200e12 explaining the need notice the dumped type change when l6 is changed to |
This function accepts strings that are not FQCN, so changing the parameter type to Can we solve this with a conditional return type? |
There was an issue about this in phpstan |
Closing as it seems this change is not wanted, at least for ORM 2.x. |
I think the string support was deprecated so maybe the issue does not exist in 3.x anymore (or the phpdoc could be updated). Need to check |
When split between
@param
and@psalm-param
, only the@psalm-param
is used by psalm/phpstan, ieclass-string<T>
is used instead of (too wide)class|class-string<T>
.In the 2nd commit, I fixed all other simillar problems in the whole repo. I used
@.*(string.*\|class-s|class-string.*\|.*string)
regex to find the lines to check/fix.