diff --git a/src/Admin/FieldDescription.php b/src/Admin/FieldDescription.php index 14d66568a..590e2849d 100644 --- a/src/Admin/FieldDescription.php +++ b/src/Admin/FieldDescription.php @@ -91,7 +91,7 @@ public function isIdentifier(): bool return $this->fieldMapping['id'] ?? false; } - public function getValue($object) + public function getValue(object $object) { foreach ($this->parentAssociationMappings as $parentAssociationMapping) { $object = $this->getFieldValue($object, $parentAssociationMapping['fieldName']); diff --git a/src/Datagrid/OrderByToSelectWalker.php b/src/Datagrid/OrderByToSelectWalker.php index b19da86ef..825fa273f 100644 --- a/src/Datagrid/OrderByToSelectWalker.php +++ b/src/Datagrid/OrderByToSelectWalker.php @@ -14,6 +14,7 @@ namespace Sonata\DoctrineORMAdminBundle\Datagrid; use Doctrine\ORM\Query\AST\Functions\IdentityFunction; +use Doctrine\ORM\Query\AST\Node; use Doctrine\ORM\Query\AST\OrderByClause; use Doctrine\ORM\Query\AST\PathExpression; use Doctrine\ORM\Query\AST\SelectExpression; @@ -90,7 +91,7 @@ public function walkSelectStatement(SelectStatement $AST): void * * @return IdentityFunction|PathExpression */ - private function createSelectExpressionItem(PathExpression $pathExpression) + private function createSelectExpressionItem(PathExpression $pathExpression): Node { if (PathExpression::TYPE_SINGLE_VALUED_ASSOCIATION === $pathExpression->type) { $identity = new IdentityFunction('identity'); diff --git a/src/Datagrid/ProxyQuery.php b/src/Datagrid/ProxyQuery.php index 3285d71d3..a4e9ab9d3 100644 --- a/src/Datagrid/ProxyQuery.php +++ b/src/Datagrid/ProxyQuery.php @@ -114,22 +114,19 @@ class ProxyQuery implements ProxyQueryInterface */ private $hints = []; - /** - * @param QueryBuilder $queryBuilder - */ - public function __construct($queryBuilder) + public function __construct(QueryBuilder $queryBuilder) { $this->queryBuilder = $queryBuilder; $this->uniqueParameterId = 0; $this->entityJoinAliases = []; } - public function __call($name, $args) + public function __call(string $name, array $args) { return $this->queryBuilder->$name(...$args); } - public function __get($name) + public function __get(string $name) { return $this->queryBuilder->$name; } diff --git a/src/Datagrid/ProxyQueryInterface.php b/src/Datagrid/ProxyQueryInterface.php index 370ee0bd6..d073acaca 100644 --- a/src/Datagrid/ProxyQueryInterface.php +++ b/src/Datagrid/ProxyQueryInterface.php @@ -18,8 +18,5 @@ interface ProxyQueryInterface extends BaseProxyQueryInterface { - /** - * @return QueryBuilder - */ - public function getQueryBuilder(); + public function getQueryBuilder(): QueryBuilder; } diff --git a/src/DependencyInjection/Compiler/AddTemplatesCompilerPass.php b/src/DependencyInjection/Compiler/AddTemplatesCompilerPass.php index ee9dfa219..f9de10491 100644 --- a/src/DependencyInjection/Compiler/AddTemplatesCompilerPass.php +++ b/src/DependencyInjection/Compiler/AddTemplatesCompilerPass.php @@ -55,10 +55,9 @@ public function process(ContainerBuilder $container): void } /** - * @param string $name - * @param mixed $value + * @param mixed $value */ - public function mergeMethodCall(Definition $definition, $name, $value): void + public function mergeMethodCall(Definition $definition, string $name, $value): void { $methodCalls = $definition->getMethodCalls(); diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 7e57b8ab0..f7d2155b8 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -30,10 +30,8 @@ class Configuration implements ConfigurationInterface { /** * Generates the configuration tree. - * - * @return TreeBuilder */ - public function getConfigTreeBuilder() + public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder('sonata_doctrine_orm_admin'); diff --git a/src/Filter/AbstractDateFilter.php b/src/Filter/AbstractDateFilter.php index bc16af829..0a6396fa3 100644 --- a/src/Filter/AbstractDateFilter.php +++ b/src/Filter/AbstractDateFilter.php @@ -13,7 +13,6 @@ namespace Sonata\DoctrineORMAdminBundle\Filter; -use Sonata\AdminBundle\Datagrid\ProxyQueryInterface as BaseProxyQueryInterface; use Sonata\AdminBundle\Form\Type\Filter\DateRangeType; use Sonata\AdminBundle\Form\Type\Filter\DateTimeRangeType; use Sonata\AdminBundle\Form\Type\Filter\DateTimeType; @@ -46,21 +45,10 @@ abstract class AbstractDateFilter extends Filter */ protected $time = false; - public function filter(BaseProxyQueryInterface $query, $alias, $field, $data): void + public function filter(ProxyQueryInterface $query, string $alias, string $field, array $data): void { - /* NEXT_MAJOR: Remove this deprecation and update the typehint */ - if (!$query instanceof ProxyQueryInterface) { - @trigger_error(sprintf( - 'Passing %s as argument 1 to %s() is deprecated since sonata-project/doctrine-orm-admin-bundle 3.27' - .' and will throw a \TypeError error in version 4.0. You MUST pass an instance of %s instead.', - \get_class($query), - __METHOD__, - ProxyQueryInterface::class - )); - } - // check data sanity - if (!$data || !\is_array($data) || !\array_key_exists('value', $data)) { + if (!\array_key_exists('value', $data)) { return; } diff --git a/src/Filter/BooleanFilter.php b/src/Filter/BooleanFilter.php index 33a1d58bf..bfd1e61ff 100644 --- a/src/Filter/BooleanFilter.php +++ b/src/Filter/BooleanFilter.php @@ -13,7 +13,6 @@ namespace Sonata\DoctrineORMAdminBundle\Filter; -use Sonata\AdminBundle\Datagrid\ProxyQueryInterface as BaseProxyQueryInterface; use Sonata\AdminBundle\Form\Type\Filter\DefaultType; use Sonata\DoctrineORMAdminBundle\Datagrid\ProxyQueryInterface; use Sonata\Form\Type\BooleanType; @@ -24,20 +23,9 @@ */ class BooleanFilter extends Filter { - public function filter(BaseProxyQueryInterface $query, $alias, $field, $data): void + public function filter(ProxyQueryInterface $query, string $alias, string $field, array $data): void { - /* NEXT_MAJOR: Remove this deprecation and update the typehint */ - if (!$query instanceof ProxyQueryInterface) { - @trigger_error(sprintf( - 'Passing %s as argument 1 to %s() is deprecated since sonata-project/doctrine-orm-admin-bundle 3.27' - .' and will throw a \TypeError error in version 4.0. You MUST pass an instance of %s instead.', - \get_class($query), - __METHOD__, - ProxyQueryInterface::class - )); - } - - if (!$data || !\is_array($data) || !\array_key_exists('type', $data) || !\array_key_exists('value', $data)) { + if (!\array_key_exists('type', $data) || !\array_key_exists('value', $data)) { return; } diff --git a/src/Filter/CallbackFilter.php b/src/Filter/CallbackFilter.php index 52352b5a8..47033a4bd 100644 --- a/src/Filter/CallbackFilter.php +++ b/src/Filter/CallbackFilter.php @@ -13,7 +13,6 @@ namespace Sonata\DoctrineORMAdminBundle\Filter; -use Sonata\AdminBundle\Datagrid\ProxyQueryInterface as BaseProxyQueryInterface; use Sonata\AdminBundle\Form\Type\Filter\DefaultType; use Sonata\DoctrineORMAdminBundle\Datagrid\ProxyQueryInterface; use Symfony\Component\Form\Extension\Core\Type\HiddenType; @@ -24,19 +23,8 @@ */ class CallbackFilter extends Filter { - public function filter(BaseProxyQueryInterface $query, $alias, $field, $data): void + public function filter(ProxyQueryInterface $query, string $alias, string $field, array $data): void { - /* NEXT_MAJOR: Remove this deprecation and update the typehint */ - if (!$query instanceof ProxyQueryInterface) { - @trigger_error(sprintf( - 'Passing %s as argument 1 to %s() is deprecated since sonata-project/doctrine-orm-admin-bundle 3.27' - .' and will throw a \TypeError error in version 4.0. You MUST pass an instance of %s instead.', - \get_class($query), - __METHOD__, - ProxyQueryInterface::class - )); - } - if (!\is_callable($this->getOption('callback'))) { throw new \RuntimeException(sprintf('Please provide a valid callback option "filter" for field "%s"', $this->getName())); } @@ -80,22 +68,8 @@ public function getRenderSettings(): array ]]; } - /** - * @param mixed[] $data - */ - protected function association(BaseProxyQueryInterface $query, array $data): array + protected function association(ProxyQueryInterface $query, array $data): array { - /* NEXT_MAJOR: Remove this deprecation and update the typehint */ - if (!$query instanceof ProxyQueryInterface) { - @trigger_error(sprintf( - 'Passing %s as argument 1 to %s() is deprecated since sonata-project/doctrine-orm-admin-bundle 3.27' - .' and will throw a \TypeError error in version 4.0. You MUST pass an instance of %s instead.', - \get_class($query), - __METHOD__, - ProxyQueryInterface::class - )); - } - $alias = $query->entityJoin($this->getParentAssociationMappings()); return [$this->getOption('alias', $alias), $this->getFieldName()]; diff --git a/src/Filter/ChoiceFilter.php b/src/Filter/ChoiceFilter.php index 333055759..28b00992e 100644 --- a/src/Filter/ChoiceFilter.php +++ b/src/Filter/ChoiceFilter.php @@ -13,7 +13,6 @@ namespace Sonata\DoctrineORMAdminBundle\Filter; -use Sonata\AdminBundle\Datagrid\ProxyQueryInterface as BaseProxyQueryInterface; use Sonata\AdminBundle\Form\Type\Filter\DefaultType; use Sonata\AdminBundle\Form\Type\Operator\EqualOperatorType; use Sonata\DoctrineORMAdminBundle\Datagrid\ProxyQueryInterface; @@ -23,20 +22,9 @@ */ class ChoiceFilter extends Filter { - public function filter(BaseProxyQueryInterface $query, $alias, $field, $data): void + public function filter(ProxyQueryInterface $query, string $alias, string $field, array $data): void { - /* NEXT_MAJOR: Remove this deprecation and update the typehint */ - if (!$query instanceof ProxyQueryInterface) { - @trigger_error(sprintf( - 'Passing %s as argument 1 to %s() is deprecated since sonata-project/doctrine-orm-admin-bundle 3.27' - .' and will throw a \TypeError error in version 4.0. You MUST pass an instance of %s instead.', - \get_class($query), - __METHOD__, - ProxyQueryInterface::class - )); - } - - if (!$data || !\is_array($data) || !\array_key_exists('type', $data) || !\array_key_exists('value', $data)) { + if (!\array_key_exists('type', $data) || !\array_key_exists('value', $data)) { return; } @@ -66,10 +54,7 @@ public function getRenderSettings(): array ]]; } - /** - * NEXT_MAJOR: Change the typehint to ProxyQueryInterface. - */ - private function filterWithMultipleValues(BaseProxyQueryInterface $query, string $alias, string $field, array $data = []): void + private function filterWithMultipleValues(ProxyQueryInterface $query, string $alias, string $field, array $data = []): void { if (0 === \count($data['value'])) { return; @@ -100,10 +85,7 @@ private function filterWithMultipleValues(BaseProxyQueryInterface $query, string } } - /** - * NEXT_MAJOR: Change the typehint to ProxyQueryInterface. - */ - private function filterWithSingleValue(BaseProxyQueryInterface $query, string $alias, string $field, array $data = []): void + private function filterWithSingleValue(ProxyQueryInterface $query, string $alias, string $field, array $data = []): void { if ('' === $data['value'] || false === $data['value']) { return; diff --git a/src/Filter/ClassFilter.php b/src/Filter/ClassFilter.php index ee0faecd3..c5d45075a 100644 --- a/src/Filter/ClassFilter.php +++ b/src/Filter/ClassFilter.php @@ -13,7 +13,6 @@ namespace Sonata\DoctrineORMAdminBundle\Filter; -use Sonata\AdminBundle\Datagrid\ProxyQueryInterface as BaseProxyQueryInterface; use Sonata\AdminBundle\Form\Type\Filter\DefaultType; use Sonata\AdminBundle\Form\Type\Operator\EqualOperatorType; use Sonata\DoctrineORMAdminBundle\Datagrid\ProxyQueryInterface; @@ -29,20 +28,9 @@ class ClassFilter extends Filter EqualOperatorType::TYPE_NOT_EQUAL => 'NOT INSTANCE OF', ]; - public function filter(BaseProxyQueryInterface $query, $alias, $field, $data): void + public function filter(ProxyQueryInterface $query, string $alias, string $field, array $data): void { - /* NEXT_MAJOR: Remove this deprecation and update the typehint */ - if (!$query instanceof ProxyQueryInterface) { - @trigger_error(sprintf( - 'Passing %s as argument 1 to %s() is deprecated since sonata-project/doctrine-orm-admin-bundle 3.27' - .' and will throw a \TypeError error in version 4.0. You MUST pass an instance of %s instead.', - \get_class($query), - __METHOD__, - ProxyQueryInterface::class - )); - } - - if (!$data || !\is_array($data) || !\array_key_exists('value', $data)) { + if (!\array_key_exists('value', $data)) { return; } diff --git a/src/Filter/EmptyFilter.php b/src/Filter/EmptyFilter.php deleted file mode 100644 index a9fdb3012..000000000 --- a/src/Filter/EmptyFilter.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Sonata\DoctrineORMAdminBundle\Filter; - -/** - * @psalm-suppress InvalidExtendClass - */ -final class EmptyFilter extends NullFilter -{ - public function __construct() - { - // NEXT_MAJOR: remove this file - @trigger_error(sprintf( - 'The %s class is deprecated since version 3.27 and will be removed in 4.0.' - .' Use %s instead.', - __CLASS__, - NullFilter::class - ), \E_USER_DEPRECATED); - } -} diff --git a/src/Filter/Filter.php b/src/Filter/Filter.php index cb0ae8f7a..7a289ef82 100644 --- a/src/Filter/Filter.php +++ b/src/Filter/Filter.php @@ -25,19 +25,17 @@ abstract class Filter extends BaseFilter protected $active = false; /** - * NEXT_MAJOR change $query type for Sonata\DoctrineORMAdminBundle\Datagrid\ProxyQueryInterface. - * * Apply the filter to the QueryBuilder instance. - * - * @param string $alias - * @param string $field - * @param mixed[] $data */ - abstract public function filter(BaseProxyQueryInterface $query, $alias, $field, $data); + abstract public function filter(ProxyQueryInterface $query, string $alias, string $field, array $data): void; - public function apply($query, $filterData): void + public function apply(BaseProxyQueryInterface $query, array $filterData): void { - if (\is_array($filterData) && \array_key_exists('value', $filterData)) { + if (!$query instanceof ProxyQueryInterface) { + throw new \TypeError(sprintf('The query MUST implement %s.', ProxyQueryInterface::class)); + } + + if (\array_key_exists('value', $filterData)) { [$alias, $field] = $this->association($query, $filterData); $this->filter($query, $alias, $field, $filterData); @@ -49,24 +47,8 @@ public function isActive(): bool return $this->active; } - /** - * @param mixed[] $data - * - * @return string[] - */ - protected function association(BaseProxyQueryInterface $query, array $data): array + protected function association(ProxyQueryInterface $query, array $data): array { - /* NEXT_MAJOR: Remove this deprecation and update the typehint */ - if (!$query instanceof ProxyQueryInterface) { - @trigger_error(sprintf( - 'Passing %s as argument 1 to %s() is deprecated since sonata-project/doctrine-orm-admin-bundle 3.27' - .' and will throw a \TypeError error in version 4.0. You MUST pass an instance of %s instead.', - \get_class($query), - __METHOD__, - ProxyQueryInterface::class - )); - } - $alias = $query->entityJoin($this->getParentAssociationMappings()); return [$alias, $this->getFieldName()]; @@ -75,19 +57,8 @@ protected function association(BaseProxyQueryInterface $query, array $data): arr /** * @param mixed $parameter */ - protected function applyWhere(BaseProxyQueryInterface $query, $parameter): void + protected function applyWhere(ProxyQueryInterface $query, $parameter): void { - /* NEXT_MAJOR: Remove this deprecation and update the typehint */ - if (!$query instanceof ProxyQueryInterface) { - @trigger_error(sprintf( - 'Passing %s as argument 1 to %s() is deprecated since sonata-project/doctrine-orm-admin-bundle 3.27' - .' and will throw a \TypeError error in version 4.0. You MUST pass an instance of %s instead.', - \get_class($query), - __METHOD__, - ProxyQueryInterface::class - )); - } - if (self::CONDITION_OR === $this->getCondition()) { $query->getQueryBuilder()->orWhere($parameter); } else { @@ -98,19 +69,8 @@ protected function applyWhere(BaseProxyQueryInterface $query, $parameter): void $this->active = true; } - protected function getNewParameterName(BaseProxyQueryInterface $query): string + protected function getNewParameterName(ProxyQueryInterface $query): string { - /* NEXT_MAJOR: Remove this deprecation and update the typehint */ - if (!$query instanceof ProxyQueryInterface) { - @trigger_error(sprintf( - 'Passing %s as argument 1 to %s() is deprecated since sonata-project/doctrine-orm-admin-bundle 3.27' - .' and will throw a \TypeError error in version 4.0. You MUST pass an instance of %s instead.', - \get_class($query), - __METHOD__, - ProxyQueryInterface::class - )); - } - // dots are not accepted in a DQL identifier so replace them // by underscores. return str_replace('.', '_', $this->getName()).'_'.$query->getUniqueParameterId(); diff --git a/src/Filter/ModelAutocompleteFilter.php b/src/Filter/ModelAutocompleteFilter.php index c3abe5365..09a3efdd5 100644 --- a/src/Filter/ModelAutocompleteFilter.php +++ b/src/Filter/ModelAutocompleteFilter.php @@ -14,7 +14,6 @@ namespace Sonata\DoctrineORMAdminBundle\Filter; use Doctrine\Common\Collections\Collection; -use Sonata\AdminBundle\Datagrid\ProxyQueryInterface as BaseProxyQueryInterface; use Sonata\AdminBundle\Form\Type\Filter\DefaultType; use Sonata\AdminBundle\Form\Type\ModelAutocompleteType; use Sonata\AdminBundle\Form\Type\Operator\EqualOperatorType; @@ -25,20 +24,9 @@ */ class ModelAutocompleteFilter extends Filter { - public function filter(BaseProxyQueryInterface $query, $alias, $field, $data): void + public function filter(ProxyQueryInterface $query, string $alias, string $field, array $data): void { - /* NEXT_MAJOR: Remove this deprecation and update the typehint */ - if (!$query instanceof ProxyQueryInterface) { - @trigger_error(sprintf( - 'Passing %s as argument 1 to %s() is deprecated since sonata-project/doctrine-orm-admin-bundle 3.27' - .' and will throw a \TypeError error in version 4.0. You MUST pass an instance of %s instead.', - \get_class($query), - __METHOD__, - ProxyQueryInterface::class - )); - } - - if (!$data || !\is_array($data) || !\array_key_exists('value', $data)) { + if (!\array_key_exists('value', $data)) { return; } @@ -79,22 +67,10 @@ public function getRenderSettings(): array * For the record, the $alias value is provided by the association method (and the entity join method) * so the field value is not used here. * - * @param string $alias * @param mixed[] $data */ - protected function handleMultiple(BaseProxyQueryInterface $query, $alias, $data): void + protected function handleMultiple(ProxyQueryInterface $query, string $alias, array $data): void { - /* NEXT_MAJOR: Remove this deprecation and update the typehint */ - if (!$query instanceof ProxyQueryInterface) { - @trigger_error(sprintf( - 'Passing %s as argument 1 to %s() is deprecated since sonata-project/doctrine-orm-admin-bundle 3.27' - .' and will throw a \TypeError error in version 4.0. You MUST pass an instance of %s instead.', - \get_class($query), - __METHOD__, - ProxyQueryInterface::class - )); - } - if (0 === \count($data['value'])) { return; } @@ -111,22 +87,10 @@ protected function handleMultiple(BaseProxyQueryInterface $query, $alias, $data) } /** - * @param string $alias * @param mixed[] $data */ - protected function handleModel(BaseProxyQueryInterface $query, $alias, $data): void + protected function handleModel(ProxyQueryInterface $query, string $alias, array $data): void { - /* NEXT_MAJOR: Remove this deprecation and update the typehint */ - if (!$query instanceof ProxyQueryInterface) { - @trigger_error(sprintf( - 'Passing %s as argument 1 to %s() is deprecated since sonata-project/doctrine-orm-admin-bundle 3.27' - .' and will throw a \TypeError error in version 4.0. You MUST pass an instance of %s instead.', - \get_class($query), - __METHOD__, - ProxyQueryInterface::class - )); - } - if (empty($data['value'])) { return; } @@ -142,28 +106,12 @@ protected function handleModel(BaseProxyQueryInterface $query, $alias, $data): v $query->getQueryBuilder()->setParameter($parameterName, $data['value']); } - /** - * @param mixed[] $data - * - * @phpstan-return array{string, bool} - */ - protected function association(BaseProxyQueryInterface $query, $data): array + protected function association(ProxyQueryInterface $query, array $data): array { - /* NEXT_MAJOR: Remove this deprecation and update the typehint */ - if (!$query instanceof ProxyQueryInterface) { - @trigger_error(sprintf( - 'Passing %s as argument 1 to %s() is deprecated since sonata-project/doctrine-orm-admin-bundle 3.27' - .' and will throw a \TypeError error in version 4.0. You MUST pass an instance of %s instead.', - \get_class($query), - __METHOD__, - ProxyQueryInterface::class - )); - } - $associationMappings = $this->getParentAssociationMappings(); $associationMappings[] = $this->getAssociationMapping(); $alias = $query->entityJoin($associationMappings); - return [$alias, false]; + return [$alias, '']; } } diff --git a/src/Filter/ModelFilter.php b/src/Filter/ModelFilter.php index 469810e45..2ccf34cce 100644 --- a/src/Filter/ModelFilter.php +++ b/src/Filter/ModelFilter.php @@ -15,7 +15,6 @@ use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping\ClassMetadata; -use Sonata\AdminBundle\Datagrid\ProxyQueryInterface as BaseProxyQueryInterface; use Sonata\AdminBundle\Form\Type\Filter\DefaultType; use Sonata\AdminBundle\Form\Type\Operator\EqualOperatorType; use Sonata\DoctrineORMAdminBundle\Datagrid\ProxyQueryInterface; @@ -26,20 +25,9 @@ */ class ModelFilter extends Filter { - public function filter(BaseProxyQueryInterface $query, $alias, $field, $data): void + public function filter(ProxyQueryInterface $query, string $alias, string $field, array $data): void { - /* NEXT_MAJOR: Remove this deprecation and update the typehint */ - if (!$query instanceof ProxyQueryInterface) { - @trigger_error(sprintf( - 'Passing %s as argument 1 to %s() is deprecated since sonata-project/doctrine-orm-admin-bundle 3.27' - .' and will throw a \TypeError error in version 4.0. You MUST pass an instance of %s instead.', - \get_class($query), - __METHOD__, - ProxyQueryInterface::class - )); - } - - if (!$data || !\is_array($data) || !\array_key_exists('value', $data) || empty($data['value'])) { + if (!\array_key_exists('value', $data) || empty($data['value'])) { return; } @@ -81,22 +69,10 @@ public function getRenderSettings(): array * For the record, the $alias value is provided by the association method (and the entity join method) * so the field value is not used here. * - * @param string $alias * @param mixed[] $data */ - protected function handleMultiple(BaseProxyQueryInterface $query, $alias, $data): void + protected function handleMultiple(ProxyQueryInterface $query, string $alias, array $data): void { - /* NEXT_MAJOR: Remove this deprecation and update the typehint */ - if (!$query instanceof ProxyQueryInterface) { - @trigger_error(sprintf( - 'Passing %s as argument 1 to %s() is deprecated since sonata-project/doctrine-orm-admin-bundle 3.27' - .' and will throw a \TypeError error in version 4.0. You MUST pass an instance of %s instead.', - \get_class($query), - __METHOD__, - ProxyQueryInterface::class - )); - } - if (0 === \count($data['value'])) { return; } @@ -126,24 +102,8 @@ protected function handleMultiple(BaseProxyQueryInterface $query, $alias, $data) $query->getQueryBuilder()->setParameter($parameterName, $data['value']); } - /** - * @param mixed[] $data - * - * @phpstan-return array{string, bool} - */ - protected function association(BaseProxyQueryInterface $query, array $data): array + protected function association(ProxyQueryInterface $query, array $data): array { - /* NEXT_MAJOR: Remove this deprecation and update the typehint */ - if (!$query instanceof ProxyQueryInterface) { - @trigger_error(sprintf( - 'Passing %s as argument 1 to %s() is deprecated since sonata-project/doctrine-orm-admin-bundle 3.27' - .' and will throw a \TypeError error in version 4.0. You MUST pass an instance of %s instead.', - \get_class($query), - __METHOD__, - ProxyQueryInterface::class - )); - } - $types = [ ClassMetadata::ONE_TO_ONE, ClassMetadata::ONE_TO_MANY, @@ -159,26 +119,15 @@ protected function association(BaseProxyQueryInterface $query, array $data): arr $associationMappings[] = $this->getAssociationMapping(); $alias = $query->entityJoin($associationMappings); - return [$alias, false]; + return [$alias, '']; } /** * Retrieve the parent alias for given alias. * Root alias for direct association or entity joined alias for association depth >= 2. */ - private function getParentAlias(BaseProxyQueryInterface $query, string $alias): string + private function getParentAlias(ProxyQueryInterface $query, string $alias): string { - /* NEXT_MAJOR: Remove this deprecation and update the typehint */ - if (!$query instanceof ProxyQueryInterface) { - @trigger_error(sprintf( - 'Passing %s as argument 1 to %s() is deprecated since sonata-project/doctrine-orm-admin-bundle 3.27' - .' and will throw a \TypeError error in version 4.0. You MUST pass an instance of %s instead.', - \get_class($query), - __METHOD__, - ProxyQueryInterface::class - )); - } - $parentAlias = $rootAlias = current($query->getQueryBuilder()->getRootAliases()); $joins = $query->getQueryBuilder()->getDQLPart('join'); if (isset($joins[$rootAlias])) { diff --git a/src/Filter/NullFilter.php b/src/Filter/NullFilter.php index 226a558f7..fba291af9 100644 --- a/src/Filter/NullFilter.php +++ b/src/Filter/NullFilter.php @@ -13,38 +13,16 @@ namespace Sonata\DoctrineORMAdminBundle\Filter; -use Sonata\AdminBundle\Datagrid\ProxyQueryInterface as BaseProxyQueryInterface; use Sonata\AdminBundle\Form\Type\Filter\DefaultType; use Sonata\DoctrineORMAdminBundle\Datagrid\ProxyQueryInterface; use Sonata\Form\Type\BooleanType; use Symfony\Component\Form\Extension\Core\Type\HiddenType; -/** - * NEXT_MAJOR: Declare this class as final. - * - * @final - */ -class NullFilter extends Filter +final class NullFilter extends Filter { - /** - * @param string $alias - * @param string $field - * @param mixed[]|null $data - */ - public function filter(BaseProxyQueryInterface $query, $alias, $field, $data): void + public function filter(ProxyQueryInterface $query, string $alias, string $field, array $data): void { - /* NEXT_MAJOR: Remove this deprecation and update the typehint */ - if (!$query instanceof ProxyQueryInterface) { - @trigger_error(sprintf( - 'Passing %s as argument 1 to %s() is deprecated since sonata-project/doctrine-orm-admin-bundle 3.27' - .' and will throw a \TypeError error in version 4.0. You MUST pass an instance of %s instead.', - \get_class($query), - __METHOD__, - ProxyQueryInterface::class - )); - } - - if (null === $data || !\is_array($data) || !\array_key_exists('value', $data)) { + if (!\array_key_exists('value', $data)) { return; } diff --git a/src/Filter/NumberFilter.php b/src/Filter/NumberFilter.php index c8e4c35f4..63f41d519 100644 --- a/src/Filter/NumberFilter.php +++ b/src/Filter/NumberFilter.php @@ -13,7 +13,6 @@ namespace Sonata\DoctrineORMAdminBundle\Filter; -use Sonata\AdminBundle\Datagrid\ProxyQueryInterface as BaseProxyQueryInterface; use Sonata\AdminBundle\Form\Type\Filter\NumberType; use Sonata\AdminBundle\Form\Type\Operator\NumberOperatorType; use Sonata\DoctrineORMAdminBundle\Datagrid\ProxyQueryInterface; @@ -32,20 +31,9 @@ class NumberFilter extends Filter NumberOperatorType::TYPE_LESS_THAN => '<', ]; - public function filter(BaseProxyQueryInterface $query, $alias, $field, $data): void + public function filter(ProxyQueryInterface $query, string $alias, string $field, array $data): void { - /* NEXT_MAJOR: Remove this deprecation and update the typehint */ - if (!$query instanceof ProxyQueryInterface) { - @trigger_error(sprintf( - 'Passing %s as argument 1 to %s() is deprecated since sonata-project/doctrine-orm-admin-bundle 3.27' - .' and will throw a \TypeError error in version 4.0. You MUST pass an instance of %s instead.', - \get_class($query), - __METHOD__, - ProxyQueryInterface::class - )); - } - - if (!$data || !\is_array($data) || !\array_key_exists('value', $data) || !is_numeric($data['value'])) { + if (!\array_key_exists('value', $data) || !is_numeric($data['value'])) { return; } diff --git a/src/Filter/StringFilter.php b/src/Filter/StringFilter.php index 2d4c67ec9..28b50aa88 100644 --- a/src/Filter/StringFilter.php +++ b/src/Filter/StringFilter.php @@ -13,7 +13,6 @@ namespace Sonata\DoctrineORMAdminBundle\Filter; -use Sonata\AdminBundle\Datagrid\ProxyQueryInterface as BaseProxyQueryInterface; use Sonata\AdminBundle\Form\Type\Filter\ChoiceType; use Sonata\AdminBundle\Form\Type\Operator\StringOperatorType; use Sonata\DoctrineORMAdminBundle\Datagrid\ProxyQueryInterface; @@ -47,20 +46,9 @@ class StringFilter extends Filter StringOperatorType::TYPE_NOT_CONTAINS, ]; - public function filter(BaseProxyQueryInterface $query, $alias, $field, $data): void + public function filter(ProxyQueryInterface $query, string $alias, string $field, array $data): void { - /* NEXT_MAJOR: Remove this deprecation and update the typehint */ - if (!$query instanceof ProxyQueryInterface) { - @trigger_error(sprintf( - 'Passing %s as argument 1 to %s() is deprecated since sonata-project/doctrine-orm-admin-bundle 3.27' - .' and will throw a \TypeError error in version 4.0. You MUST pass an instance of %s instead.', - \get_class($query), - __METHOD__, - ProxyQueryInterface::class - )); - } - - if (!\is_array($data) || !\array_key_exists('value', $data)) { + if (!\array_key_exists('value', $data)) { return; } diff --git a/src/Filter/StringListFilter.php b/src/Filter/StringListFilter.php index 91fac7a95..53e541041 100644 --- a/src/Filter/StringListFilter.php +++ b/src/Filter/StringListFilter.php @@ -13,27 +13,15 @@ namespace Sonata\DoctrineORMAdminBundle\Filter; -use Sonata\AdminBundle\Datagrid\ProxyQueryInterface as BaseProxyQueryInterface; use Sonata\AdminBundle\Form\Type\Filter\ChoiceType; use Sonata\AdminBundle\Form\Type\Operator\ContainsOperatorType; use Sonata\DoctrineORMAdminBundle\Datagrid\ProxyQueryInterface; final class StringListFilter extends Filter { - public function filter(BaseProxyQueryInterface $query, $alias, $field, $data): void + public function filter(ProxyQueryInterface $query, string $alias, string $field, array $data): void { - /* NEXT_MAJOR: Remove this deprecation and update the typehint */ - if (!$query instanceof ProxyQueryInterface) { - @trigger_error(sprintf( - 'Passing %s as argument 1 to %s() is deprecated since sonata-project/doctrine-orm-admin-bundle 3.27' - .' and will throw a \TypeError error in version 4.0. You MUST pass an instance of %s instead.', - \get_class($query), - __METHOD__, - ProxyQueryInterface::class - )); - } - - if (!$data || !\is_array($data) || !\array_key_exists('type', $data) || !\array_key_exists('value', $data)) { + if (!\array_key_exists('type', $data) || !\array_key_exists('value', $data)) { return; } diff --git a/src/Guesser/AbstractTypeGuesser.php b/src/Guesser/AbstractTypeGuesser.php index f20c04dc9..c7276daf4 100644 --- a/src/Guesser/AbstractTypeGuesser.php +++ b/src/Guesser/AbstractTypeGuesser.php @@ -20,16 +20,11 @@ abstract class AbstractTypeGuesser implements TypeGuesserInterface { /** - * @param string $baseClass - * @param string $propertyFullName - * - * @return array|null - * * @phpstan-param class-string $baseClass * * @phpstan-return array{\Doctrine\ORM\Mapping\ClassMetadata, string, array}|null */ - protected function getParentMetadataForProperty($baseClass, $propertyFullName, ModelManagerInterface $modelManager) + protected function getParentMetadataForProperty(string $baseClass, string $propertyFullName, ModelManagerInterface $modelManager): ?array { try { return $modelManager->getParentMetadataForProperty($baseClass, $propertyFullName); diff --git a/tests/Filter/BooleanFilterTest.php b/tests/Filter/BooleanFilterTest.php index 7a1f9f362..1f665b670 100644 --- a/tests/Filter/BooleanFilterTest.php +++ b/tests/Filter/BooleanFilterTest.php @@ -37,11 +37,6 @@ public function testFilterEmpty(): void $builder = new ProxyQuery($this->createQueryBuilderStub()); - $filter->filter($builder, 'alias', 'field', null); - $filter->filter($builder, 'alias', 'field', ''); - $filter->filter($builder, 'alias', 'field', 'test'); - $filter->filter($builder, 'alias', 'field', false); - $filter->filter($builder, 'alias', 'field', []); $filter->filter($builder, 'alias', 'field', [null, 'test']); diff --git a/tests/Filter/CallbackFilterTest.php b/tests/Filter/CallbackFilterTest.php index 71ede7a91..8f4417677 100644 --- a/tests/Filter/CallbackFilterTest.php +++ b/tests/Filter/CallbackFilterTest.php @@ -14,6 +14,7 @@ namespace Sonata\DoctrineORMAdminBundle\Tests\Filter; use Sonata\DoctrineORMAdminBundle\Datagrid\ProxyQuery; +use Sonata\DoctrineORMAdminBundle\Datagrid\ProxyQueryInterface; use Sonata\DoctrineORMAdminBundle\Filter\CallbackFilter; use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; use Symfony\Component\Form\Extension\Core\Type\HiddenType; @@ -38,15 +39,15 @@ public function testFilterClosure(): void $filter = new CallbackFilter(); $filter->initialize('field_name', [ - 'callback' => static function ($builder, $alias, $field, $value) { - $builder->andWhere(sprintf('CUSTOM QUERY %s.%s', $alias, $field)); - $builder->setParameter('value', $value); + 'callback' => static function (ProxyQueryInterface $query, string $alias, string $field, array $data): bool { + $query->getQueryBuilder()->andWhere(sprintf('CUSTOM QUERY %s.%s', $alias, $field)); + $query->getQueryBuilder()->setParameter('value', $data['value']); return true; }, ]); - $filter->filter($builder, 'alias', 'field', 'myValue'); + $filter->filter($builder, 'alias', 'field', ['value' => 'myValue']); $this->assertSame(['CUSTOM QUERY alias.field'], $builder->query); $this->assertSame(['value' => 'myValue'], $builder->queryParameters); @@ -62,17 +63,17 @@ public function testFilterMethod(): void 'callback' => [$this, 'customCallback'], ]); - $filter->filter($builder, 'alias', 'field', 'myValue'); + $filter->filter($builder, 'alias', 'field', ['value' => 'myValue']); $this->assertSame(['CUSTOM QUERY alias.field'], $builder->query); $this->assertSame(['value' => 'myValue'], $builder->queryParameters); $this->assertTrue($filter->isActive()); } - public function customCallback($builder, $alias, $field, $value) + public function customCallback(ProxyQueryInterface $query, string $alias, string $field, array $data): bool { - $builder->andWhere(sprintf('CUSTOM QUERY %s.%s', $alias, $field)); - $builder->setParameter('value', $value); + $query->getQueryBuilder()->andWhere(sprintf('CUSTOM QUERY %s.%s', $alias, $field)); + $query->getQueryBuilder()->setParameter('value', $data['value']); return true; } @@ -86,7 +87,7 @@ public function testFilterException(): void $filter = new CallbackFilter(); $filter->initialize('field_name', []); - $filter->filter($builder, 'alias', 'field', 'myValue'); + $filter->filter($builder, 'alias', 'field', ['value' => 'myValue']); } public function testApplyMethod(): void @@ -95,9 +96,9 @@ public function testApplyMethod(): void $filter = new CallbackFilter(); $filter->initialize('field_name_test', [ - 'callback' => static function ($builder, $alias, $field, $value) { - $builder->andWhere(sprintf('CUSTOM QUERY %s.%s', $alias, $field)); - $builder->setParameter('value', $value['value']); + 'callback' => static function (ProxyQueryInterface $query, string $alias, string $field, array $data): bool { + $query->getQueryBuilder()->andWhere(sprintf('CUSTOM QUERY %s.%s', $alias, $field)); + $query->getQueryBuilder()->setParameter('value', $data['value']); return true; }, @@ -122,9 +123,9 @@ public function testWrongCallbackReturnType(): void $filter = new CallbackFilter(); $filter->initialize('field_name', [ - 'callback' => static function ($builder, $alias, $field, $value) { - $builder->andWhere(sprintf('CUSTOM QUERY %s.%s', $alias, $field)); - $builder->setParameter('value', $value); + 'callback' => static function (ProxyQueryInterface $query, string $alias, string $field, array $data) { + $query->getQueryBuilder()->andWhere(sprintf('CUSTOM QUERY %s.%s', $alias, $field)); + $query->getQueryBuilder()->setParameter('value', $data['value']); return 1; }, @@ -134,7 +135,7 @@ public function testWrongCallbackReturnType(): void 'Using another return type than boolean for the callback option is deprecated' .' since sonata-project/doctrine-orm-admin-bundle 3.25 and will throw an exception in version 4.0.' ); - $filter->filter($builder, 'alias', 'field', 'myValue'); + $filter->filter($builder, 'alias', 'field', ['value' => 'myValue']); $this->assertSame(['CUSTOM QUERY alias.field'], $builder->query); $this->assertSame(['value' => 'myValue'], $builder->queryParameters); diff --git a/tests/Filter/ChoiceFilterTest.php b/tests/Filter/ChoiceFilterTest.php index e4eb75544..ee16e0336 100644 --- a/tests/Filter/ChoiceFilterTest.php +++ b/tests/Filter/ChoiceFilterTest.php @@ -36,7 +36,6 @@ public function testFilterEmpty(): void $builder = new ProxyQuery($this->createQueryBuilderStub()); - $filter->filter($builder, 'alias', 'field', null); $filter->filter($builder, 'alias', 'field', []); $this->assertSame([], $builder->query); diff --git a/tests/Filter/ClassFilterTest.php b/tests/Filter/ClassFilterTest.php index a39191d22..3cd4fbb2d 100644 --- a/tests/Filter/ClassFilterTest.php +++ b/tests/Filter/ClassFilterTest.php @@ -36,8 +36,6 @@ public function testFilterEmpty(): void $builder = new ProxyQuery($this->createQueryBuilderStub()); - $filter->filter($builder, 'alias', 'field', null); - $filter->filter($builder, 'alias', 'field', 'asds'); $filter->filter($builder, 'alias', 'field', ['value' => '']); $this->assertSame([], $builder->query); diff --git a/tests/Filter/DateFilterTest.php b/tests/Filter/DateFilterTest.php index d82977ade..2bb818880 100644 --- a/tests/Filter/DateFilterTest.php +++ b/tests/Filter/DateFilterTest.php @@ -29,8 +29,7 @@ public function testEmpty(): void $builder = new ProxyQuery($this->createQueryBuilderStub()); - $filter->filter($builder, 'alias', 'field', null); - $filter->filter($builder, 'alias', 'field', ''); + $filter->filter($builder, 'alias', 'field', []); $this->assertSame([], $builder->query); $this->assertFalse($filter->isActive()); diff --git a/tests/Filter/DateRangeFilterTest.php b/tests/Filter/DateRangeFilterTest.php index 58eb1dd0e..d48b00de3 100644 --- a/tests/Filter/DateRangeFilterTest.php +++ b/tests/Filter/DateRangeFilterTest.php @@ -28,11 +28,6 @@ public function testFilterEmpty(): void $builder = new ProxyQuery($this->createQueryBuilderStub()); - $filter->filter($builder, 'alias', 'field', null); - $filter->filter($builder, 'alias', 'field', ''); - $filter->filter($builder, 'alias', 'field', 'test'); - $filter->filter($builder, 'alias', 'field', false); - $filter->filter($builder, 'alias', 'field', []); $filter->filter($builder, 'alias', 'field', [null, 'test']); $filter->filter($builder, 'alias', 'field', ['type' => null, 'value' => []]); diff --git a/tests/Filter/DateTimeFilterTest.php b/tests/Filter/DateTimeFilterTest.php index d5bea2c7b..e9ccbd029 100644 --- a/tests/Filter/DateTimeFilterTest.php +++ b/tests/Filter/DateTimeFilterTest.php @@ -29,8 +29,6 @@ public function testEmpty(): void $builder = new ProxyQuery($this->createQueryBuilderStub()); - $filter->filter($builder, 'alias', 'field', null); - $filter->filter($builder, 'alias', 'field', ''); $filter->filter($builder, 'alias', 'field', ['value' => '']); $this->assertSame([], $builder->query); diff --git a/tests/Filter/DateTimeRangeFilterTest.php b/tests/Filter/DateTimeRangeFilterTest.php index cd51f0b53..f6129c04b 100644 --- a/tests/Filter/DateTimeRangeFilterTest.php +++ b/tests/Filter/DateTimeRangeFilterTest.php @@ -29,8 +29,7 @@ public function testEmpty(): void $builder = new ProxyQuery($this->createQueryBuilderStub()); - $filter->filter($builder, 'alias', 'field', null); - $filter->filter($builder, 'alias', 'field', ''); + $filter->filter($builder, 'alias', 'field', []); $this->assertSame([], $builder->query); $this->assertFalse($filter->isActive()); diff --git a/tests/Filter/EmptyFilterTest.php b/tests/Filter/EmptyFilterTest.php deleted file mode 100644 index d61f7e206..000000000 --- a/tests/Filter/EmptyFilterTest.php +++ /dev/null @@ -1,82 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Sonata\DoctrineORMAdminBundle\Tests\Filter; - -use Sonata\DoctrineORMAdminBundle\Datagrid\ProxyQuery; -use Sonata\DoctrineORMAdminBundle\Filter\EmptyFilter; -use Sonata\Form\Type\BooleanType; - -/** - * NEXT_MAJOR: Remove this test. - * - * @group legacy - */ -final class EmptyFilterTest extends FilterTestCase -{ - public function testEmpty(): void - { - $filter = new EmptyFilter(); - $filter->initialize('field_name', [ - 'field_options' => ['class' => 'FooBar'], - ]); - - $builder = new ProxyQuery($this->createQueryBuilderStub()); - - $filter->filter($builder, 'alias', 'field', null); - - $this->assertSame([], $builder->query); - $this->assertFalse($filter->isActive()); - } - - /** - * @dataProvider valueDataProvider - */ - public function testValue(bool $inverse, int $value, string $expectedQuery): void - { - $filter = new EmptyFilter(); - $filter->initialize('field_name', [ - 'field_options' => ['class' => 'FooBar'], - 'inverse' => $inverse, - ]); - - $builder = new ProxyQuery($this->createQueryBuilderStub()); - $this->assertSame([], $builder->query); - - $filter->filter($builder, 'alias', 'field', ['value' => $value]); - - $this->assertSame([$expectedQuery], $builder->query); - $this->assertTrue($filter->isActive()); - } - - public function testRenderSettings(): void - { - $filter = new EmptyFilter(); - $filter->initialize('field_name', [ - 'field_options' => ['class' => 'FooBar'], - ]); - $options = $filter->getRenderSettings()[1]; - - $this->assertSame(BooleanType::class, $options['field_type']); - } - - public function valueDataProvider(): array - { - return [ - [false, BooleanType::TYPE_YES, 'alias.field IS NULL'], - [false, BooleanType::TYPE_NO, 'alias.field IS NOT NULL'], - [true, BooleanType::TYPE_YES, 'alias.field IS NOT NULL'], - [true, BooleanType::TYPE_NO, 'alias.field IS NULL'], - ]; - } -} diff --git a/tests/Filter/ModelFilterTest.php b/tests/Filter/ModelFilterTest.php index 9fd78ddc3..749b171f5 100644 --- a/tests/Filter/ModelFilterTest.php +++ b/tests/Filter/ModelFilterTest.php @@ -40,7 +40,6 @@ public function testFilterEmpty(): void $builder = new ProxyQuery($this->createQueryBuilderStub()); - $filter->filter($builder, 'alias', 'field', null); $filter->filter($builder, 'alias', 'field', []); $this->assertSame([], $builder->query); diff --git a/tests/Filter/NullFilterTest.php b/tests/Filter/NullFilterTest.php index 58f1d93e4..3d976b44d 100644 --- a/tests/Filter/NullFilterTest.php +++ b/tests/Filter/NullFilterTest.php @@ -28,7 +28,7 @@ public function testEmpty(): void $builder = new ProxyQuery($this->createQueryBuilderStub()); - $filter->filter($builder, 'alias', 'field', null); + $filter->filter($builder, 'alias', 'field', []); $this->assertSame([], $builder->query); $this->assertFalse($filter->isActive()); diff --git a/tests/Filter/NumberFilterTest.php b/tests/Filter/NumberFilterTest.php index f7ce2fd23..5ad66ba80 100644 --- a/tests/Filter/NumberFilterTest.php +++ b/tests/Filter/NumberFilterTest.php @@ -26,8 +26,7 @@ public function testFilterEmpty(): void $builder = new ProxyQuery($this->createQueryBuilderStub()); - $filter->filter($builder, 'alias', 'field', null); - $filter->filter($builder, 'alias', 'field', 'asds'); + $filter->filter($builder, 'alias', 'field', []); $this->assertSame([], $builder->query); $this->assertFalse($filter->isActive()); diff --git a/tests/Filter/StringFilterTest.php b/tests/Filter/StringFilterTest.php index 5c0b28498..713f4f933 100644 --- a/tests/Filter/StringFilterTest.php +++ b/tests/Filter/StringFilterTest.php @@ -26,8 +26,6 @@ public function testEmpty(): void $builder = new ProxyQuery($this->createQueryBuilderStub()); - $filter->filter($builder, 'alias', 'field', null); - $filter->filter($builder, 'alias', 'field', ''); $filter->filter($builder, 'alias', 'field', []); $this->assertSame([], $builder->query); diff --git a/tests/Filter/StringListFilterTest.php b/tests/Filter/StringListFilterTest.php index 4c7dea653..a84aa38bd 100644 --- a/tests/Filter/StringListFilterTest.php +++ b/tests/Filter/StringListFilterTest.php @@ -26,8 +26,7 @@ public function testItStaysDisabledWhenFilteringWithAnEmptyValue(): void $builder = new ProxyQuery($this->createQueryBuilderStub()); - $filter->filter($builder, 'alias', 'field', null); - $filter->filter($builder, 'alias', 'field', ''); + $filter->filter($builder, 'alias', 'field', []); $this->assertSame([], $builder->query); $this->assertFalse($filter->isActive()); diff --git a/tests/Filter/TimeFilterTest.php b/tests/Filter/TimeFilterTest.php index 25b334fdd..9e0aaea6b 100644 --- a/tests/Filter/TimeFilterTest.php +++ b/tests/Filter/TimeFilterTest.php @@ -29,8 +29,7 @@ public function testEmpty(): void $builder = new ProxyQuery($this->createQueryBuilderStub()); - $filter->filter($builder, 'alias', 'field', null); - $filter->filter($builder, 'alias', 'field', ''); + $filter->filter($builder, 'alias', 'field', []); $filter->filter($builder, 'alias', 'field', ['value' => '']); $this->assertSame([], $builder->query);