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

New PSR for data querying #1284

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

Conversation

alexandre-daubois
Copy link
Contributor

@alexandre-daubois alexandre-daubois commented Jul 4, 2022

A new PSR to standardize how data can be queried.

Here is the Google Groups thread: https://groups.google.com/g/php-fig/c/bKg4OvW-wcY

@alexandre-daubois alexandre-daubois requested a review from a team as a code owner July 4, 2022 16:50
@samdark
Copy link
Contributor

samdark commented Jul 4, 2022

Interesting. We have a different approach to similar problem at Yii: https://github.com/yiisoft/data

@alexandre-daubois
Copy link
Contributor Author

@samdark I really like how you managed filters! This is a great way to do this I didn't think of!

*
* @return QueryInterface
*/
public static function from(iterable $source, QueryContextInterface $context = null): QueryInterface;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public static function from(iterable $source, QueryContextInterface $context = null): QueryInterface;
public static function from(iterable $source, QueryContextInterface $context = null): static;

This is precisely the use case static returns were added for.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's right, I updated it!

*
* @return QueryContextInterface
*/
public function getContext(): QueryContextInterface;
Copy link
Contributor

Choose a reason for hiding this comment

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

"context objects" are a code smell.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can understand this. Maybe getContext, context arguments and QueryContextInterface could simply be removed!

*
* @return QueryInterface
*/
public function applyModifier(QueryModifierInterface $modifier): QueryInterface;
Copy link
Contributor

Choose a reason for hiding this comment

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

Ibid.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed as well. And also learnt what "ibid" stands for, thanks! 😄

*/
interface QueryInterface
{
/**namespace Psr\Query;

Choose a reason for hiding this comment

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

This namespace looks like a cut&paste error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, definitely. Thank you!

Copy link
Contributor

@ashnazg ashnazg left a comment

Choose a reason for hiding this comment

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

Looks interesting to me...

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