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

Update code with ProxyQueryInterface generic #1687

Merged
merged 3 commits into from
Aug 22, 2022

Conversation

VincentLanglet
Copy link
Member

@VincentLanglet VincentLanglet commented Aug 19, 2022

Subject

I am targeting this branch, because {reason}.

Closes #{put_issue_number_here}.

Changelog

### Added
- Generics for ProxyQueryInterface and ProxyQuery

@VincentLanglet VincentLanglet marked this pull request as ready for review August 21, 2022 13:00
@VincentLanglet VincentLanglet requested review from jordisala1991 and a team August 21, 2022 13:56
@@ -156,14 +156,15 @@ public function getBaseDatagrid(AdminInterface $admin, array $values = []): Data
if (!$query instanceof ProxyQueryInterface) {
throw new \TypeError(sprintf('The admin query MUST implement %s.', ProxyQueryInterface::class));
}
/** @phpstan-var ProxyQueryInterface<object> $query */
Copy link
Member

Choose a reason for hiding this comment

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

Is this one necessary? Isnt the admin->createQuery returning already with the generic applied?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's considered as a

Sonata\AdminBundle\Datagrid\ProxyQueryInterface&Sonata\DoctrineORMAdminBundle\Datagrid\ProxyQueryInterface<object>

And I have the error:

Method Sonata\DoctrineORMAdminBundle\Builder\DatagridBuilder::getBaseDatagrid() should return                                  
         Sonata\AdminBundle\Datagrid\DatagridInterface<Sonata\DoctrineORMAdminBundle\Datagrid\ProxyQueryInterface<object>> but returns  
         Sonata\AdminBundle\Datagrid\Datagrid<Sonata\DoctrineORMAdminBundle\Datagrid\ProxyQueryInterface>.  

/**
* @param ProxyQueryInterface<object> $query
*/
private function handleModel(ProxyQueryInterface $query, string $alias, FilterData $data): void
Copy link
Member

Choose a reason for hiding this comment

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

isnt this change a bc break?

Copy link
Member Author

Choose a reason for hiding this comment

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

The class is final.

Copy link
Member

@jordisala1991 jordisala1991 left a comment

Choose a reason for hiding this comment

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

I guess we need similar change for mongodb

@VincentLanglet VincentLanglet merged commit ceb8770 into sonata-project:4.x Aug 22, 2022
@VincentLanglet VincentLanglet deleted the proxyQueryGenerics branch August 22, 2022 07:01
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.

2 participants