DX: fix phpstan errors

This commit is contained in:
Julien Fastré 2023-02-07 23:03:37 +01:00
parent fa481fd795
commit f57555dab4
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
11 changed files with 41 additions and 41 deletions

View File

@ -44,14 +44,7 @@ class UrgencyAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data)
{
$qb->addSelect('cal.urgent AS urgency_aggregator');
$groupBy = $qb->getDQLPart('groupBy');
if (!empty($groupBy)) {
$qb->addGroupBy('urgency_aggregator');
} else {
$qb->groupBy('urgency_aggregator');
}
$qb->addGroupBy('urgency_aggregator');
}
public function applyOn(): string

View File

@ -49,23 +49,11 @@ class CalendarRangeFilter implements FilterInterface
public function alterQuery(QueryBuilder $qb, $data)
{
$where = $qb->getDQLPart('where');
dump($data);
if ($data['hasCalendarRange']) {
$clause = $qb->expr()->isNotNull('cal.calendarRange');
if (null !== $data['hasCalendarRange']) {
$qb->andWhere($qb->expr()->isNotNull('cal.calendarRange'));
} else {
$clause = $qb->expr()->isNull('cal.calendarRange');
$qb->andWhere($qb->expr()->isNull('cal.calendarRange'));
}
if ($where instanceof Andx) {
$where->add($clause);
} else {
$where = $qb->expr()->andX($clause);
}
$qb->add('where', $where);
}
public function applyOn(): string
@ -87,6 +75,8 @@ class CalendarRangeFilter implements FilterInterface
public function describeAction($data, $format = 'string'): array
{
$choice = '';
foreach (self::CHOICES as $k => $v) {
if ($v === $data['hasCalendarRange']) {
$choice = $k;

View File

@ -22,6 +22,9 @@ use Chill\CalendarBundle\Entity\Calendar;
use Chill\CalendarBundle\Messenger\Message\CalendarMessage;
use Chill\CalendarBundle\Messenger\Message\CalendarRemovedMessage;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\ORM\Event\PostPersistEventArgs;
use Doctrine\ORM\Event\PostRemoveEventArgs;
use Doctrine\ORM\Event\PostUpdateEventArgs;
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\Security\Core\Security;
@ -37,7 +40,7 @@ class CalendarEntityListener
$this->security = $security;
}
public function postPersist(Calendar $calendar, LifecycleEventArgs $args): void
public function postPersist(Calendar $calendar, PostPersistEventArgs $args): void
{
if (!$calendar->preventEnqueueChanges) {
$this->messageBus->dispatch(
@ -50,7 +53,7 @@ class CalendarEntityListener
}
}
public function postRemove(Calendar $calendar, LifecycleEventArgs $args): void
public function postRemove(Calendar $calendar, PostRemoveEventArgs $args): void
{
if (!$calendar->preventEnqueueChanges) {
$this->messageBus->dispatch(
@ -62,7 +65,7 @@ class CalendarEntityListener
}
}
public function postUpdate(Calendar $calendar, LifecycleEventArgs $args): void
public function postUpdate(Calendar $calendar, PostUpdateEventArgs $args): void
{
if (!$calendar->preventEnqueueChanges) {
$this->messageBus->dispatch(

View File

@ -22,6 +22,9 @@ use Chill\CalendarBundle\Entity\CalendarRange;
use Chill\CalendarBundle\Messenger\Message\CalendarRangeMessage;
use Chill\CalendarBundle\Messenger\Message\CalendarRangeRemovedMessage;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\ORM\Event\PostPersistEventArgs;
use Doctrine\ORM\Event\PostRemoveEventArgs;
use Doctrine\ORM\Event\PostUpdateEventArgs;
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\Security\Core\Security;
@ -37,7 +40,7 @@ class CalendarRangeEntityListener
$this->security = $security;
}
public function postPersist(CalendarRange $calendarRange, LifecycleEventArgs $eventArgs): void
public function postPersist(CalendarRange $calendarRange, PostPersistEventArgs $eventArgs): void
{
if (!$calendarRange->preventEnqueueChanges) {
$this->messageBus->dispatch(
@ -50,7 +53,7 @@ class CalendarRangeEntityListener
}
}
public function postRemove(CalendarRange $calendarRange, LifecycleEventArgs $eventArgs): void
public function postRemove(CalendarRange $calendarRange, PostRemoveEventArgs $eventArgs): void
{
if (!$calendarRange->preventEnqueueChanges) {
$this->messageBus->dispatch(
@ -62,7 +65,7 @@ class CalendarRangeEntityListener
}
}
public function postUpdate(CalendarRange $calendarRange, LifecycleEventArgs $eventArgs): void
public function postUpdate(CalendarRange $calendarRange, PostUpdateEventArgs $eventArgs): void
{
if (!$calendarRange->preventEnqueueChanges) {
$this->messageBus->dispatch(

View File

@ -110,11 +110,11 @@ class CalendarSyncer
$endDate = RemoteEventConverter::convertStringDateWithoutTimezone($new['end']['dateTime']);
if ($startDate->getTimestamp() !== $calendar->getStartDate()->getTimestamp()) {
$calendar->setStartDate($startDate)->setStatus(Calendar::STATUS_MOVED);
$calendar->setStartDate($startDate);
}
if ($endDate->getTimestamp() !== $calendar->getEndDate()->getTimestamp()) {
$calendar->setEndDate($endDate)->setStatus(Calendar::STATUS_MOVED);
$calendar->setEndDate($endDate);
}
$calendar

View File

@ -17,6 +17,7 @@ use DateTimeImmutable;
use DateTimeInterface;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\ORM\Event\PreFlushEventArgs;
use Doctrine\ORM\Event\PrePersistEventArgs;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
@ -133,7 +134,7 @@ class NotificationComment implements TrackCreationInterface, TrackUpdateInterfac
/**
* @ORM\PrePersist
*/
public function onPrePersist(LifecycleEventArgs $eventArgs): void
public function onPrePersist(PrePersistEventArgs $eventArgs): void
{
$this->recentlyPersisted = true;
}

View File

@ -17,6 +17,8 @@ use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Repository\NotificationRepository;
use Chill\MainBundle\Templating\UI\NotificationCounterInterface;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\ORM\Event\PostPersistEventArgs;
use Doctrine\ORM\Event\PostUpdateEventArgs;
use Doctrine\ORM\Event\PreFlushEventArgs;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\Security\Core\User\UserInterface;
@ -68,7 +70,7 @@ final class NotificationByUserCounter implements NotificationCounterInterface
return 'chill_main_notif_unread_by_' . $user->getId();
}
public function onEditNotificationComment(NotificationComment $notificationComment, LifecycleEventArgs $eventArgs): void
public function onEditNotificationComment(NotificationComment $notificationComment, PostPersistEventArgs $eventArgs): void
{
$this->resetCacheForNotification($notificationComment->getNotification());
}

View File

@ -14,6 +14,8 @@ namespace Chill\MainBundle\Notification\Email;
use Chill\MainBundle\Entity\Notification;
use Chill\MainBundle\Entity\NotificationComment;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\ORM\Event\PostPersistEventArgs;
use Doctrine\ORM\Event\PostUpdateEventArgs;
use Psr\Log\LoggerInterface;
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
@ -36,7 +38,7 @@ class NotificationMailer
$this->translator = $translator;
}
public function postPersistComment(NotificationComment $comment, LifecycleEventArgs $eventArgs): void
public function postPersistComment(NotificationComment $comment, PostPersistEventArgs $eventArgs): void
{
foreach (
array_merge(
@ -72,13 +74,13 @@ class NotificationMailer
/**
* Send a email after a notification is persisted.
*/
public function postPersistNotification(Notification $notification, LifecycleEventArgs $eventArgs): void
public function postPersistNotification(Notification $notification, PostPersistEventArgs $eventArgs): void
{
$this->sendNotificationEmailsToAddresses($notification);
$this->sendNotificationEmailsToAddressesEmails($notification);
}
public function postUpdateNotification(Notification $notification, LifecycleEventArgs $eventArgs): void
public function postUpdateNotification(Notification $notification, PostUpdateEventArgs $eventArgs): void
{
$this->sendNotificationEmailsToAddressesEmails($notification);
}

View File

@ -14,6 +14,8 @@ namespace Chill\PersonBundle\AccompanyingPeriod\SocialIssueConsistency;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\ORM\Event\PrePersistEventArgs;
use Doctrine\ORM\Event\PreUpdateEventArgs;
/**
* This service listens for preUpdate and prePersist events on some entities
@ -26,22 +28,22 @@ use Doctrine\ORM\Event\LifecycleEventArgs;
*/
final class AccompanyingPeriodSocialIssueConsistencyEntityListener
{
public function prePersist(AccompanyingPeriodLinkedWithSocialIssuesEntityInterface $entity, LifecycleEventArgs $eventArgs)
public function prePersist(AccompanyingPeriodLinkedWithSocialIssuesEntityInterface $entity, PrePersistEventArgs $eventArgs)
{
$this->ensureConsistencyEntity($entity);
}
public function prePersistAccompanyingPeriod(AccompanyingPeriod $period, LifecycleEventArgs $eventArgs)
public function prePersistAccompanyingPeriod(AccompanyingPeriod $period, PrePersistEventArgs $eventArgs)
{
$this->ensureConsistencyAccompanyingPeriod($period);
}
public function preUpdate(AccompanyingPeriodLinkedWithSocialIssuesEntityInterface $entity, LifecycleEventArgs $eventArgs)
public function preUpdate(AccompanyingPeriodLinkedWithSocialIssuesEntityInterface $entity, PreUpdateEventArgs $eventArgs)
{
$this->ensureConsistencyEntity($entity);
}
public function preUpdateAccompanyingPeriod(AccompanyingPeriod $period, LifecycleEventArgs $eventArgs)
public function preUpdateAccompanyingPeriod(AccompanyingPeriod $period, PreUpdateEventArgs $eventArgs)
{
$this->ensureConsistencyAccompanyingPeriod($period);
}

View File

@ -51,6 +51,9 @@ use function json_decode;
use const JSON_PRETTY_PRINT;
use const LC_TIME;
/**
* @deprecated, to remove in a next version
*/
final class ImportPeopleFromCSVCommand extends Command
{
protected $cacheAnswersMapping = [];
@ -1021,6 +1024,7 @@ final class ImportPeopleFromCSVCommand extends Command
foreach ($possibleFormats as $format) {
$this->logger->debug("Trying format {$format}", [__METHOD__]);
/** @phpstan-ignore-next-line */
$dateR = strptime($value, $format);
if (is_array($dateR) && '' === $dateR['unparsed']) {

View File

@ -881,7 +881,7 @@ class AccompanyingPeriod implements
/**
* Get a list of all persons which are participating to this course.
*
* @psalm-return Collection<int, Person>
* @psalm-return Collection<(int|string), Person|null>
*/
public function getPersons(): Collection
{