Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
greg0ire merged 1 commit into
doctrine:2.8.xfrom
KartaviK:patch-3
Apr 5, 2021
Merged

Additional psalm param typehint for orderBy argument in findBy method#8586
greg0ire merged 1 commit into
doctrine:2.8.xfrom
KartaviK:patch-3

Conversation

@KartaviK
Copy link
Copy Markdown
Contributor

@KartaviK KartaviK commented Apr 2, 2021

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

Comment thread lib/Doctrine/ORM/EntityRepository.php Outdated
*
* @psalm-param array<string, mixed> $criteria
* @psalm-param list<string>|null $orderBy
* @psalm-param list<string>|array<string, string>|null $orderBy
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Comment thread lib/Doctrine/ORM/EntityRepository.php Outdated
@KartaviK
Copy link
Copy Markdown
Contributor Author

KartaviK commented Apr 2, 2021

@greg0ire Updated!

@greg0ire
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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