Skip to content

Commit

Permalink
Fix PHPStan
Browse files Browse the repository at this point in the history
Apparently you cannot use `::class` in a `from` when using alternative
namespaces in the `EntityManager`.
  • Loading branch information
tomudding committed Apr 28, 2023
1 parent d4f80b9 commit c17ffb7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
22 changes: 7 additions & 15 deletions module/Report/src/Mapper/Member.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query\Expr\Join;
use Report\Model\Member as MemberModel;
use Report\Model\OrganMember as OrganMemberModel;
use Report\Model\OrganMember;

class Member
{
Expand All @@ -23,11 +23,8 @@ public function __construct(protected readonly EntityManager $em)
*/
public function findSimple(int $lidnr): ?MemberModel
{
$qb = $this->em->createQueryBuilder();

$qb->select('m')
->from(MemberModel::class, 'm')
->where('m.lidnr = :lidnr')
$qb = $this->getRepository()->createQueryBuilder('m');
$qb->where('m.lidnr = :lidnr')
->orderBy('m.lidnr', 'DESC');

$qb->setParameter(':lidnr', $lidnr);
Expand All @@ -42,11 +39,9 @@ public function findSimple(int $lidnr): ?MemberModel
*/
public function findNormal(): array
{
$qb = $this->em->createQueryBuilder();
$qb = $this->getRepository()->createQueryBuilder('m');

$qb->select('m')
->from(MemberModel::class, 'm')
->where('m.expiration >= CURRENT_TIMESTAMP()')
$qb->where('m.expiration >= CURRENT_TIMESTAMP()')
->andWhere('m.hidden = false')
->andWhere('m.deleted = false')
->setMaxResults(32)
Expand All @@ -62,11 +57,8 @@ public function findNormal(): array
*/
public function findActive(bool $includeOrganMembership = false): array
{
$qb = $this->em->createQueryBuilder();

$qb->select('m')
->from(MemberModel::class, 'm')
->leftJoin(OrganMemberModel::class, 'om', Join::WITH, 'm.lidnr = om.member')
$qb = $this->getRepository()->createQueryBuilder('m');
$qb->leftJoin(OrganMember::class, 'om', Join::WITH, 'm.lidnr = om.member')
->where('om.dischargeDate IS NULL OR om.dischargeDate > CURRENT_DATE()')
->andWhere('om.installDate < CURRENT_DATE()')
->andWhere('om.function <> \'\'')
Expand Down
1 change: 1 addition & 0 deletions phpstan/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ parameters:
count: 1
path: ../module/Report/src/Service/Meeting.php
- '#Property User\\Model\\ApiPrincipal\:\:\$permissions type mapping mismatch\: backing type string of enum User\\Model\\Enums\\ApiPermissions does not match database type array.$#'
- '#Property User\\Model\\ApiPrincipal\:\:\$permissions type mapping mismatch\: database can contain User\\Model\\Enums\\ApiPermissions\|null but property expects array\<User\\Model\\Enums\\ApiPermissions\>.$#'
- '#Property User\\Model\\ApiPrincipal\:\:\$permissions type mapping mismatch\: property can contain array but database expects User\\Model\\Enums\\ApiPermissions\|null.$#'

0 comments on commit c17ffb7

Please sign in to comment.