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

Additional psalm param typehint for orderBy argument in findBy method #8586

Merged
merged 1 commit into from
Apr 5, 2021

Conversation

KartaviK
Copy link
Contributor

@KartaviK KartaviK commented Apr 2, 2021

Because of findBy([], ['somField' => 'DESC']...);

@@ -185,7 +185,7 @@ public function findAll()
* @param int|null $offset
*
* @psalm-param array<string, mixed> $criteria
* @psalm-param list<string>|null $orderBy
* @psalm-param list<string>|array<string, string>|null $orderBy
Copy link
Member

@greg0ire greg0ire Apr 2, 2021

Choose a reason for hiding this comment

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

Good catch, my bad! Should list<string> be removed? Also, EntityPersister::loadAll() seems to have the same issue, and EntityPersister::getSelectSQL() could be improved.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If list<string> can not be, so it can be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should i update EntityPersister::loadAll()?

Copy link
Member

@greg0ire greg0ire Apr 2, 2021

Choose a reason for hiding this comment

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

Yes please, and EntityPersister::getSelectSQL() too please 🙏

@greg0ire greg0ire added the Bug label Apr 2, 2021
@KartaviK
Copy link
Contributor Author

KartaviK commented Apr 2, 2021

@greg0ire Updated!

@greg0ire
Copy link
Member

greg0ire commented Apr 3, 2021

@orklah @vladyslavstartsev @simonberger please review, and please also tell me if you would rather I don't ping you for such reviews.

@orklah
Copy link
Contributor

orklah commented Apr 3, 2021

I don't mind being pinged :)

Ideally, this line in doctrine/persistence should be updated to match array<string, string> accordingly as well.

It could be the occasion to update some other case of $orderBy as well like in AbstractEntityPersister::getHash

@greg0ire
Copy link
Member

greg0ire commented Apr 3, 2021

Maybe we could go even further, see doctrine/persistence#165 ?
I looked for parameters called $orderBy in the whole project, here is the list of signatures that should be updated:

  • EntityRepository::findBy (wrong)
  • EntityRepository::findOneBy (imprecise)
  • AbstractEntityPersister::getHash (imprecise)
  • EntityPersister::getSelectSQL (imprecise)
  • EntityPersister::load (imprecise)
  • EntityPersister::loadAll (wrong)

Maybe this PR should only fix what's wrong so EntityRepository::findBy and EntityPersister::loadAll, and the rest should be improved in a PR targeting 2.9.x

A list of string is incorrect, it actually looks like this:
['someField' => 'DESC', 'someOtherField' => 'ASC'…]`
greg0ire
greg0ire previously approved these changes Apr 3, 2021
@greg0ire
Copy link
Member

greg0ire commented Apr 3, 2021

I updated the PR according to that plan.

@annuh annuh mentioned this pull request Apr 5, 2021
@greg0ire greg0ire added this to the 2.8.4 milestone Apr 5, 2021
@greg0ire greg0ire merged commit a588555 into doctrine:2.8.x Apr 5, 2021
@greg0ire
Copy link
Member

greg0ire commented Apr 5, 2021

Thanks @KartaviK !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants