Skip to content

New PSR for data querying#1284

Closed
alexandre-daubois wants to merge 1 commit intophp-fig:masterfrom
alexandre-daubois:feat/psr/query
Closed

New PSR for data querying#1284
alexandre-daubois wants to merge 1 commit intophp-fig:masterfrom
alexandre-daubois:feat/psr/query

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
Member

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...

@LeTraceurSnork
Copy link

Could you show an example of usage? In meta-document or just in comment?

@Crell
Copy link
Contributor

Crell commented Jun 25, 2025

This didn't go anywhere.

@Crell Crell closed this Jun 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants