Happyr / Doctrine-Specification

This library gives you a new way for writing queries. Using the Specification pattern you will get small Specification classes that are highly reusable.
MIT License
445 stars 40 forks source link

Revert "Correct PHPStan generic annotation" #307

Closed peter-gribanov closed 3 years ago

peter-gribanov commented 3 years ago

Reverts Happyr/Doctrine-Specification#305

Most of the cases look like:

/** @var array<array-key, JobInterface> $jobs */
$jobs = $this->jobRepository->match(new Running());

But there are cases in which we do not select the entire entity, but only individual fields or something else.

Get only profile info.

/** @var array<array-key, array<string, string>> $profiles */
$profiles = $this->jobRepository->match(Spec::andX(
    Spec::select(
        Spec::field('profile.title'),
        Spec::field('profile.name'),
    ),
    new Running(),
));

Get count jobs in types.

/** @var array<array-key, array<string, string>> $count_types*/
$count_types = $this->jobRepository->match(Spec::andX(
    Spec::select(Spec::selectAs(Spec::COUNT('type'), 'total')),
    Spec::groupBy('type'),
    new Running(),
));

Get related entities.

/** @var array<array-key, Group> $groups */
$groups = $this->jobRepository->match(Spec::andX(
    Spec::select('group'),
    Spec::groupBy('group.id'),
    new Running(),
));