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

Consider adding a type-hint to Table::find() for SelectQuery #17349

Open
nicosp opened this issue Oct 16, 2023 · 4 comments
Open

Consider adding a type-hint to Table::find() for SelectQuery #17349

nicosp opened this issue Oct 16, 2023 · 4 comments

Comments

@nicosp
Copy link
Contributor

nicosp commented Oct 16, 2023

Description

We are evaluating upgrading to 4.5 and the new *Query classes. This is easy with the exception of find() which still lists Query in the type-hint and return type.

Can we change the find() return type to SelectQuery or at least change the type hint?

Since SelectQuery is a subclass of Query both approaches should be backward compatible.

CakePHP Version

4.5.0

@ADmad ADmad added this to the 4.5.1 milestone Oct 16, 2023
@ADmad
Copy link
Member

ADmad commented Oct 16, 2023

Changing the return type as you suggest won't be backwards compatible if someone has overridden Table::find() and using Cake\ORM\Query as the return type.

@nicosp
Copy link
Contributor Author

nicosp commented Oct 16, 2023

Changing the return type as you suggest won't be backwards compatible if someone has overridden Table::find() and using Cake\ORM\Query as the return type.

You are right. I haven't considered that. Can we at least change the type hint?

@markstory
Copy link
Member

Changing the documented return type will result in phpstan errors because the documented type and the defined type diverge. We could suppress those warning in cakephp, but I'm not sure if those errors will spill into application code too.

@markstory markstory modified the milestones: 4.5.1, 4.5.2 Nov 15, 2023
@markstory markstory modified the milestones: 4.5.2, 4.5.3 Dec 15, 2023
@markstory markstory modified the milestones: 4.5.3, 4.5.4 Jan 20, 2024
@dereuromark dereuromark modified the milestones: 4.5.4, 6.0 Jan 28, 2024
Copy link

This issue is stale because it has been open for 120 days with no activity. Remove the stale label or comment or this will be closed in 15 days

@github-actions github-actions bot added the stale label May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants