diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 31d64e600..9aae1c43f 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -91,7 +91,7 @@ $rules = array_merge( [ '@PhpCsFixer' => true, '@PhpCsFixer:risky' => false, - '@Symfony' => false, + '@Symfony' => true, '@Symfony:risky' => false, 'ordered_class_elements' => [ 'order' => [ @@ -111,13 +111,13 @@ $rules = array_merge( 'method_private', ], 'sort_algorithm' => 'alpha', - ] + ], ], $rules, $riskyRules, $untilFullSwitchToPhp8, ); -$rules['header_comment']['header'] = trim(file_get_contents(__DIR__ . '/resource/header.txt')); +$rules['header_comment']['header'] = trim(file_get_contents(__DIR__.'/resource/header.txt')); return $config->setRules($rules); diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index 89ff9d3e2..43c0b13bb 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -18,7 +18,6 @@ use Chill\ActivityBundle\Repository\ActivityACLAwareRepositoryInterface; use Chill\ActivityBundle\Repository\ActivityRepository; use Chill\ActivityBundle\Repository\ActivityTypeCategoryRepository; use Chill\ActivityBundle\Repository\ActivityTypeRepositoryInterface; -use Chill\ActivityBundle\Repository\ActivityUserJobRepository; use Chill\ActivityBundle\Security\Authorization\ActivityVoter; use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable; use Chill\MainBundle\Entity\UserJob; @@ -35,11 +34,8 @@ use Chill\PersonBundle\Privacy\PrivacyEvent; use Chill\PersonBundle\Repository\AccompanyingPeriodRepository; use Chill\PersonBundle\Repository\PersonRepository; use Chill\ThirdPartyBundle\Repository\ThirdPartyRepository; -use DateTime; use Doctrine\ORM\EntityManagerInterface; -use InvalidArgumentException; use Psr\Log\LoggerInterface; -use RuntimeException; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\Form\Extension\Core\Type\HiddenType; @@ -49,7 +45,6 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Serializer\SerializerInterface; use Symfony\Contracts\Translation\TranslatorInterface; -use function array_key_exists; final class ActivityController extends AbstractController { @@ -76,6 +71,7 @@ final class ActivityController extends AbstractController /** * Deletes a Activity entity. + * * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/activity/{id}/delete", name="chill_activity_activity_delete", methods={"GET", "POST", "DELETE"}) */ public function deleteAction(Request $request, mixed $id) @@ -102,7 +98,7 @@ final class ActivityController extends AbstractController $form = $this->createDeleteForm($activity->getId(), $person, $accompanyingPeriod); - if ($request->getMethod() === Request::METHOD_DELETE) { + if (Request::METHOD_DELETE === $request->getMethod()) { $form->handleRequest($request); if ($form->isValid()) { @@ -145,6 +141,7 @@ final class ActivityController extends AbstractController /** * Displays a form to edit an existing Activity entity. + * * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/activity/{id}/edit", name="chill_activity_activity_edit", methods={"GET", "POST", "PUT"}) */ public function editAction(int $id, Request $request): Response @@ -239,6 +236,7 @@ final class ActivityController extends AbstractController /** * Lists all Activity entities. + * * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/activity/", name="chill_activity_activity_list") */ public function listAction(Request $request): Response @@ -295,7 +293,7 @@ final class ActivityController extends AbstractController $view = '@ChillActivity/Activity/listAccompanyingCourse.html.twig'; } else { - throw new \LogicException("Unsupported"); + throw new \LogicException('Unsupported'); } return $this->render( @@ -325,19 +323,19 @@ final class ActivityController extends AbstractController ->addEntityChoice('activity_types', 'activity_filter.Types', \Chill\ActivityBundle\Entity\ActivityType::class, $types, [ 'choice_label' => function (\Chill\ActivityBundle\Entity\ActivityType $activityType) { $text = match ($activityType->hasCategory()) { - true => $this->translatableStringHelper->localize($activityType->getCategory()->getName()) . ' > ', + true => $this->translatableStringHelper->localize($activityType->getCategory()->getName()).' > ', false => '', }; - return $text . $this->translatableStringHelper->localize($activityType->getName()); - } + return $text.$this->translatableStringHelper->localize($activityType->getName()); + }, ]); } if (1 < count($jobs)) { $filterBuilder ->addEntityChoice('jobs', 'activity_filter.Jobs', UserJob::class, $jobs, [ - 'choice_label' => fn (UserJob $u) => $this->translatableStringHelper->localize($u->getLabel()) + 'choice_label' => fn (UserJob $u) => $this->translatableStringHelper->localize($u->getLabel()), ]); } @@ -363,7 +361,7 @@ final class ActivityController extends AbstractController $activityType = $this->activityTypeRepository->find($activityType_id); if (isset($activityType) && !$activityType->isActive()) { - throw new InvalidArgumentException('Activity type must be active'); + throw new \InvalidArgumentException('Activity type must be active'); } $activityData = null; @@ -398,45 +396,45 @@ final class ActivityController extends AbstractController } $entity->setActivityType($activityType); - $entity->setDate(new DateTime('now')); + $entity->setDate(new \DateTime('now')); if ($request->query->has('activityData')) { $activityData = $request->query->get('activityData'); - if (array_key_exists('durationTime', $activityData) && $activityType->getDurationTimeVisible() > 0) { + if (\array_key_exists('durationTime', $activityData) && $activityType->getDurationTimeVisible() > 0) { $durationTimeInMinutes = $activityData['durationTime']; $hours = floor($durationTimeInMinutes / 60); $minutes = $durationTimeInMinutes % 60; - $duration = DateTime::createFromFormat('H:i', $hours . ':' . $minutes); + $duration = \DateTime::createFromFormat('H:i', $hours.':'.$minutes); if ($duration) { $entity->setDurationTime($duration); } } - if (array_key_exists('date', $activityData)) { - $date = DateTime::createFromFormat('Y-m-d', $activityData['date']); + if (\array_key_exists('date', $activityData)) { + $date = \DateTime::createFromFormat('Y-m-d', $activityData['date']); if ($date) { $entity->setDate($date); } } - if (array_key_exists('personsId', $activityData) && $activityType->getPersonsVisible() > 0) { + if (\array_key_exists('personsId', $activityData) && $activityType->getPersonsVisible() > 0) { foreach ($activityData['personsId'] as $personId) { $concernedPerson = $this->personRepository->find($personId); $entity->addPerson($concernedPerson); } } - if (array_key_exists('professionalsId', $activityData) && $activityType->getThirdPartiesVisible() > 0) { + if (\array_key_exists('professionalsId', $activityData) && $activityType->getThirdPartiesVisible() > 0) { foreach ($activityData['professionalsId'] as $professionalsId) { $professional = $this->thirdPartyRepository->find($professionalsId); $entity->addThirdParty($professional); } } - if (array_key_exists('usersId', $activityData) && $activityType->getUsersVisible() > 0) { + if (\array_key_exists('usersId', $activityData) && $activityType->getUsersVisible() > 0) { foreach ($activityData['usersId'] as $userId) { $user = $this->userRepository->find($userId); @@ -446,16 +444,16 @@ final class ActivityController extends AbstractController } } - if (array_key_exists('location', $activityData) && $activityType->getLocationVisible() > 0) { + if (\array_key_exists('location', $activityData) && $activityType->getLocationVisible() > 0) { $location = $this->locationRepository->find($activityData['location']); $entity->setLocation($location); } - if (array_key_exists('comment', $activityData) && $activityType->getCommentVisible() > 0) { + if (\array_key_exists('comment', $activityData) && $activityType->getCommentVisible() > 0) { $comment = new CommentEmbeddable(); $comment->setComment($activityData['comment']); $comment->setUserId($this->getUser()->getid()); - $comment->setDate(new DateTime('now')); + $comment->setDate(new \DateTime('now')); $entity->setComment($comment); } } @@ -593,7 +591,7 @@ final class ActivityController extends AbstractController } elseif ($person instanceof Person) { $view = '@ChillActivity/Activity/showPerson.html.twig'; } else { - throw new RuntimeException('the activity should be linked with a period or person'); + throw new \RuntimeException('the activity should be linked with a period or person'); } if (null !== $accompanyingPeriod) { diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityReasonCategoryController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityReasonCategoryController.php index 1a104a3be..6d0b825cc 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityReasonCategoryController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityReasonCategoryController.php @@ -24,6 +24,7 @@ class ActivityReasonCategoryController extends AbstractController { /** * Creates a new ActivityReasonCategory entity. + * * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreasoncategory/create", name="chill_activity_activityreasoncategory_create", methods={"POST"}) */ public function createAction(Request $request) @@ -48,6 +49,7 @@ class ActivityReasonCategoryController extends AbstractController /** * Displays a form to edit an existing ActivityReasonCategory entity. + * * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreasoncategory/{id}/edit", name="chill_activity_activityreasoncategory_edit") */ public function editAction(mixed $id) @@ -70,6 +72,7 @@ class ActivityReasonCategoryController extends AbstractController /** * Lists all ActivityReasonCategory entities. + * * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreasoncategory/", name="chill_activity_activityreasoncategory") */ public function indexAction() @@ -85,6 +88,7 @@ class ActivityReasonCategoryController extends AbstractController /** * Displays a form to create a new ActivityReasonCategory entity. + * * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreasoncategory/new", name="chill_activity_activityreasoncategory_new") */ public function newAction() @@ -100,6 +104,7 @@ class ActivityReasonCategoryController extends AbstractController /** * Finds and displays a ActivityReasonCategory entity. + * * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreasoncategory/{id}/show", name="chill_activity_activityreasoncategory_show") */ public function showAction(mixed $id) @@ -119,6 +124,7 @@ class ActivityReasonCategoryController extends AbstractController /** * Edits an existing ActivityReasonCategory entity. + * * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreasoncategory/{id}/update", name="chill_activity_activityreasoncategory_update", methods={"POST", "PUT"}) */ public function updateAction(Request $request, mixed $id) diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityReasonController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityReasonController.php index 30638340c..141398cc4 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityReasonController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityReasonController.php @@ -28,6 +28,7 @@ class ActivityReasonController extends AbstractController /** * Creates a new ActivityReason entity. + * * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreason/create", name="chill_activity_activityreason_create", methods={"POST"}) */ public function createAction(Request $request) @@ -52,6 +53,7 @@ class ActivityReasonController extends AbstractController /** * Displays a form to edit an existing ActivityReason entity. + * * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreason/{id}/edit", name="chill_activity_activityreason_edit") */ public function editAction(mixed $id) @@ -74,6 +76,7 @@ class ActivityReasonController extends AbstractController /** * Lists all ActivityReason entities. + * * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreason/", name="chill_activity_activityreason") */ public function indexAction() @@ -89,6 +92,7 @@ class ActivityReasonController extends AbstractController /** * Displays a form to create a new ActivityReason entity. + * * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreason/new", name="chill_activity_activityreason_new") */ public function newAction() @@ -104,6 +108,7 @@ class ActivityReasonController extends AbstractController /** * Finds and displays a ActivityReason entity. + * * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreason/{id}/show", name="chill_activity_activityreason_show") */ public function showAction(mixed $id) @@ -123,6 +128,7 @@ class ActivityReasonController extends AbstractController /** * Edits an existing ActivityReason entity. + * * @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreason/{id}/update", name="chill_activity_activityreason_update", methods={"POST", "PUT"}) */ public function updateAction(Request $request, mixed $id) diff --git a/src/Bundle/ChillActivityBundle/Controller/AdminActivityPresenceController.php b/src/Bundle/ChillActivityBundle/Controller/AdminActivityPresenceController.php index 3a39ca072..8a1ccda44 100644 --- a/src/Bundle/ChillActivityBundle/Controller/AdminActivityPresenceController.php +++ b/src/Bundle/ChillActivityBundle/Controller/AdminActivityPresenceController.php @@ -24,7 +24,7 @@ class AdminActivityPresenceController extends CRUDController */ protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator) { - /** @var \Doctrine\ORM\QueryBuilder $query */ + /* @var \Doctrine\ORM\QueryBuilder $query */ return $query->orderBy('e.id', 'ASC'); } } diff --git a/src/Bundle/ChillActivityBundle/Controller/AdminActivityTypeCategoryController.php b/src/Bundle/ChillActivityBundle/Controller/AdminActivityTypeCategoryController.php index 666f8721c..887749406 100644 --- a/src/Bundle/ChillActivityBundle/Controller/AdminActivityTypeCategoryController.php +++ b/src/Bundle/ChillActivityBundle/Controller/AdminActivityTypeCategoryController.php @@ -24,7 +24,7 @@ class AdminActivityTypeCategoryController extends CRUDController */ protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator) { - /** @var \Doctrine\ORM\QueryBuilder $query */ + /* @var \Doctrine\ORM\QueryBuilder $query */ return $query->orderBy('e.ordering', 'ASC'); } } diff --git a/src/Bundle/ChillActivityBundle/Controller/AdminActivityTypeController.php b/src/Bundle/ChillActivityBundle/Controller/AdminActivityTypeController.php index 5f245e9c4..ff75e5909 100644 --- a/src/Bundle/ChillActivityBundle/Controller/AdminActivityTypeController.php +++ b/src/Bundle/ChillActivityBundle/Controller/AdminActivityTypeController.php @@ -24,7 +24,7 @@ class AdminActivityTypeController extends CRUDController */ protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator) { - /** @var \Doctrine\ORM\QueryBuilder $query */ + /* @var \Doctrine\ORM\QueryBuilder $query */ return $query->orderBy('e.ordering', 'ASC') ->addOrderBy('e.id', 'ASC'); } diff --git a/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivityReason.php b/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivityReason.php index d006a624c..af674be9e 100644 --- a/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivityReason.php +++ b/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivityReason.php @@ -52,13 +52,13 @@ class LoadActivityReason extends AbstractFixture implements OrderedFixtureInterf ]; foreach ($reasons as $r) { - echo 'Creating activity reason : ' . $r['name']['en'] . "\n"; + echo 'Creating activity reason : '.$r['name']['en']."\n"; $activityReason = (new ActivityReason()) - ->setName(($r['name'])) + ->setName($r['name']) ->setActive(true) ->setCategory($this->getReference($r['category'])); $manager->persist($activityReason); - $reference = 'activity_reason_' . $r['name']['en']; + $reference = 'activity_reason_'.$r['name']['en']; $this->addReference($reference, $activityReason); static::$references[] = $reference; } diff --git a/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivityReasonCategory.php b/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivityReasonCategory.php index 63d9a2ee0..a78ae3972 100644 --- a/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivityReasonCategory.php +++ b/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivityReasonCategory.php @@ -34,13 +34,13 @@ class LoadActivityReasonCategory extends AbstractFixture implements OrderedFixtu ]; foreach ($categs as $c) { - echo 'Creating activity reason category : ' . $c['name']['en'] . "\n"; + echo 'Creating activity reason category : '.$c['name']['en']."\n"; $activityReasonCategory = (new ActivityReasonCategory()) - ->setName(($c['name'])) + ->setName($c['name']) ->setActive(true); $manager->persist($activityReasonCategory); $this->addReference( - 'cat_' . $c['name']['en'], + 'cat_'.$c['name']['en'], $activityReasonCategory ); } diff --git a/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivityType.php b/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivityType.php index d0cd9d2be..891f2c979 100644 --- a/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivityType.php +++ b/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivityType.php @@ -54,14 +54,14 @@ class LoadActivityType extends Fixture implements OrderedFixtureInterface ]; foreach ($types as $t) { - echo 'Creating activity type : ' . $t['name']['fr'] . ' (cat:' . $t['category'] . " \n"; + echo 'Creating activity type : '.$t['name']['fr'].' (cat:'.$t['category']." \n"; $activityType = (new ActivityType()) - ->setName(($t['name'])) - ->setCategory($this->getReference('activity_type_cat_' . $t['category'])) + ->setName($t['name']) + ->setCategory($this->getReference('activity_type_cat_'.$t['category'])) ->setSocialIssuesVisible(1) ->setSocialActionsVisible(1); $manager->persist($activityType); - $reference = 'activity_type_' . $t['name']['fr']; + $reference = 'activity_type_'.$t['name']['fr']; $this->addReference($reference, $activityType); static::$references[] = $reference; } diff --git a/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivityTypeCategory.php b/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivityTypeCategory.php index 4fb5a3e38..2f15a2676 100644 --- a/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivityTypeCategory.php +++ b/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivityTypeCategory.php @@ -42,13 +42,13 @@ class LoadActivityTypeCategory extends Fixture implements OrderedFixtureInterfac ]; foreach ($categories as $cat) { - echo 'Creating activity type category : ' . $cat['ref'] . "\n"; + echo 'Creating activity type category : '.$cat['ref']."\n"; $newCat = (new ActivityTypeCategory()) - ->setName(($cat['name'])); + ->setName($cat['name']); $manager->persist($newCat); - $reference = 'activity_type_cat_' . $cat['ref']; + $reference = 'activity_type_cat_'.$cat['ref']; $this->addReference($reference, $newCat); static::$references[] = $reference; diff --git a/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivitytACL.php b/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivitytACL.php index 0ffb2ed0e..e7c893cd9 100644 --- a/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivitytACL.php +++ b/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivitytACL.php @@ -20,8 +20,6 @@ use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Persistence\ObjectManager; -use function in_array; - /** * Add a role CHILL_ACTIVITY_UPDATE & CHILL_ACTIVITY_CREATE for all groups except administrative, * and a role CHILL_ACTIVITY_SEE for administrative. @@ -40,10 +38,10 @@ class LoadActivitytACL extends AbstractFixture implements OrderedFixtureInterfac foreach (LoadScopes::$references as $scopeRef) { $scope = $this->getReference($scopeRef); - //create permission group + // create permission group switch ($permissionsGroup->getName()) { case 'social': - if ($scope->getName()['en'] === 'administrative') { + if ('administrative' === $scope->getName()['en']) { break 2; // we do not want any power on administrative } @@ -51,7 +49,7 @@ class LoadActivitytACL extends AbstractFixture implements OrderedFixtureInterfac case 'administrative': case 'direction': - if (in_array($scope->getName()['en'], ['administrative', 'social'], true)) { + if (\in_array($scope->getName()['en'], ['administrative', 'social'], true)) { break 2; // we do not want any power on social or administrative } @@ -60,7 +58,7 @@ class LoadActivitytACL extends AbstractFixture implements OrderedFixtureInterfac printf( 'Adding CHILL_ACTIVITY_UPDATE & CHILL_ACTIVITY_CREATE & CHILL_ACTIVITY_DELETE, and stats and list permissions to %s ' - . "permission group, scope '%s' \n", + ."permission group, scope '%s' \n", $permissionsGroup->getName(), $scope->getName()['en'] ); diff --git a/src/Bundle/ChillActivityBundle/DependencyInjection/ChillActivityExtension.php b/src/Bundle/ChillActivityBundle/DependencyInjection/ChillActivityExtension.php index 49b3927ed..15e7e7e4b 100644 --- a/src/Bundle/ChillActivityBundle/DependencyInjection/ChillActivityExtension.php +++ b/src/Bundle/ChillActivityBundle/DependencyInjection/ChillActivityExtension.php @@ -32,7 +32,7 @@ class ChillActivityExtension extends Extension implements PrependExtensionInterf $container->setParameter('chill_activity.form.time_duration', $config['form']['time_duration']); - $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../config')); + $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../config')); $loader->load('services.yaml'); $loader->load('services/export.yaml'); $loader->load('services/repositories.yaml'); @@ -73,7 +73,7 @@ class ChillActivityExtension extends Extension implements PrependExtensionInterf */ public function prependRoutes(ContainerBuilder $container) { - //add routes for custom bundle + // add routes for custom bundle $container->prependExtensionConfig('chill_main', [ 'routing' => [ 'resources' => [ diff --git a/src/Bundle/ChillActivityBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillActivityBundle/DependencyInjection/Configuration.php index 57a1ec578..112d49f60 100644 --- a/src/Bundle/ChillActivityBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillActivityBundle/DependencyInjection/Configuration.php @@ -13,7 +13,6 @@ namespace Chill\ActivityBundle\DependencyInjection; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; - use function is_int; /** @@ -59,7 +58,7 @@ class Configuration implements ConfigurationInterface ->info('The number of seconds of this duration. Must be an integer.') ->cannotBeEmpty() ->validate() - ->ifTrue(static fn ($data) => !is_int($data))->thenInvalid('The value %s is not a valid integer') + ->ifTrue(static fn ($data) => !\is_int($data))->thenInvalid('The value %s is not a valid integer') ->end() ->end() ->scalarNode('label') diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index 1cf783e0b..9407aecbe 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -36,7 +36,6 @@ use DateTime; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; -use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Serializer\Annotation\DiscriminatorMap; use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Serializer\Annotation\SerializedName; @@ -46,11 +45,15 @@ use Symfony\Component\Validator\Constraints as Assert; * Class Activity. * * @ORM\Entity(repositoryClass="Chill\ActivityBundle\Repository\ActivityRepository") + * * @ORM\Table(name="activity") + * * @ORM\HasLifecycleCallbacks + * * @DiscriminatorMap(typeProperty="type", mapping={ * "activity": Activity::class * }) + * * @ActivityValidator\ActivityValidity * * TODO see if necessary @@ -71,39 +74,48 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac /** * @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod") + * * @Groups({"read"}) */ private ?AccompanyingPeriod $accompanyingPeriod = null; /** * @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityType") + * * @Groups({"read", "docgen:read"}) + * * @SerializedName("activityType") + * * @ORM\JoinColumn(name="type_id") */ private ActivityType $activityType; /** * @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityPresence") + * * @Groups({"docgen:read"}) */ private ?ActivityPresence $attendee = null; /** * @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\CommentEmbeddable", columnPrefix="comment_") + * * @Groups({"docgen:read"}) */ private CommentEmbeddable $comment; /** * @ORM\Column(type="datetime") + * * @Groups({"docgen:read"}) */ - private DateTime $date; + private \DateTime $date; /** * @ORM\ManyToMany(targetEntity="Chill\DocStoreBundle\Entity\StoredObject", cascade={"persist"}) + * * @Assert\Valid(traverse=true) + * * @var Collection */ private Collection $documents; @@ -111,24 +123,29 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac /** * @ORM\Column(type="time", nullable=true) */ - private ?DateTime $durationTime = null; + private ?\DateTime $durationTime = null; /** * @ORM\Column(type="boolean", options={"default": false}) + * * @Groups({"docgen:read"}) */ private bool $emergency = false; /** * @ORM\Id + * * @ORM\Column(name="id", type="integer") + * * @ORM\GeneratedValue(strategy="AUTO") + * * @Groups({"read", "docgen:read"}) */ private ?int $id = null; /** * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Location") + * * @groups({"read", "docgen:read"}) */ private ?Location $location = null; @@ -140,7 +157,9 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac /** * @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\Person") + * * @Groups({"read", "docgen:read"}) + * * @var Collection */ private Collection $persons; @@ -152,42 +171,54 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac /** * @ORM\ManyToMany(targetEntity="Chill\ActivityBundle\Entity\ActivityReason") + * * @Groups({"docgen:read"}) + * * @var Collection */ private Collection $reasons; /** * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Scope") + * * @Groups({"docgen:read"}) */ private ?Scope $scope = null; /** * @ORM\Column(type="string", options={"default": ""}) + * * @Groups({"docgen:read"}) */ private string $sentReceived = ''; /** * @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\SocialWork\SocialAction") + * * @ORM\JoinTable(name="chill_activity_activity_chill_person_socialaction") + * * @Groups({"read", "docgen:read"}) + * * @var Collection */ private Collection $socialActions; /** * @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\SocialWork\SocialIssue") + * * @ORM\JoinTable(name="chill_activity_activity_chill_person_socialissue") + * * @Groups({"read", "docgen:read"}) + * * @var Collection */ private Collection $socialIssues; /** * @ORM\ManyToMany(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty") + * * @Groups({"read", "docgen:read"}) + * * @var Collection */ private Collection $thirdParties; @@ -195,17 +226,20 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac /** * @ORM\Column(type="time", nullable=true) */ - private ?DateTime $travelTime = null; + private ?\DateTime $travelTime = null; /** * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User") + * * @Groups({"docgen:read"}) */ private ?User $user = null; /** * @ORM\ManyToMany(targetEntity="Chill\MainBundle\Entity\User") + * * @Groups({"read", "docgen:read"}) + * * @var Collection */ private Collection $users; @@ -275,7 +309,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac $this->socialIssues[] = $socialIssue; } - if ($this->getAccompanyingPeriod() !== null) { + if (null !== $this->getAccompanyingPeriod()) { $this->getAccompanyingPeriod()->addSocialIssue($socialIssue); } @@ -341,7 +375,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac return $this->comment; } - public function getDate(): DateTime + public function getDate(): \DateTime { return $this->date; } @@ -363,7 +397,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac return (int) round(($this->durationTime->getTimestamp() + $this->durationTime->getOffset()) / 60.0, 0); } - public function getDurationTime(): ?DateTime + public function getDurationTime(): ?\DateTime { return $this->durationTime; } @@ -417,7 +451,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac // TODO better semantic with: return $this->persons->filter(...); foreach ($this->persons as $person) { - if ($this->accompanyingPeriod->getOpenParticipationContainsPerson($person) === null) { + if (null === $this->accompanyingPeriod->getOpenParticipationContainsPerson($person)) { $personsNotAssociated[] = $person; } } @@ -476,7 +510,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac return $this->thirdParties; } - public function getTravelTime(): ?DateTime + public function getTravelTime(): ?\DateTime { return $this->travelTime; } @@ -587,7 +621,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac return $this; } - public function setDate(DateTime $date): self + public function setDate(\DateTime $date): self { $this->date = $date; @@ -601,7 +635,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac return $this; } - public function setDurationTime(?DateTime $durationTime): self + public function setDurationTime(?\DateTime $durationTime): self { $this->durationTime = $durationTime; @@ -671,7 +705,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac return $this; } - public function setTravelTime(DateTime $travelTime): self + public function setTravelTime(\DateTime $travelTime): self { $this->travelTime = $travelTime; diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityPresence.php b/src/Bundle/ChillActivityBundle/Entity/ActivityPresence.php index b0154e509..c181b7c6b 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityPresence.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityPresence.php @@ -18,7 +18,9 @@ use Symfony\Component\Serializer\Annotation as Serializer; * Class ActivityPresence. * * @ORM\Entity + * * @ORM\Table(name="activitytpresence") + * * @ORM\HasLifecycleCallbacks */ class ActivityPresence @@ -30,15 +32,20 @@ class ActivityPresence /** * @ORM\Id + * * @ORM\Column(name="id", type="integer") + * * @ORM\GeneratedValue(strategy="AUTO") + * * @Serializer\Groups({"docgen:read"}) */ private ?int $id = null; /** * @ORM\Column(type="json") + * * @Serializer\Groups({"docgen:read"}) + * * @Serializer\Context({"is-translatable": true}, groups={"docgen:read"}) */ private array $name = []; diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityReason.php b/src/Bundle/ChillActivityBundle/Entity/ActivityReason.php index 99504f469..90d088f6f 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityReason.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityReason.php @@ -17,7 +17,9 @@ use Doctrine\ORM\Mapping as ORM; * Class ActivityReason. * * @ORM\Entity + * * @ORM\Table(name="activityreason") + * * @ORM\HasLifecycleCallbacks */ class ActivityReason @@ -28,7 +30,6 @@ class ActivityReason private bool $active = true; /** - * @var ActivityReasonCategory * @ORM\ManyToOne( * targetEntity="Chill\ActivityBundle\Entity\ActivityReasonCategory", * inversedBy="reasons") @@ -36,16 +37,15 @@ class ActivityReason private ?ActivityReasonCategory $category = null; /** - * @var int - * * @ORM\Id + * * @ORM\Column(name="id", type="integer") + * * @ORM\GeneratedValue(strategy="AUTO") */ private ?int $id = null; /** - * @var array * @ORM\Column(type="json") */ private array $name; diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityReasonCategory.php b/src/Bundle/ChillActivityBundle/Entity/ActivityReasonCategory.php index 65a414758..64d7f9672 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityReasonCategory.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityReasonCategory.php @@ -19,7 +19,9 @@ use Doctrine\ORM\Mapping as ORM; * Class ActivityReasonCategory. * * @ORM\Entity + * * @ORM\Table(name="activityreasoncategory") + * * @ORM\HasLifecycleCallbacks */ class ActivityReasonCategory implements \Stringable @@ -30,16 +32,17 @@ class ActivityReasonCategory implements \Stringable private bool $active = true; /** - * @var int - * * @ORM\Id + * * @ORM\Column(name="id", type="integer") + * * @ORM\GeneratedValue(strategy="AUTO") */ private ?int $id = null; /** * @var string + * * @ORM\Column(type="json") */ private $name; @@ -48,6 +51,7 @@ class ActivityReasonCategory implements \Stringable * Array of ActivityReason. * * @var Collection + * * @ORM\OneToMany( * targetEntity="Chill\ActivityBundle\Entity\ActivityReason", * mappedBy="category") @@ -62,12 +66,9 @@ class ActivityReasonCategory implements \Stringable $this->reasons = new ArrayCollection(); } - /** - * @return string - */ public function __toString(): string { - return 'ActivityReasonCategory(' . $this->getName('x') . ')'; + return 'ActivityReasonCategory('.$this->getName('x').')'; } /** diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php index aa6598b0b..c14c8292b 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php @@ -12,7 +12,6 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Entity; use Doctrine\ORM\Mapping as ORM; -use InvalidArgumentException; use Symfony\Component\Serializer\Annotation as Serializer; use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Validator\Constraints as Assert; @@ -22,7 +21,9 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface; * Class ActivityType. * * @ORM\Entity + * * @ORM\Table(name="activitytype") + * * @ORM\HasLifecycleCallbacks */ class ActivityType @@ -35,18 +36,21 @@ class ActivityType /** * @deprecated not in use + * * @ORM\Column(type="string", nullable=false, options={"default": ""}) */ private string $accompanyingPeriodLabel = ''; /** * @deprecated not in use + * * @ORM\Column(type="smallint", nullable=false, options={"default": 1}) */ private int $accompanyingPeriodVisible = self::FIELD_INVISIBLE; /** * @ORM\Column(type="boolean") + * * @Groups({"read"}) */ private bool $active = true; @@ -118,8 +122,11 @@ class ActivityType /** * @ORM\Id + * * @ORM\Column(name="id", type="integer") + * * @ORM\GeneratedValue(strategy="AUTO") + * * @Groups({"docgen:read"}) */ private ?int $id = null; @@ -136,7 +143,9 @@ class ActivityType /** * @ORM\Column(type="json") + * * @Groups({"read", "docgen:read"}) + * * @Serializer\Context({"is-translatable": true}, groups={"docgen:read"}) */ private array $name = []; @@ -158,6 +167,7 @@ class ActivityType /** * @ORM\Column(type="smallint", nullable=false, options={"default": 1}) + * * @Groups({"read"}) */ private int $personsVisible = self::FIELD_OPTIONAL; @@ -238,6 +248,7 @@ class ActivityType /** * @ORM\Column(type="smallint", nullable=false, options={"default": 1}) + * * @Groups({"read"}) */ private int $thirdPartiesVisible = self::FIELD_INVISIBLE; @@ -264,6 +275,7 @@ class ActivityType /** * @ORM\Column(type="smallint", nullable=false, options={"default": 1}) + * * @Groups({"read"}) */ private int $usersVisible = self::FIELD_OPTIONAL; @@ -372,13 +384,13 @@ class ActivityType public function getLabel(string $field): ?string { - $property = $field . 'Label'; + $property = $field.'Label'; if (!property_exists($this, $property)) { - throw new InvalidArgumentException('Field "' . $field . '" not found'); + throw new \InvalidArgumentException('Field "'.$field.'" not found'); } - /** @phpstan-ignore-next-line */ + /* @phpstan-ignore-next-line */ return $this->{$property}; } @@ -531,25 +543,25 @@ class ActivityType public function isRequired(string $field): bool { - $property = $field . 'Visible'; + $property = $field.'Visible'; if (!property_exists($this, $property)) { - throw new InvalidArgumentException('Field "' . $field . '" not found'); + throw new \InvalidArgumentException('Field "'.$field.'" not found'); } - /** @phpstan-ignore-next-line */ + /* @phpstan-ignore-next-line */ return self::FIELD_REQUIRED === $this->{$property}; } public function isVisible(string $field): bool { - $property = $field . 'Visible'; + $property = $field.'Visible'; if (!property_exists($this, $property)) { - throw new InvalidArgumentException('Field "' . $field . '" not found'); + throw new \InvalidArgumentException('Field "'.$field.'" not found'); } - /** @phpstan-ignore-next-line */ + /* @phpstan-ignore-next-line */ return self::FIELD_INVISIBLE !== $this->{$property}; } diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityTypeCategory.php b/src/Bundle/ChillActivityBundle/Entity/ActivityTypeCategory.php index 2cf6972c7..680a15fa7 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityTypeCategory.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityTypeCategory.php @@ -15,7 +15,9 @@ use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity + * * @ORM\Table(name="activitytypecategory") + * * @ORM\HasLifecycleCallbacks */ class ActivityTypeCategory @@ -27,7 +29,9 @@ class ActivityTypeCategory /** * @ORM\Id + * * @ORM\Column(name="id", type="integer") + * * @ORM\GeneratedValue(strategy="AUTO") */ private ?int $id = null; diff --git a/src/Bundle/ChillActivityBundle/EntityListener/ActivityEntityListener.php b/src/Bundle/ChillActivityBundle/EntityListener/ActivityEntityListener.php index d2ae3bf9b..31fac3be8 100644 --- a/src/Bundle/ChillActivityBundle/EntityListener/ActivityEntityListener.php +++ b/src/Bundle/ChillActivityBundle/EntityListener/ActivityEntityListener.php @@ -15,11 +15,8 @@ use Chill\ActivityBundle\Entity\Activity; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork; use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository; -use DateTimeImmutable; use Doctrine\ORM\EntityManagerInterface; -use function in_array; - class ActivityEntityListener { public function __construct(private readonly EntityManagerInterface $em, private readonly AccompanyingPeriodWorkRepository $workRepository) {} @@ -31,11 +28,11 @@ class ActivityEntityListener $accompanyingCourseWorks = $this->workRepository->findByAccompanyingPeriod($period); $periodActions = []; - $now = new DateTimeImmutable(); + $now = new \DateTimeImmutable(); foreach ($accompanyingCourseWorks as $key => $work) { // take only the actions which are still opened - if ($work->getEndDate() === null || $work->getEndDate() > ($activity->getDate() ?? $now)) { + if (null === $work->getEndDate() || $work->getEndDate() > ($activity->getDate() ?? $now)) { $periodActions[$key] = spl_object_hash($work->getSocialAction()); } } @@ -44,14 +41,14 @@ class ActivityEntityListener $associatedThirdparties = $activity->getThirdParties(); foreach ($activity->getSocialActions() as $action) { - if (in_array(spl_object_hash($action), $periodActions, true)) { + if (\in_array(spl_object_hash($action), $periodActions, true)) { continue; } $newAction = new AccompanyingPeriodWork(); $newAction->setSocialAction($action); $period->addWork($newAction); - $date = DateTimeImmutable::createFromMutable($activity->getDate()); + $date = \DateTimeImmutable::createFromMutable($activity->getDate()); $newAction->setStartDate($date); foreach ($associatedPersons as $person) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByActivityNumberAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByActivityNumberAggregator.php index c23db738e..e9e8fb474 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByActivityNumberAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByActivityNumberAggregator.php @@ -27,7 +27,7 @@ class ByActivityNumberAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data): void { $qb - ->addSelect('(SELECT COUNT(activity.id) FROM ' . Activity::class . ' activity WHERE activity.accompanyingPeriod = acp) AS activity_by_number_aggregator') + ->addSelect('(SELECT COUNT(activity.id) FROM '.Activity::class.' activity WHERE activity.accompanyingPeriod = acp) AS activity_by_number_aggregator') ->addGroupBy('activity_by_number_aggregator'); } @@ -40,6 +40,7 @@ class ByActivityNumberAggregator implements AggregatorInterface { // No form needed } + public function getFormDefaultData(): array { return []; diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php index 320152008..9282f92e4 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php @@ -17,7 +17,6 @@ use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository; use Chill\PersonBundle\Templating\Entity\SocialActionRender; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; -use function in_array; class BySocialActionAggregator implements AggregatorInterface { @@ -30,7 +29,7 @@ class BySocialActionAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('actsocialaction', $qb->getAllAliases(), true)) { + if (!\in_array('actsocialaction', $qb->getAllAliases(), true)) { $qb->leftJoin('activity.socialActions', 'actsocialaction'); } @@ -47,6 +46,7 @@ class BySocialActionAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array { return []; diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php index 240a555b5..bbdadf4d6 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php @@ -17,7 +17,6 @@ use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository; use Chill\PersonBundle\Templating\Entity\SocialIssueRender; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; -use function in_array; class BySocialIssueAggregator implements AggregatorInterface { @@ -30,7 +29,7 @@ class BySocialIssueAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('actsocialissue', $qb->getAllAliases(), true)) { + if (!\in_array('actsocialissue', $qb->getAllAliases(), true)) { $qb->leftJoin('activity.socialIssues', 'actsocialissue'); } @@ -47,6 +46,7 @@ class BySocialIssueAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array { return []; diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityLocationAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityLocationAggregator.php index 9103943e4..ab07afca7 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityLocationAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityLocationAggregator.php @@ -12,14 +12,9 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Export\Aggregator; use Chill\ActivityBundle\Export\Declarations; -use Chill\ActivityBundle\Repository\ActivityTypeRepositoryInterface; use Chill\MainBundle\Export\AggregatorInterface; -use Chill\MainBundle\Repository\LocationRepository; -use Chill\MainBundle\Templating\TranslatableStringHelperInterface; -use Closure; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; -use function in_array; final readonly class ActivityLocationAggregator implements AggregatorInterface { @@ -32,7 +27,7 @@ final readonly class ActivityLocationAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('actloc', $qb->getAllAliases(), true)) { + if (!\in_array('actloc', $qb->getAllAliases(), true)) { $qb->leftJoin('activity.location', 'actloc'); } $qb->addSelect(sprintf('actloc.name AS %s', self::KEY)); @@ -48,12 +43,13 @@ final readonly class ActivityLocationAggregator implements AggregatorInterface { // no form required for this aggregator } + public function getFormDefaultData(): array { return []; } - public function getLabels($key, array $values, $data): Closure + public function getLabels($key, array $values, $data): \Closure { return function ($value): string { if ('_header' === $value) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php index 4d0ad4ac1..fa658635b 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php @@ -15,10 +15,8 @@ use Chill\ActivityBundle\Export\Declarations; use Chill\ActivityBundle\Repository\ActivityTypeRepositoryInterface; use Chill\MainBundle\Export\AggregatorInterface; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; -use Closure; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; -use function in_array; class ActivityTypeAggregator implements AggregatorInterface { @@ -33,7 +31,7 @@ class ActivityTypeAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('acttype', $qb->getAllAliases(), true)) { + if (!\in_array('acttype', $qb->getAllAliases(), true)) { $qb->leftJoin('activity.activityType', 'acttype'); } @@ -50,12 +48,13 @@ class ActivityTypeAggregator implements AggregatorInterface { // no form required for this aggregator } + public function getFormDefaultData(): array { return []; } - public function getLabels($key, array $values, $data): Closure + public function getLabels($key, array $values, $data): \Closure { // for performance reason, we load data from db only once $this->activityTypeRepository->findBy(['id' => $values]); diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php index 79ba09eb9..61452af22 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php @@ -15,7 +15,6 @@ use Chill\ActivityBundle\Export\Declarations; use Chill\MainBundle\Export\AggregatorInterface; use Chill\MainBundle\Repository\UserRepository; use Chill\MainBundle\Templating\Entity\UserRender; -use Closure; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; @@ -48,12 +47,13 @@ class ActivityUserAggregator implements AggregatorInterface { // nothing to add } + public function getFormDefaultData(): array { return []; } - public function getLabels($key, $values, $data): Closure + public function getLabels($key, $values, $data): \Closure { return function ($value) { if ('_header' === $value) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersAggregator.php index 3bad88f4e..cc4ab9d14 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersAggregator.php @@ -17,7 +17,6 @@ use Chill\MainBundle\Repository\UserRepositoryInterface; use Chill\MainBundle\Templating\Entity\UserRender; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; -use function in_array; class ActivityUsersAggregator implements AggregatorInterface { @@ -30,7 +29,7 @@ class ActivityUsersAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('actusers', $qb->getAllAliases(), true)) { + if (!\in_array('actusers', $qb->getAllAliases(), true)) { $qb->leftJoin('activity.users', 'actusers'); } @@ -48,6 +47,7 @@ class ActivityUsersAggregator implements AggregatorInterface { // nothing to add on the form } + public function getFormDefaultData(): array { return []; diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersJobAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersJobAggregator.php index af4ed7352..3628206ec 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersJobAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersJobAggregator.php @@ -39,7 +39,7 @@ class ActivityUsersJobAggregator implements AggregatorInterface $p = self::PREFIX; $qb - ->leftJoin("activity.users", "{$p}_user") + ->leftJoin('activity.users', "{$p}_user") ->leftJoin( UserJobHistory::class, "{$p}_history", @@ -49,10 +49,10 @@ class ActivityUsersJobAggregator implements AggregatorInterface // job_at based on activity.date ->andWhere( $qb->expr()->andX( - $qb->expr()->lte("{$p}_history.startDate", "activity.date"), + $qb->expr()->lte("{$p}_history.startDate", 'activity.date'), $qb->expr()->orX( $qb->expr()->isNull("{$p}_history.endDate"), - $qb->expr()->gt("{$p}_history.endDate", "activity.date") + $qb->expr()->gt("{$p}_history.endDate", 'activity.date') ) ) ) @@ -93,7 +93,7 @@ class ActivityUsersJobAggregator implements AggregatorInterface public function getQueryKeys($data): array { - return [self::PREFIX . '_select']; + return [self::PREFIX.'_select']; } public function getTitle(): string diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersScopeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersScopeAggregator.php index aeb021cf1..bffce629f 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersScopeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersScopeAggregator.php @@ -39,7 +39,7 @@ class ActivityUsersScopeAggregator implements AggregatorInterface $p = self::PREFIX; $qb - ->leftJoin("activity.users", "{$p}_user") + ->leftJoin('activity.users', "{$p}_user") ->leftJoin( UserScopeHistory::class, "{$p}_history", @@ -49,10 +49,10 @@ class ActivityUsersScopeAggregator implements AggregatorInterface // scope_at based on activity.date ->andWhere( $qb->expr()->andX( - $qb->expr()->lte("{$p}_history.startDate", "activity.date"), + $qb->expr()->lte("{$p}_history.startDate", 'activity.date'), $qb->expr()->orX( $qb->expr()->isNull("{$p}_history.endDate"), - $qb->expr()->gt("{$p}_history.endDate", "activity.date") + $qb->expr()->gt("{$p}_history.endDate", 'activity.date') ) ) ) @@ -93,7 +93,7 @@ class ActivityUsersScopeAggregator implements AggregatorInterface public function getQueryKeys($data): array { - return [self::PREFIX . '_select']; + return [self::PREFIX.'_select']; } public function getTitle(): string diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ByCreatorAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ByCreatorAggregator.php index 17fdaa7c0..09bdab89e 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ByCreatorAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ByCreatorAggregator.php @@ -42,6 +42,7 @@ class ByCreatorAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array { return []; diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ByThirdpartyAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ByThirdpartyAggregator.php index 3190c6bda..13224bade 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ByThirdpartyAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ByThirdpartyAggregator.php @@ -17,7 +17,6 @@ use Chill\ThirdPartyBundle\Repository\ThirdPartyRepository; use Chill\ThirdPartyBundle\Templating\Entity\ThirdPartyRender; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; -use function in_array; class ByThirdpartyAggregator implements AggregatorInterface { @@ -30,7 +29,7 @@ class ByThirdpartyAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('acttparty', $qb->getAllAliases(), true)) { + if (!\in_array('acttparty', $qb->getAllAliases(), true)) { $qb->leftJoin('activity.thirdParties', 'acttparty'); } @@ -47,6 +46,7 @@ class ByThirdpartyAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array { return []; diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/CreatorScopeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/CreatorScopeAggregator.php index e2357bd7d..6641f0807 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/CreatorScopeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/CreatorScopeAggregator.php @@ -39,7 +39,7 @@ class CreatorScopeAggregator implements AggregatorInterface $p = self::PREFIX; $qb - ->leftJoin("activity.createdBy", "{$p}_user") + ->leftJoin('activity.createdBy', "{$p}_user") ->leftJoin( UserScopeHistory::class, "{$p}_history", @@ -49,10 +49,10 @@ class CreatorScopeAggregator implements AggregatorInterface // scope_at based on activity.date ->andWhere( $qb->expr()->andX( - $qb->expr()->lte("{$p}_history.startDate", "activity.date"), + $qb->expr()->lte("{$p}_history.startDate", 'activity.date'), $qb->expr()->orX( $qb->expr()->isNull("{$p}_history.endDate"), - $qb->expr()->gt("{$p}_history.endDate", "activity.date") + $qb->expr()->gt("{$p}_history.endDate", 'activity.date') ) ) ) @@ -93,7 +93,7 @@ class CreatorScopeAggregator implements AggregatorInterface public function getQueryKeys($data): array { - return [self::PREFIX . '_select']; + return [self::PREFIX.'_select']; } public function getTitle(): string diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/DateAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/DateAggregator.php index f0a02dadd..f7315140e 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/DateAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/DateAggregator.php @@ -14,10 +14,8 @@ namespace Chill\ActivityBundle\Export\Aggregator; use Chill\ActivityBundle\Export\Declarations; use Chill\MainBundle\Export\AggregatorInterface; use Doctrine\ORM\QueryBuilder; -use RuntimeException; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Contracts\Translation\TranslatorInterface; class DateAggregator implements AggregatorInterface { @@ -56,7 +54,7 @@ class DateAggregator implements AggregatorInterface break; // order DESC does not works ! default: - throw new RuntimeException(sprintf("The frequency data '%s' is invalid.", $data['frequency'])); + throw new \RuntimeException(sprintf("The frequency data '%s' is invalid.", $data['frequency'])); } $qb->addSelect(sprintf("TO_CHAR(activity.date, '%s') AS date_aggregator", $fmt)); @@ -78,6 +76,7 @@ class DateAggregator implements AggregatorInterface 'empty_data' => self::DEFAULT_CHOICE, ]); } + public function getFormDefaultData(): array { return ['frequency' => self::DEFAULT_CHOICE]; @@ -87,7 +86,7 @@ class DateAggregator implements AggregatorInterface { return static function ($value) use ($data): string { if ('_header' === $value) { - return 'by ' . $data['frequency']; + return 'by '.$data['frequency']; } if (null === $value) { diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/JobScopeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/JobScopeAggregator.php index 251f67b36..e43f430d5 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/JobScopeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/JobScopeAggregator.php @@ -13,7 +13,6 @@ namespace Chill\ActivityBundle\Export\Aggregator; use Chill\ActivityBundle\Export\Declarations; use Chill\MainBundle\Entity\User\UserJobHistory; -use Chill\MainBundle\Entity\User\UserScopeHistory; use Chill\MainBundle\Export\AggregatorInterface; use Chill\MainBundle\Repository\ScopeRepository; use Chill\MainBundle\Templating\TranslatableStringHelper; @@ -40,7 +39,7 @@ class JobScopeAggregator implements AggregatorInterface $p = self::PREFIX; $qb - ->leftJoin("activity.createdBy", "{$p}_user") + ->leftJoin('activity.createdBy', "{$p}_user") ->leftJoin( UserJobHistory::class, "{$p}_history", @@ -50,10 +49,10 @@ class JobScopeAggregator implements AggregatorInterface // job_at based on activity.date ->andWhere( $qb->expr()->andX( - $qb->expr()->lte("{$p}_history.startDate", "activity.date"), + $qb->expr()->lte("{$p}_history.startDate", 'activity.date'), $qb->expr()->orX( $qb->expr()->isNull("{$p}_history.endDate"), - $qb->expr()->gt("{$p}_history.endDate", "activity.date") + $qb->expr()->gt("{$p}_history.endDate", 'activity.date') ) ) ) @@ -94,7 +93,7 @@ class JobScopeAggregator implements AggregatorInterface public function getQueryKeys($data): array { - return [self::PREFIX . '_select']; + return [self::PREFIX.'_select']; } public function getTitle(): string diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/LocationTypeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/LocationTypeAggregator.php index e302a2569..da2d74f64 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/LocationTypeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/LocationTypeAggregator.php @@ -17,7 +17,6 @@ use Chill\MainBundle\Repository\LocationTypeRepository; use Chill\MainBundle\Templating\TranslatableStringHelper; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; -use function in_array; class LocationTypeAggregator implements AggregatorInterface { @@ -30,7 +29,7 @@ class LocationTypeAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('actloc', $qb->getAllAliases(), true)) { + if (!\in_array('actloc', $qb->getAllAliases(), true)) { $qb->leftJoin('activity.location', 'actloc'); } @@ -47,6 +46,7 @@ class LocationTypeAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array { return []; diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/PersonAggregators/ActivityReasonAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/PersonAggregators/ActivityReasonAggregator.php index c83738c19..4b1f4894e 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/PersonAggregators/ActivityReasonAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/PersonAggregators/ActivityReasonAggregator.php @@ -17,17 +17,12 @@ use Chill\ActivityBundle\Repository\ActivityReasonRepository; use Chill\MainBundle\Export\AggregatorInterface; use Chill\MainBundle\Export\ExportElementValidatedInterface; use Chill\MainBundle\Templating\TranslatableStringHelper; -use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Doctrine\ORM\Query\Expr\Join; use Doctrine\ORM\QueryBuilder; -use RuntimeException; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Validator\Context\ExecutionContextInterface; -use function count; -use function in_array; - class ActivityReasonAggregator implements AggregatorInterface, ExportElementValidatedInterface { public function __construct(protected ActivityReasonCategoryRepository $activityReasonCategoryRepository, protected ActivityReasonRepository $activityReasonRepository, protected TranslatableStringHelper $translatableStringHelper) {} @@ -47,20 +42,20 @@ class ActivityReasonAggregator implements AggregatorInterface, ExportElementVali $elem = 'actreasoncat.id'; $alias = 'activity_categories_id'; } else { - throw new RuntimeException('The data provided are not recognized.'); + throw new \RuntimeException('The data provided are not recognized.'); } - $qb->addSelect($elem . ' as ' . $alias); + $qb->addSelect($elem.' as '.$alias); // make a jointure only if needed - if (!in_array('actreasons', $qb->getAllAliases(), true)) { + if (!\in_array('actreasons', $qb->getAllAliases(), true)) { $qb->innerJoin('activity.reasons', 'actreasons'); } // join category if necessary if ('activity_categories_id' === $alias) { // add join only if needed - if (!in_array('actreasoncat', $qb->getAllAliases(), true)) { + if (!\in_array('actreasoncat', $qb->getAllAliases(), true)) { $qb->join('actreasons.category', 'actreasoncat'); } } @@ -68,7 +63,7 @@ class ActivityReasonAggregator implements AggregatorInterface, ExportElementVali // add the "group by" part $groupBy = $qb->getDQLPart('groupBy'); - if (count($groupBy) > 0) { + if (\count($groupBy) > 0) { $qb->addGroupBy($alias); } else { $qb->groupBy($alias); @@ -96,6 +91,7 @@ class ActivityReasonAggregator implements AggregatorInterface, ExportElementVali ] ); } + public function getFormDefaultData(): array { return []; @@ -106,7 +102,7 @@ class ActivityReasonAggregator implements AggregatorInterface, ExportElementVali match ($data['level']) { 'reasons' => $this->activityReasonRepository->findBy(['id' => $values]), 'categories' => $this->activityReasonCategoryRepository->findBy(['id' => $values]), - default => throw new RuntimeException(sprintf("The level data '%s' is invalid.", $data['level'])), + default => throw new \RuntimeException(sprintf("The level data '%s' is invalid.", $data['level'])), }; return function ($value) use ($data) { @@ -147,7 +143,7 @@ class ActivityReasonAggregator implements AggregatorInterface, ExportElementVali return ['activity_categories_id']; } - throw new RuntimeException('The data provided are not recognised.'); + throw new \RuntimeException('The data provided are not recognised.'); } public function getTitle() diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/SentReceivedAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/SentReceivedAggregator.php index 379826ba0..774968544 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/SentReceivedAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/SentReceivedAggregator.php @@ -14,7 +14,6 @@ namespace Chill\ActivityBundle\Export\Aggregator; use Chill\ActivityBundle\Export\Declarations; use Chill\MainBundle\Export\AggregatorInterface; use Doctrine\ORM\QueryBuilder; -use LogicException; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Contracts\Translation\TranslatorInterface; @@ -42,6 +41,7 @@ class SentReceivedAggregator implements AggregatorInterface { // No form needed } + public function getFormDefaultData(): array { return []; @@ -66,7 +66,7 @@ class SentReceivedAggregator implements AggregatorInterface return $this->translator->trans('export.aggregator.activity.by_sent_received.is received'); default: - throw new LogicException(sprintf('The value %s is not valid', $value)); + throw new \LogicException(sprintf('The value %s is not valid', $value)); } }; } diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php index 352a67014..9cdbc183d 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php @@ -24,7 +24,6 @@ use Chill\PersonBundle\Export\Declarations as PersonDeclarations; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Query; -use LogicException; use Symfony\Component\Form\FormBuilderInterface; class AvgActivityDuration implements ExportInterface, GroupedExportInterface @@ -38,6 +37,7 @@ class AvgActivityDuration implements ExportInterface, GroupedExportInterface } public function buildForm(FormBuilderInterface $builder) {} + public function getFormDefaultData(): array { return []; @@ -61,7 +61,7 @@ class AvgActivityDuration implements ExportInterface, GroupedExportInterface public function getLabels($key, array $values, $data) { if ('export_avg_activity_duration' !== $key) { - throw new LogicException("the key {$key} is not used by this export"); + throw new \LogicException("the key {$key} is not used by this export"); } return static fn ($value) => '_header' === $value ? 'Average activities linked to an accompanying period duration' : $value; @@ -101,8 +101,8 @@ class AvgActivityDuration implements ExportInterface, GroupedExportInterface $qb ->andWhere( $qb->expr()->exists( - 'SELECT 1 FROM ' . AccompanyingPeriodParticipation::class . ' acl_count_part - JOIN ' . PersonCenterHistory::class . ' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person) + 'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part + JOIN '.PersonCenterHistory::class.' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person) WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers) ' ) diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php index 4101408cc..58ac6e829 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php @@ -24,7 +24,6 @@ use Chill\PersonBundle\Export\Declarations as PersonDeclarations; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Query; -use LogicException; use Symfony\Component\Form\FormBuilderInterface; class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterface @@ -41,6 +40,7 @@ class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterfac { // TODO: Implement buildForm() method. } + public function getFormDefaultData(): array { return []; @@ -64,7 +64,7 @@ class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterfac public function getLabels($key, array $values, $data) { if ('export_avg_activity_visit_duration' !== $key) { - throw new LogicException("the key {$key} is not used by this export"); + throw new \LogicException("the key {$key} is not used by this export"); } return static fn ($value) => '_header' === $value ? 'Average activities linked to an accompanying period visit duration' : $value; @@ -104,8 +104,8 @@ class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterfac $qb ->andWhere( $qb->expr()->exists( - 'SELECT 1 FROM ' . AccompanyingPeriodParticipation::class . ' acl_count_part - JOIN ' . PersonCenterHistory::class . ' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person) + 'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part + JOIN '.PersonCenterHistory::class.' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person) WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers) ' ) diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php index 4926ecc33..39c79cf1f 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php @@ -24,7 +24,6 @@ use Chill\PersonBundle\Export\Declarations as PersonDeclarations; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Query; -use LogicException; use Symfony\Component\Form\FormBuilderInterface; class CountActivity implements ExportInterface, GroupedExportInterface @@ -38,6 +37,7 @@ class CountActivity implements ExportInterface, GroupedExportInterface } public function buildForm(FormBuilderInterface $builder) {} + public function getFormDefaultData(): array { return []; @@ -61,7 +61,7 @@ class CountActivity implements ExportInterface, GroupedExportInterface public function getLabels($key, array $values, $data) { if ('export_count_activity' !== $key) { - throw new LogicException("the key {$key} is not used by this export"); + throw new \LogicException("the key {$key} is not used by this export"); } return static fn ($value) => '_header' === $value ? 'Number of activities linked to an accompanying period' : $value; @@ -98,8 +98,8 @@ class CountActivity implements ExportInterface, GroupedExportInterface $qb ->andWhere( $qb->expr()->exists( - 'SELECT 1 FROM ' . AccompanyingPeriodParticipation::class . ' acl_count_part - JOIN ' . PersonCenterHistory::class . ' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person) + 'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part + JOIN '.PersonCenterHistory::class.' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person) WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers) ' ) diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php index 4d57a31ec..45233d97f 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/ListActivity.php @@ -32,6 +32,7 @@ class ListActivity implements ListInterface, GroupedExportInterface { $this->helper->buildForm($builder); } + public function getFormDefaultData(): array { return []; @@ -44,7 +45,7 @@ class ListActivity implements ListInterface, GroupedExportInterface public function getDescription() { - return ListActivityHelper::MSG_KEY . 'List activities linked to an accompanying course'; + return ListActivityHelper::MSG_KEY.'List activities linked to an accompanying course'; } public function getGroup(): string @@ -57,12 +58,12 @@ class ListActivity implements ListInterface, GroupedExportInterface return match ($key) { 'acpId' => static function ($value) { if ('_header' === $value) { - return ListActivityHelper::MSG_KEY . 'accompanying course id'; + return ListActivityHelper::MSG_KEY.'accompanying course id'; } return $value ?? ''; }, - 'scopesNames' => $this->translatableStringExportLabelHelper->getLabelMulti($key, $values, ListActivityHelper::MSG_KEY . 'course circles'), + 'scopesNames' => $this->translatableStringExportLabelHelper->getLabelMulti($key, $values, ListActivityHelper::MSG_KEY.'course circles'), default => $this->helper->getLabels($key, $values, $data), }; } @@ -86,7 +87,7 @@ class ListActivity implements ListInterface, GroupedExportInterface public function getTitle() { - return ListActivityHelper::MSG_KEY . 'List activity linked to a course'; + return ListActivityHelper::MSG_KEY.'List activity linked to a course'; } public function getType() @@ -110,7 +111,7 @@ class ListActivity implements ListInterface, GroupedExportInterface ->andWhere( $qb->expr()->exists( 'SELECT 1 - FROM ' . PersonCenterHistory::class . ' acl_count_person_history + FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person AND acl_count_person_history.center IN (:authorized_centers) ' @@ -127,7 +128,7 @@ class ListActivity implements ListInterface, GroupedExportInterface // add select for this step $qb ->addSelect('acp.id AS acpId') - ->addSelect('(SELECT AGGREGATE(acpScope.name) FROM ' . Scope::class . ' acpScope WHERE acpScope MEMBER OF acp.scopes) AS scopesNames') + ->addSelect('(SELECT AGGREGATE(acpScope.name) FROM '.Scope::class.' acpScope WHERE acpScope MEMBER OF acp.scopes) AS scopesNames') ->addGroupBy('scopesNames'); AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php index d9022f10e..a8d6f10fd 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php @@ -24,7 +24,6 @@ use Chill\PersonBundle\Export\Declarations as PersonDeclarations; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Query; -use LogicException; use Symfony\Component\Form\FormBuilderInterface; class SumActivityDuration implements ExportInterface, GroupedExportInterface @@ -41,6 +40,7 @@ class SumActivityDuration implements ExportInterface, GroupedExportInterface { // TODO: Implement buildForm() method. } + public function getFormDefaultData(): array { return []; @@ -64,7 +64,7 @@ class SumActivityDuration implements ExportInterface, GroupedExportInterface public function getLabels($key, array $values, $data) { if ('export_sum_activity_duration' !== $key) { - throw new LogicException("the key {$key} is not used by this export"); + throw new \LogicException("the key {$key} is not used by this export"); } return static fn ($value) => '_header' === $value ? 'Sum activities linked to an accompanying period duration' : $value; @@ -104,8 +104,8 @@ class SumActivityDuration implements ExportInterface, GroupedExportInterface $qb ->andWhere( $qb->expr()->exists( - 'SELECT 1 FROM ' . AccompanyingPeriodParticipation::class . ' acl_count_part - JOIN ' . PersonCenterHistory::class . ' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person) + 'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part + JOIN '.PersonCenterHistory::class.' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person) WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers) ' ) diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php index 81cbddc8e..dae572ba5 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php @@ -24,7 +24,6 @@ use Chill\PersonBundle\Export\Declarations as PersonDeclarations; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Query; -use LogicException; use Symfony\Component\Form\FormBuilderInterface; class SumActivityVisitDuration implements ExportInterface, GroupedExportInterface @@ -41,6 +40,7 @@ class SumActivityVisitDuration implements ExportInterface, GroupedExportInterfac { // TODO: Implement buildForm() method. } + public function getFormDefaultData(): array { return []; @@ -64,7 +64,7 @@ class SumActivityVisitDuration implements ExportInterface, GroupedExportInterfac public function getLabels($key, array $values, $data) { if ('export_sum_activity_visit_duration' !== $key) { - throw new LogicException("the key {$key} is not used by this export"); + throw new \LogicException("the key {$key} is not used by this export"); } return static fn ($value) => '_header' === $value ? 'Sum activities linked to an accompanying period visit duration' : $value; @@ -104,8 +104,8 @@ class SumActivityVisitDuration implements ExportInterface, GroupedExportInterfac $qb ->andWhere( $qb->expr()->exists( - 'SELECT 1 FROM ' . AccompanyingPeriodParticipation::class . ' acl_count_part - JOIN ' . PersonCenterHistory::class . ' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person) + 'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part + JOIN '.PersonCenterHistory::class.' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person) WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers) ' ) diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php index d24385ea8..dbc7e3fde 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php @@ -19,7 +19,6 @@ use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; use Chill\PersonBundle\Export\Declarations as PersonDeclarations; use Doctrine\ORM\Query; -use LogicException; use Symfony\Component\Form\FormBuilderInterface; class CountActivity implements ExportInterface, GroupedExportInterface @@ -27,6 +26,7 @@ class CountActivity implements ExportInterface, GroupedExportInterface public function __construct(protected ActivityRepository $activityRepository) {} public function buildForm(FormBuilderInterface $builder) {} + public function getFormDefaultData(): array { return []; @@ -50,7 +50,7 @@ class CountActivity implements ExportInterface, GroupedExportInterface public function getLabels($key, array $values, $data) { if ('export_count_activity' !== $key) { - throw new LogicException("the key {$key} is not used by this export"); + throw new \LogicException("the key {$key} is not used by this export"); } return static fn ($value) => '_header' === $value ? 'Number of activities linked to a person' : $value; diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php index f31e3faf8..50b8ace2a 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php @@ -20,7 +20,6 @@ use Chill\MainBundle\Export\GroupedExportInterface; use Chill\MainBundle\Export\ListInterface; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Chill\PersonBundle\Export\Declarations as PersonDeclarations; -use DateTime; use Doctrine\DBAL\Exception\InvalidArgumentException; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Query; @@ -30,10 +29,6 @@ use Symfony\Component\Validator\Constraints\Callback; use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Contracts\Translation\TranslatorInterface; -use function array_key_exists; -use function count; -use function in_array; - class ListActivity implements ListInterface, GroupedExportInterface { protected array $fields = [ @@ -61,7 +56,7 @@ class ListActivity implements ListInterface, GroupedExportInterface 'label' => 'Fields to include in export', 'constraints' => [new Callback([ 'callback' => static function ($selected, ExecutionContextInterface $context) { - if (count($selected) === 0) { + if (0 === \count($selected)) { $context->buildViolation('You must select at least one element') ->atPath('fields') ->addViolation(); @@ -70,6 +65,7 @@ class ListActivity implements ListInterface, GroupedExportInterface ])], ]); } + public function getFormDefaultData(): array { return []; @@ -99,7 +95,7 @@ class ListActivity implements ListInterface, GroupedExportInterface return 'date'; } - $date = DateTime::createFromFormat('Y-m-d H:i:s', $value); + $date = \DateTime::createFromFormat('Y-m-d H:i:s', $value); return $date->format('d-m-Y'); }; @@ -123,11 +119,11 @@ class ListActivity implements ListInterface, GroupedExportInterface $activity = $activityRepository->find($value); - return implode(', ', array_map(fn (ActivityReason $r) => '"' . + return implode(', ', array_map(fn (ActivityReason $r) => '"'. $this->translatableStringHelper->localize($r->getCategory()->getName()) - . ' > ' . + .' > '. $this->translatableStringHelper->localize($r->getName()) - . '"', $activity->getReasons()->toArray())); + .'"', $activity->getReasons()->toArray())); }; case 'circle_name': @@ -184,7 +180,7 @@ class ListActivity implements ListInterface, GroupedExportInterface $centers = array_map(static fn ($el) => $el['center'], $acl); // throw an error if any fields are present - if (!array_key_exists('fields', $data)) { + if (!\array_key_exists('fields', $data)) { throw new InvalidArgumentException('Any fields have been checked.'); } @@ -208,7 +204,7 @@ class ListActivity implements ListInterface, GroupedExportInterface ->setParameter('centers', $centers); foreach ($this->fields as $f) { - if (in_array($f, $data['fields'], true)) { + if (\in_array($f, $data['fields'], true)) { switch ($f) { case 'id': $qb->addSelect('activity.id AS id'); diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php index e4ecbc963..6f254bb08 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php @@ -20,7 +20,6 @@ use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; use Chill\PersonBundle\Export\Declarations as PersonDeclarations; use Doctrine\ORM\Query; -use LogicException; use Symfony\Component\Form\FormBuilderInterface; /** @@ -44,6 +43,7 @@ class StatActivityDuration implements ExportInterface, GroupedExportInterface ) {} public function buildForm(FormBuilderInterface $builder) {} + public function getFormDefaultData(): array { return []; @@ -60,7 +60,7 @@ class StatActivityDuration implements ExportInterface, GroupedExportInterface return 'Sum activities linked to a person duration by various parameters.'; } - throw new LogicException('this action is not supported: ' . $this->action); + throw new \LogicException('this action is not supported: '.$this->action); } public function getGroup(): string @@ -71,7 +71,7 @@ class StatActivityDuration implements ExportInterface, GroupedExportInterface public function getLabels($key, array $values, $data) { if ('export_stat_activity' !== $key) { - throw new LogicException(sprintf('The key %s is not used by this export', $key)); + throw new \LogicException(sprintf('The key %s is not used by this export', $key)); } $header = self::SUM === $this->action ? 'Sum activities linked to a person duration' : false; @@ -95,7 +95,7 @@ class StatActivityDuration implements ExportInterface, GroupedExportInterface return 'Sum activity linked to a person duration'; } - throw new LogicException('This action is not supported: ' . $this->action); + throw new \LogicException('This action is not supported: '.$this->action); } public function getType(): string diff --git a/src/Bundle/ChillActivityBundle/Export/Export/ListActivityHelper.php b/src/Bundle/ChillActivityBundle/Export/Export/ListActivityHelper.php index ea43d387d..75d2c3fd0 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/ListActivityHelper.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/ListActivityHelper.php @@ -23,10 +23,8 @@ use Chill\PersonBundle\Export\Helper\LabelPersonHelper; use Chill\ThirdPartyBundle\Export\Helper\LabelThirdPartyHelper; use Doctrine\ORM\AbstractQuery; use Doctrine\ORM\QueryBuilder; -use LogicException; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Contracts\Translation\TranslatorInterface; -use const SORT_NUMERIC; class ListActivityHelper { @@ -88,7 +86,7 @@ class ListActivityHelper return match ($key) { 'createdAt', 'updatedAt' => $this->dateTimeHelper->getLabel($key), 'createdBy', 'updatedBy' => $this->userHelper->getLabel($key, $values, $key), - 'date' => $this->dateTimeHelper->getLabel(self::MSG_KEY . $key), + 'date' => $this->dateTimeHelper->getLabel(self::MSG_KEY.$key), 'attendeeName' => function ($value) { if ('_header' === $value) { return 'Attendee'; @@ -112,13 +110,13 @@ class ListActivityHelper return $this->translatableStringHelper->localize($type->getName()); }, - 'usersNames' => $this->userHelper->getLabelMulti($key, $values, self::MSG_KEY . 'users name'), + 'usersNames' => $this->userHelper->getLabelMulti($key, $values, self::MSG_KEY.'users name'), 'usersIds', 'thirdPartiesIds', 'personsIds' => static function ($value) use ($key) { if ('_header' === $value) { return match ($key) { - 'usersIds' => self::MSG_KEY . 'users ids', - 'thirdPartiesIds' => self::MSG_KEY . 'third parties ids', - 'personsIds' => self::MSG_KEY . 'persons ids', + 'usersIds' => self::MSG_KEY.'users ids', + 'thirdPartiesIds' => self::MSG_KEY.'third parties ids', + 'personsIds' => self::MSG_KEY.'persons ids', }; } @@ -128,15 +126,15 @@ class ListActivityHelper '|', array_unique( array_filter($decoded, static fn (?int $id) => null !== $id), - SORT_NUMERIC + \SORT_NUMERIC ) ); }, - 'personsNames' => $this->labelPersonHelper->getLabelMulti($key, $values, self::MSG_KEY . 'persons name'), - 'thirdPartiesNames' => $this->labelThirdPartyHelper->getLabelMulti($key, $values, self::MSG_KEY . 'thirds parties'), + 'personsNames' => $this->labelPersonHelper->getLabelMulti($key, $values, self::MSG_KEY.'persons name'), + 'thirdPartiesNames' => $this->labelThirdPartyHelper->getLabelMulti($key, $values, self::MSG_KEY.'thirds parties'), 'sentReceived' => function ($value) { if ('_header' === $value) { - return self::MSG_KEY . 'sent received'; + return self::MSG_KEY.'sent received'; } if (null === $value) { @@ -147,7 +145,7 @@ class ListActivityHelper }, default => function ($value) use ($key) { if ('_header' === $value) { - return self::MSG_KEY . $key; + return self::MSG_KEY.$key; } if (null === $value) { diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php index bfa492fb9..31a29c2eb 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php @@ -37,7 +37,7 @@ class ActivityTypeFilter implements FilterInterface { $qb->andWhere( $qb->expr()->exists( - 'SELECT 1 FROM ' . Activity::class . ' act_type_filter_activity + 'SELECT 1 FROM '.Activity::class.' act_type_filter_activity WHERE act_type_filter_activity.activityType IN (:act_type_filter_activity_types) AND act_type_filter_activity.accompanyingPeriod = acp' ) ); @@ -54,13 +54,14 @@ class ActivityTypeFilter implements FilterInterface $builder->add('accepted_activitytypes', EntityType::class, [ 'class' => ActivityType::class, 'choices' => $this->activityTypeRepository->findAllActive(), - 'choice_label' => fn (ActivityType $aty) => ($aty->hasCategory() ? $this->translatableStringHelper->localize($aty->getCategory()->getName()) . ' > ' : '') + 'choice_label' => fn (ActivityType $aty) => ($aty->hasCategory() ? $this->translatableStringHelper->localize($aty->getCategory()->getName()).' > ' : '') . $this->translatableStringHelper->localize($aty->getName()), 'multiple' => true, 'expanded' => true, ]); } + public function getFormDefaultData(): array { return []; diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php index 067947b26..13349baa5 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php @@ -18,7 +18,6 @@ use Chill\PersonBundle\Form\Type\PickSocialActionType; use Chill\PersonBundle\Templating\Entity\SocialActionRender; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; -use function in_array; class BySocialActionFilter implements FilterInterface { @@ -31,7 +30,7 @@ class BySocialActionFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('actsocialaction', $qb->getAllAliases(), true)) { + if (!\in_array('actsocialaction', $qb->getAllAliases(), true)) { $qb->join('activity.socialActions', 'actsocialaction'); } @@ -55,6 +54,7 @@ class BySocialActionFilter implements FilterInterface 'multiple' => true, ]); } + public function getFormDefaultData(): array { return []; diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php index a45253b2c..bef40290e 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php @@ -18,7 +18,6 @@ use Chill\PersonBundle\Form\Type\PickSocialIssueType; use Chill\PersonBundle\Templating\Entity\SocialIssueRender; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; -use function in_array; class BySocialIssueFilter implements FilterInterface { @@ -31,7 +30,7 @@ class BySocialIssueFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('actsocialissue', $qb->getAllAliases(), true)) { + if (!\in_array('actsocialissue', $qb->getAllAliases(), true)) { $qb->join('activity.socialIssues', 'actsocialissue'); } @@ -55,6 +54,7 @@ class BySocialIssueFilter implements FilterInterface 'multiple' => true, ]); } + public function getFormDefaultData(): array { return []; diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/HasNoActivityFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/HasNoActivityFilter.php index ab7331a65..afd708d33 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/HasNoActivityFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/HasNoActivityFilter.php @@ -18,7 +18,7 @@ use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; /** - * Filter accompanying periods to keep only the one without any activity + * Filter accompanying periods to keep only the one without any activity. */ class HasNoActivityFilter implements FilterInterface { @@ -32,7 +32,7 @@ class HasNoActivityFilter implements FilterInterface $qb ->andWhere(' NOT EXISTS ( - SELECT 1 FROM ' . Activity::class . ' activity + SELECT 1 FROM '.Activity::class.' activity WHERE activity.accompanyingPeriod = acp ) '); @@ -45,8 +45,9 @@ class HasNoActivityFilter implements FilterInterface public function buildForm(FormBuilderInterface $builder) { - //no form needed + // no form needed } + public function getFormDefaultData(): array { return []; diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/PeriodHavingActivityBetweenDatesFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/PeriodHavingActivityBetweenDatesFilter.php index 20d0452fa..2d3282ad1 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/PeriodHavingActivityBetweenDatesFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/PeriodHavingActivityBetweenDatesFilter.php @@ -34,10 +34,10 @@ final readonly class PeriodHavingActivityBetweenDatesFilter implements FilterInt { $builder ->add('start_date', PickRollingDateType::class, [ - 'label' => 'export.filter.activity.course_having_activity_between_date.Receiving an activity after' + 'label' => 'export.filter.activity.course_having_activity_between_date.Receiving an activity after', ]) ->add('end_date', PickRollingDateType::class, [ - 'label' => 'export.filter.activity.course_having_activity_between_date.Receiving an activity before' + 'label' => 'export.filter.activity.course_having_activity_between_date.Receiving an activity before', ]); } @@ -45,7 +45,7 @@ final readonly class PeriodHavingActivityBetweenDatesFilter implements FilterInt { return [ 'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START), - 'end_date' => new RollingDate(RollingDate::T_TODAY) + 'end_date' => new RollingDate(RollingDate::T_TODAY), ]; } @@ -56,7 +56,7 @@ final readonly class PeriodHavingActivityBetweenDatesFilter implements FilterInt [ 'from' => $this->rollingDateConverter->convert($data['start_date']), 'to' => $this->rollingDateConverter->convert($data['end_date']), - ] + ], ]; } @@ -73,7 +73,7 @@ final readonly class PeriodHavingActivityBetweenDatesFilter implements FilterInt $qb->andWhere( $qb->expr()->exists( - 'SELECT 1 FROM ' . Activity::class . " {$alias} WHERE {$alias}.date >= :{$from} AND {$alias}.date < :{$to} AND {$alias}.accompanyingPeriod = acp" + 'SELECT 1 FROM '.Activity::class." {$alias} WHERE {$alias}.date >= :{$from} AND {$alias}.date < :{$to} AND {$alias}.accompanyingPeriod = acp" ) ); diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php index a572f4a65..a67d0155d 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php @@ -90,14 +90,14 @@ class ActivityDateFilter implements FilterInterface if (null === $date_from) { $form->get('date_from')->addError(new FormError( $this->translator->trans('This field ' - . 'should not be empty') + .'should not be empty') )); } if (null === $date_to) { $form->get('date_to')->addError(new FormError( $this->translator->trans('This field ' - . 'should not be empty') + .'should not be empty') )); } @@ -108,13 +108,14 @@ class ActivityDateFilter implements FilterInterface ) { $form->get('date_to')->addError(new FormError( $this->translator->trans('This date should be after ' - . 'the date given in "Implied in an activity after ' - . 'this date" field') + .'the date given in "Implied in an activity after ' + .'this date" field') )); } } }); } + public function getFormDefaultData(): array { return ['date_from' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), 'date_to' => new RollingDate(RollingDate::T_TODAY)]; diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php index a0b121c3d..43f9ba0da 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php @@ -22,8 +22,6 @@ use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Validator\Context\ExecutionContextInterface; -use function count; - class ActivityTypeFilter implements ExportElementValidatedInterface, FilterInterface { public function __construct( @@ -54,7 +52,7 @@ class ActivityTypeFilter implements ExportElementValidatedInterface, FilterInter $builder->add('types', EntityType::class, [ 'choices' => $this->activityTypeRepository->findAllActive(), 'class' => ActivityType::class, - 'choice_label' => fn (ActivityType $aty) => ($aty->hasCategory() ? $this->translatableStringHelper->localize($aty->getCategory()->getName()) . ' > ' : '') + 'choice_label' => fn (ActivityType $aty) => ($aty->hasCategory() ? $this->translatableStringHelper->localize($aty->getCategory()->getName()).' > ' : '') . $this->translatableStringHelper->localize($aty->getName()), 'group_by' => function (ActivityType $type) { @@ -71,6 +69,7 @@ class ActivityTypeFilter implements ExportElementValidatedInterface, FilterInter ], ]); } + public function getFormDefaultData(): array { return []; @@ -96,7 +95,7 @@ class ActivityTypeFilter implements ExportElementValidatedInterface, FilterInter public function validateForm($data, ExecutionContextInterface $context) { - if (null === $data['types'] || count($data['types']) === 0) { + if (null === $data['types'] || 0 === \count($data['types'])) { $context ->buildViolation('At least one type must be chosen') ->addViolation(); diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityUsersFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityUsersFilter.php index 5f1b1ee6b..56285c026 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityUsersFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityUsersFilter.php @@ -32,8 +32,8 @@ class ActivityUsersFilter implements FilterInterface $orX = $qb->expr()->orX(); foreach ($data['accepted_users'] as $key => $user) { - $orX->add($qb->expr()->isMemberOf(':activity_users_filter_u' . $key, 'activity.users')); - $qb->setParameter('activity_users_filter_u' . $key, $user); + $orX->add($qb->expr()->isMemberOf(':activity_users_filter_u'.$key, 'activity.users')); + $qb->setParameter('activity_users_filter_u'.$key, $user); } $qb->andWhere($orX); @@ -51,6 +51,7 @@ class ActivityUsersFilter implements FilterInterface 'label' => 'Users', ]); } + public function getFormDefaultData(): array { return []; diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ByCreatorFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ByCreatorFilter.php index 285dc2e44..f75c5a817 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ByCreatorFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ByCreatorFilter.php @@ -47,6 +47,7 @@ class ByCreatorFilter implements FilterInterface 'multiple' => true, ]); } + public function getFormDefaultData(): array { return []; diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/EmergencyFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/EmergencyFilter.php index 43090391e..b74be2552 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/EmergencyFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/EmergencyFilter.php @@ -65,6 +65,7 @@ class EmergencyFilter implements FilterInterface 'empty_data' => self::DEFAULT_CHOICE, ]); } + public function getFormDefaultData(): array { return ['accepted_emergency' => self::DEFAULT_CHOICE]; diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/LocationFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/LocationFilter.php index f5c7b4d16..77b4ce20d 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/LocationFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/LocationFilter.php @@ -14,7 +14,6 @@ namespace Chill\ActivityBundle\Export\Filter; use Chill\ActivityBundle\Export\Declarations; use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Form\Type\PickUserLocationType; -use Chill\MainBundle\Templating\TranslatableStringHelper; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; @@ -46,6 +45,7 @@ class LocationFilter implements FilterInterface 'label' => 'pick location', ]); } + public function getFormDefaultData(): array { return []; diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/LocationTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/LocationTypeFilter.php index 8395ff579..771dfca30 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/LocationTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/LocationTypeFilter.php @@ -18,7 +18,6 @@ use Chill\MainBundle\Templating\TranslatableStringHelper; use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; -use function in_array; class LocationTypeFilter implements FilterInterface { @@ -31,7 +30,7 @@ class LocationTypeFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('actloc', $qb->getAllAliases(), true)) { + if (!\in_array('actloc', $qb->getAllAliases(), true)) { $qb->join('activity.location', 'actloc'); } @@ -57,9 +56,10 @@ class LocationTypeFilter implements FilterInterface { $builder->add('accepted_locationtype', PickLocationTypeType::class, [ 'multiple' => true, - //'label' => false, + // 'label' => false, ]); } + public function getFormDefaultData(): array { return []; diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/ActivityReasonFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/ActivityReasonFilter.php index 6158e2b37..3f71add31 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/ActivityReasonFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/ActivityReasonFilter.php @@ -17,16 +17,12 @@ use Chill\ActivityBundle\Repository\ActivityReasonRepository; use Chill\MainBundle\Export\ExportElementValidatedInterface; use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Templating\TranslatableStringHelper; -use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Doctrine\ORM\Query\Expr; use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Validator\Context\ExecutionContextInterface; -use function count; -use function in_array; - class ActivityReasonFilter implements ExportElementValidatedInterface, FilterInterface { public function __construct(protected TranslatableStringHelper $translatableStringHelper, protected ActivityReasonRepository $activityReasonRepository) {} @@ -42,7 +38,7 @@ class ActivityReasonFilter implements ExportElementValidatedInterface, FilterInt $join = $qb->getDQLPart('join'); $clause = $qb->expr()->in('actreasons', ':selected_activity_reasons'); - if (!in_array('actreasons', $qb->getAllAliases(), true)) { + if (!\in_array('actreasons', $qb->getAllAliases(), true)) { $qb->join('activity.reasons', 'actreasons'); } @@ -72,6 +68,7 @@ class ActivityReasonFilter implements ExportElementValidatedInterface, FilterInt 'expanded' => false, ]); } + public function getFormDefaultData(): array { return []; @@ -81,7 +78,7 @@ class ActivityReasonFilter implements ExportElementValidatedInterface, FilterInt { // collect all the reasons'name used in this filter in one array $reasonsNames = array_map( - fn (ActivityReason $r): string => '"' . $this->translatableStringHelper->localize($r->getName()) . '"', + fn (ActivityReason $r): string => '"'.$this->translatableStringHelper->localize($r->getName()).'"', $this->activityReasonRepository->findBy(['id' => $data['reasons']->toArray()]) ); @@ -100,7 +97,7 @@ class ActivityReasonFilter implements ExportElementValidatedInterface, FilterInt public function validateForm($data, ExecutionContextInterface $context) { - if (null === $data['reasons'] || count($data['reasons']) === 0) { + if (null === $data['reasons'] || 0 === \count($data['reasons'])) { $context ->buildViolation('At least one reason must be chosen') ->addViolation(); diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilter.php index 9cf6fa281..eb2312c0e 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilter.php @@ -49,11 +49,11 @@ final readonly class PersonHavingActivityBetweenDateFilter implements ExportElem // add clause between date $sqb->where('activity_person_having_activity.date BETWEEN ' - . ':person_having_activity_between_date_from' - . ' AND ' - . ':person_having_activity_between_date_to' - . ' AND ' - . '(person_person_having_activity.id = person.id OR person MEMBER OF activity_person_having_activity.persons)'); + .':person_having_activity_between_date_from' + .' AND ' + .':person_having_activity_between_date_to' + .' AND ' + .'(person_person_having_activity.id = person.id OR person MEMBER OF activity_person_having_activity.persons)'); if (isset($data['reasons']) && [] !== $data['reasons']) { // add clause activity reason @@ -111,6 +111,7 @@ final readonly class PersonHavingActivityBetweenDateFilter implements ExportElem ]); } } + public function getFormDefaultData(): array { return [ @@ -132,7 +133,7 @@ final readonly class PersonHavingActivityBetweenDateFilter implements ExportElem 'reasons' => implode( ', ', array_map( - fn (ActivityReason $r): string => '"' . $this->translatableStringHelper->localize($r->getName()) . '"', + fn (ActivityReason $r): string => '"'.$this->translatableStringHelper->localize($r->getName()).'"', $data['reasons'] ) ), diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/SentReceivedFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/SentReceivedFilter.php index c93158f2f..640f33592 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/SentReceivedFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/SentReceivedFilter.php @@ -66,6 +66,7 @@ class SentReceivedFilter implements FilterInterface 'empty_data' => self::DEFAULT_CHOICE, ]); } + public function getFormDefaultData(): array { return ['accepted_sentreceived' => self::DEFAULT_CHOICE]; diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/UserFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/UserFilter.php index 5fd08020e..6e6b745b9 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/UserFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/UserFilter.php @@ -56,6 +56,7 @@ class UserFilter implements FilterInterface 'label' => 'Creators', ]); } + public function getFormDefaultData(): array { return []; diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/UserScopeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/UserScopeFilter.php index d33ae1a10..d205e2d30 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/UserScopeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/UserScopeFilter.php @@ -39,7 +39,7 @@ class UserScopeFilter implements FilterInterface $p = self::PREFIX; $qb - ->leftJoin("activity.user", "{$p}_user") // createdBy ? cfr translation + ->leftJoin('activity.user', "{$p}_user") // createdBy ? cfr translation ->leftJoin( UserScopeHistory::class, "{$p}_history", @@ -49,10 +49,10 @@ class UserScopeFilter implements FilterInterface // scope_at based on activity.date ->andWhere( $qb->expr()->andX( - $qb->expr()->lte("{$p}_history.startDate", "activity.date"), + $qb->expr()->lte("{$p}_history.startDate", 'activity.date'), $qb->expr()->orX( $qb->expr()->isNull("{$p}_history.endDate"), - $qb->expr()->gt("{$p}_history.endDate", "activity.date") + $qb->expr()->gt("{$p}_history.endDate", 'activity.date') ) ) ) @@ -61,7 +61,7 @@ class UserScopeFilter implements FilterInterface ) ->setParameter( "{$p}_scopes", - $data["scopes"], + $data['scopes'], ); } diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/UsersJobFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/UsersJobFilter.php index d787f30ea..b65994b9d 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/UsersJobFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/UsersJobFilter.php @@ -41,19 +41,19 @@ class UsersJobFilter implements FilterInterface $qb ->andWhere( $qb->expr()->exists( - "SELECT 1 FROM " . Activity::class . " {$p}_act " - . "JOIN {$p}_act.users {$p}_user " - . "JOIN " . UserJobHistory::class . " {$p}_history WITH {$p}_history.user = {$p}_user " - . "WHERE {$p}_act = activity " + 'SELECT 1 FROM '.Activity::class." {$p}_act " + ."JOIN {$p}_act.users {$p}_user " + .'JOIN '.UserJobHistory::class." {$p}_history WITH {$p}_history.user = {$p}_user " + ."WHERE {$p}_act = activity " // job_at based on activity.date - . "AND {$p}_history.startDate <= activity.date " - . "AND ({$p}_history.endDate IS NULL OR {$p}_history.endDate > activity.date) " - . "AND {$p}_history.job IN ( :{$p}_jobs )" + ."AND {$p}_history.startDate <= activity.date " + ."AND ({$p}_history.endDate IS NULL OR {$p}_history.endDate > activity.date) " + ."AND {$p}_history.job IN ( :{$p}_jobs )" ) ) ->setParameter( "{$p}_jobs", - $data["jobs"] + $data['jobs'] ); } diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/UsersScopeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/UsersScopeFilter.php index a1bcb958b..4c4a83c20 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/UsersScopeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/UsersScopeFilter.php @@ -43,19 +43,19 @@ class UsersScopeFilter implements FilterInterface $qb ->andWhere( $qb->expr()->exists( - "SELECT 1 FROM " . Activity::class . " {$p}_act " - . "JOIN {$p}_act.users {$p}_user " - . "JOIN " . UserScopeHistory::class . " {$p}_history WITH {$p}_history.user = {$p}_user " - . "WHERE {$p}_act = activity " + 'SELECT 1 FROM '.Activity::class." {$p}_act " + ."JOIN {$p}_act.users {$p}_user " + .'JOIN '.UserScopeHistory::class." {$p}_history WITH {$p}_history.user = {$p}_user " + ."WHERE {$p}_act = activity " // scope_at based on activity.date - . "AND {$p}_history.startDate <= activity.date " - . "AND ({$p}_history.endDate IS NULL OR {$p}_history.endDate > activity.date) " - . "AND {$p}_history.scope IN ( :{$p}_scopes )" + ."AND {$p}_history.startDate <= activity.date " + ."AND ({$p}_history.endDate IS NULL OR {$p}_history.endDate > activity.date) " + ."AND {$p}_history.scope IN ( :{$p}_scopes )" ) ) ->setParameter( "{$p}_scopes", - $data["scopes"] + $data['scopes'] ); } diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityType.php b/src/Bundle/ChillActivityBundle/Form/ActivityType.php index 89167219e..8ea117c4a 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityType.php @@ -34,12 +34,8 @@ use Chill\PersonBundle\Entity\SocialWork\SocialIssue; use Chill\PersonBundle\Templating\Entity\SocialActionRender; use Chill\PersonBundle\Templating\Entity\SocialIssueRender; use Chill\ThirdPartyBundle\Entity\ThirdParty; -use DateInterval; -use DateTime; -use DateTimeZone; use Doctrine\ORM\EntityRepository; use Doctrine\Persistence\ObjectManager; -use RuntimeException; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\CallbackTransformer; @@ -53,8 +49,6 @@ use Symfony\Component\Form\FormEvents; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; -use function in_array; - class ActivityType extends AbstractType { protected User $user; @@ -69,7 +63,7 @@ class ActivityType extends AbstractType protected SocialActionRender $socialActionRender ) { if (!$tokenStorage->getToken()->getUser() instanceof User) { - throw new RuntimeException('you should have a valid user'); + throw new \RuntimeException('you should have a valid user'); } $this->user = $tokenStorage->getToken()->getUser(); @@ -102,16 +96,16 @@ class ActivityType extends AbstractType ]); } - /** @var ? \Chill\PersonBundle\Entity\AccompanyingPeriod $accompanyingPeriod */ + /** @var \Chill\PersonBundle\Entity\AccompanyingPeriod|null $accompanyingPeriod */ $accompanyingPeriod = null; if ($options['accompanyingPeriod'] instanceof AccompanyingPeriod) { $accompanyingPeriod = $options['accompanyingPeriod']; } - if ($activityType->isVisible('socialIssues') && $accompanyingPeriod) { + if ($activityType->isVisible('socialIssues') && null !== $accompanyingPeriod) { $builder->add('socialIssues', HiddenType::class, [ - 'required' => $activityType->getSocialIssuesVisible() === 2, + 'required' => 2 === $activityType->getSocialIssuesVisible(), ]); $builder->get('socialIssues') ->addModelTransformer(new CallbackTransformer( @@ -137,9 +131,9 @@ class ActivityType extends AbstractType )); } - if ($activityType->isVisible('socialActions') && $accompanyingPeriod) { + if ($activityType->isVisible('socialActions') && null !== $accompanyingPeriod) { $builder->add('socialActions', HiddenType::class, [ - 'required' => $activityType->getSocialActionsVisible() === 2, + 'required' => 2 === $activityType->getSocialActionsVisible(), ]); $builder->get('socialActions') ->addModelTransformer(new CallbackTransformer( @@ -323,7 +317,7 @@ class ActivityType extends AbstractType if ($activityType->isVisible('location')) { $builder->add('location', HiddenType::class, [ - 'required' => $activityType->getLocationVisible() === 2, + 'required' => 2 === $activityType->getLocationVisible(), ]) ->get('location') ->addModelTransformer(new CallbackTransformer( @@ -374,16 +368,16 @@ class ActivityType extends AbstractType ) { // set the timezone to GMT, and fix the difference between current and GMT // the datetimetransformer will then handle timezone as GMT - $timezoneUTC = new DateTimeZone('GMT'); - /** @var DateTime $data */ - $data = $formEvent->getData() ?? DateTime::createFromFormat('U', '300'); + $timezoneUTC = new \DateTimeZone('GMT'); + /** @var \DateTime $data */ + $data = $formEvent->getData() ?? \DateTime::createFromFormat('U', '300'); $seconds = $data->getTimezone()->getOffset($data); $data->setTimeZone($timezoneUTC); - $data->add(new DateInterval('PT' . $seconds . 'S')); + $data->add(new \DateInterval('PT'.$seconds.'S')); // test if the timestamp is in the choices. // If not, recreate the field with the new timestamp - if (!in_array($data->getTimestamp(), $timeChoices, true)) { + if (!\in_array($data->getTimestamp(), $timeChoices, true)) { // the data are not in the possible values. add them $timeChoices[$data->format('H:i')] = $data->getTimestamp(); $form = $builder->create($fieldName, ChoiceType::class, array_merge( diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php b/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php index 29b00e337..8e8ae51f7 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php @@ -56,8 +56,8 @@ class ActivityTypeType extends AbstractType foreach ($fields as $field) { $builder - ->add($field . 'Visible', ActivityFieldPresence::class) - ->add($field . 'Label', TextType::class, [ + ->add($field.'Visible', ActivityFieldPresence::class) + ->add($field.'Label', TextType::class, [ 'required' => false, 'empty_data' => '', ]); diff --git a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReasonCategoryType.php b/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReasonCategoryType.php index f04e6ac45..ee1417bfb 100644 --- a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReasonCategoryType.php +++ b/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityReasonCategoryType.php @@ -31,7 +31,7 @@ class TranslatableActivityReasonCategoryType extends AbstractType [ 'class' => ActivityReasonCategory::class, 'choice_label' => fn (ActivityReasonCategory $category) => $this->translatableStringHelper->localize($category->getName()) - . (!$category->getActive() ? ' (' . $this->translator->trans('inactive') . ')' : ''), + .(!$category->getActive() ? ' ('.$this->translator->trans('inactive').')' : ''), ] ); } diff --git a/src/Bundle/ChillActivityBundle/Notification/ActivityNotificationHandler.php b/src/Bundle/ChillActivityBundle/Notification/ActivityNotificationHandler.php index de789b9fe..8eb219fd2 100644 --- a/src/Bundle/ChillActivityBundle/Notification/ActivityNotificationHandler.php +++ b/src/Bundle/ChillActivityBundle/Notification/ActivityNotificationHandler.php @@ -35,6 +35,6 @@ final readonly class ActivityNotificationHandler implements NotificationHandlerI public function supports(Notification $notification, array $options = []): bool { - return $notification->getRelatedEntityClass() === Activity::class; + return Activity::class === $notification->getRelatedEntityClass(); } } diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php index d61e0999e..231ad5432 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php @@ -35,9 +35,6 @@ use Doctrine\ORM\QueryBuilder; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\Security\Core\Security; -use function count; -use function in_array; - final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepositoryInterface { public function __construct( @@ -75,7 +72,6 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos return $qb->getQuery()->getSingleScalarResult(); } - public function findByAccompanyingPeriod(AccompanyingPeriod $period, string $role, ?int $start = 0, ?int $limit = 1000, array $orderBy = ['date' => 'DESC'], array $filters = []): array { $qb = $this->buildBaseQuery($filters); @@ -83,7 +79,7 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos $qb->andWhere('a.accompanyingPeriod = :period')->setParameter('period', $period); foreach ($orderBy as $field => $order) { - $qb->addOrderBy('a.' . $field, $order); + $qb->addOrderBy('a.'.$field, $order); } if (null !== $start) { @@ -124,25 +120,25 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos $qb->expr()->orX( $qb->expr()->exists( sprintf( - "SELECT 1 FROM %s ujh_creator WHERE ujh_creator.user = a.createdBy " - . "AND ujh_creator.job IN (:jobs) AND a.createdAt > ujh_creator.startDate " - . "AND (ujh_creator.endDate IS NULL or ujh_creator.endDate > a.date)", + 'SELECT 1 FROM %s ujh_creator WHERE ujh_creator.user = a.createdBy ' + .'AND ujh_creator.job IN (:jobs) AND a.createdAt > ujh_creator.startDate ' + .'AND (ujh_creator.endDate IS NULL or ujh_creator.endDate > a.date)', User\UserJobHistory::class ) ), $qb->expr()->exists( sprintf( - "SELECT 1 FROM %s ujh_u WHERE ujh_u.user = a.user " - . "AND ujh_u.job IN (:jobs) AND a.createdAt > ujh_u.startDate " - . "AND (ujh_u.endDate IS NULL or ujh_u.endDate > a.date)", + 'SELECT 1 FROM %s ujh_u WHERE ujh_u.user = a.user ' + .'AND ujh_u.job IN (:jobs) AND a.createdAt > ujh_u.startDate ' + .'AND (ujh_u.endDate IS NULL or ujh_u.endDate > a.date)', User\UserJobHistory::class ) ), $qb->expr()->exists( sprintf( - "SELECT 1 FROM %s ujh_users WHERE ujh_users.user MEMBER OF a.users " - . "AND ujh_users.job IN (:jobs) AND a.createdAt > ujh_users.startDate " - . "AND (ujh_users.endDate IS NULL or ujh_users.endDate > a.date)", + 'SELECT 1 FROM %s ujh_users WHERE ujh_users.user MEMBER OF a.users ' + .'AND ujh_users.job IN (:jobs) AND a.createdAt > ujh_users.startDate ' + .'AND (ujh_users.endDate IS NULL or ujh_users.endDate > a.date)', User\UserJobHistory::class ) ), @@ -163,7 +159,6 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos } /** - * @param AccompanyingPeriod|Person $associated * @return array */ public function findActivityTypeByAssociated(AccompanyingPeriod|Person $associated): array @@ -225,7 +220,6 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos return $qb->getQuery()->getResult(); } - public function findByAccompanyingPeriodSimplified(AccompanyingPeriod $period, ?int $limit = 1000): array { $rsm = new ResultSetMappingBuilder($this->em); @@ -313,7 +307,7 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos $qb = $this->filterBaseQueryByPerson($qb, $person, $role); foreach ($orderBy as $field => $direction) { - $qb->addOrderBy('a.' . $field, $direction); + $qb->addOrderBy('a.'.$field, $direction); } if (null !== $start) { @@ -340,7 +334,7 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos $orX->add(sprintf('a.person = :person AND a.scope IN (:scopes_%d)', $counter)); $qb->setParameter(sprintf('scopes_%d', $counter), $scopes); $qb->setParameter('person', $person); - $counter++; + ++$counter; } foreach ($person->getAccompanyingPeriodParticipations() as $participation) { @@ -363,7 +357,7 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos ->setParameter(sprintf('participation_end_%d', $counter), $participation->getEndDate()); } $orX->add($and); - $counter++; + ++$counter; } if (0 === $orX->count()) { @@ -384,10 +378,10 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos return [ 'id' => $metadataActivity->getTableName() - . '.' . $metadataActivity->getColumnName('id'), + .'.'.$metadataActivity->getColumnName('id'), 'type' => 'activity', 'date' => $metadataActivity->getTableName() - . '.' . $metadataActivity->getColumnName('date'), + .'.'.$metadataActivity->getColumnName('date'), 'FROM' => $from, 'WHERE' => $where, 'parameters' => $parameters, @@ -400,12 +394,12 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos $metadataPerson = $this->em->getClassMetadata(Person::class); $associationMapping = $metadataActivity->getAssociationMapping('person'); - return $metadataActivity->getTableName() . ' JOIN ' - . $metadataPerson->getTableName() . ' ON ' - . $metadataPerson->getTableName() . '.' . + return $metadataActivity->getTableName().' JOIN ' + .$metadataPerson->getTableName().' ON ' + .$metadataPerson->getTableName().'.'. $associationMapping['joinColumns'][0]['referencedColumnName'] - . ' = ' - . $associationMapping['joinColumns'][0]['name']; + .' = ' + .$associationMapping['joinColumns'][0]['name']; } private function getWhereClause(string $context, array $args): array @@ -424,7 +418,7 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos ActivityVoter::SEE ); - if (count($reachableCenters) === 0) { + if (0 === \count($reachableCenters)) { // insert a dummy condition return 'FALSE = TRUE'; } @@ -441,7 +435,7 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos foreach ($reachableCenters as $center) { // we pass if not in centers - if (!in_array($center, $args['centers'], true)) { + if (!\in_array($center, $args['centers'], true)) { continue; } // we get all the reachable scopes for this center @@ -463,7 +457,7 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos // begin loop for scopes $where .= ' AND ('; - $scopesI = 0; //like scope#i + $scopesI = 0; // like scope#i foreach ($reachablesScopesId as $scopeId) { if (0 < $scopesI) { diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepositoryInterface.php b/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepositoryInterface.php index 474d8ad16..7c51afd63 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepositoryInterface.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepositoryInterface.php @@ -22,8 +22,8 @@ interface ActivityACLAwareRepositoryInterface /** * Return all the activities associated to an accompanying period and that the user is allowed to apply the given role. * - * * @param array{my_activities?: bool, types?: array, jobs?: array, after?: \DateTimeImmutable|null, before?: \DateTimeImmutable|null} $filters + * * @return array */ public function findByAccompanyingPeriod(AccompanyingPeriod $period, string $role, ?int $start = 0, ?int $limit = 1000, array $orderBy = ['date' => 'DESC'], array $filters = []): array; @@ -49,20 +49,20 @@ interface ActivityACLAwareRepositoryInterface /** * @param array{my_activities?: bool, types?: array, jobs?: array, after?: \DateTimeImmutable|null, before?: \DateTimeImmutable|null} $filters + * * @return array */ public function findByPerson(Person $person, string $role, ?int $start = 0, ?int $limit = 1000, array $orderBy = ['date' => 'DESC'], array $filters = []): array; - /** - * Return a list of the type for the activities associated to person or accompanying period + * Return a list of the type for the activities associated to person or accompanying period. * * @return array */ public function findActivityTypeByAssociated(AccompanyingPeriod|Person $associated): array; /** - * Return a list of the user job for the activities associated to person or accompanying period + * Return a list of the user job for the activities associated to person or accompanying period. * * Associated mean the job: * - of the creator; diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityDocumentACLAwareRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityDocumentACLAwareRepository.php index 9cc57f93f..99e75f2da 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityDocumentACLAwareRepository.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityDocumentACLAwareRepository.php @@ -15,25 +15,15 @@ use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Security\Authorization\ActivityVoter; use Chill\ActivityBundle\Service\GenericDoc\Providers\AccompanyingPeriodActivityGenericDocProvider; use Chill\ActivityBundle\Service\GenericDoc\Providers\PersonActivityGenericDocProvider; -use Chill\DocStoreBundle\Entity\PersonDocument; use Chill\DocStoreBundle\Entity\StoredObject; use Chill\DocStoreBundle\GenericDoc\FetchQuery; use Chill\DocStoreBundle\GenericDoc\FetchQueryInterface; -use Chill\DocStoreBundle\GenericDoc\Providers\PersonDocumentGenericDocProvider; -use Chill\DocStoreBundle\Repository\PersonDocumentACLAwareRepositoryInterface; -use Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter; use Chill\MainBundle\Entity\Scope; use Chill\MainBundle\Security\Authorization\AuthorizationHelperForCurrentUserInterface; use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface; -use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; -use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodWorkVoter; -use DateTimeImmutable; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\EntityManagerInterface; -use Doctrine\ORM\Mapping\MappingException; -use Doctrine\ORM\QueryBuilder; -use Symfony\Component\HttpKernel\HttpCache\Store; use Symfony\Component\Security\Core\Security; final readonly class ActivityDocumentACLAwareRepository implements ActivityDocumentACLAwareRepositoryInterface @@ -45,14 +35,14 @@ final readonly class ActivityDocumentACLAwareRepository implements ActivityDocum private Security $security ) {} - public function buildFetchQueryActivityDocumentLinkedToPersonFromPersonContext(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null): FetchQueryInterface + public function buildFetchQueryActivityDocumentLinkedToPersonFromPersonContext(Person $person, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null): FetchQueryInterface { $query = $this->buildBaseFetchQueryActivityDocumentLinkedToPersonFromPersonContext($person, $startDate, $endDate, $content); return $this->addFetchQueryByPersonACL($query, $person); } - public function buildBaseFetchQueryActivityDocumentLinkedToPersonFromPersonContext(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null): FetchQuery + public function buildBaseFetchQueryActivityDocumentLinkedToPersonFromPersonContext(Person $person, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null): FetchQuery { $storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class); $activityMetadata = $this->em->getClassMetadata(Activity::class); @@ -81,7 +71,7 @@ final readonly class ActivityDocumentACLAwareRepository implements ActivityDocum return $this->addWhereClauses($query, $startDate, $endDate, $content); } - public function buildFetchQueryActivityDocumentLinkedToAccompanyingPeriodFromPersonContext(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null): FetchQuery + public function buildFetchQueryActivityDocumentLinkedToAccompanyingPeriodFromPersonContext(Person $person, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null): FetchQuery { $storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class); $activityMetadata = $this->em->getClassMetadata(Activity::class); @@ -116,8 +106,8 @@ final readonly class ActivityDocumentACLAwareRepository implements ActivityDocum $storedObjectMetadata->getColumnName('createdAt') ); $orParams = [...$orParams, $participation->getAccompanyingPeriod()->getId(), - DateTimeImmutable::createFromInterface($participation->getStartDate()), - null === $participation->getEndDate() ? null : DateTimeImmutable::createFromInterface($participation->getEndDate())]; + \DateTimeImmutable::createFromInterface($participation->getStartDate()), + null === $participation->getEndDate() ? null : \DateTimeImmutable::createFromInterface($participation->getEndDate())]; $orTypes = [...$orTypes, Types::INTEGER, Types::DATE_IMMUTABLE, Types::DATE_IMMUTABLE]; } @@ -132,7 +122,7 @@ final readonly class ActivityDocumentACLAwareRepository implements ActivityDocum return $this->addWhereClauses($query, $startDate, $endDate, $content); } - private function addWhereClauses(FetchQuery $query, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null): FetchQuery + private function addWhereClauses(FetchQuery $query, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null): FetchQuery { $storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class); @@ -155,7 +145,7 @@ final readonly class ActivityDocumentACLAwareRepository implements ActivityDocum if (null !== $content and '' !== $content) { $query->addWhereClause( 'stored_obj.title ilike ?', - ['%' . $content . '%'], + ['%'.$content.'%'], [Types::STRING] ); } @@ -172,7 +162,7 @@ final readonly class ActivityDocumentACLAwareRepository implements ActivityDocum foreach ($this->centerResolverManager->resolveCenters($person) as $center) { $reachableScopes = [ ...$reachableScopes, - ...$this->authorizationHelperForCurrentUser->getReachableScopes(ActivityVoter::SEE, $center) + ...$this->authorizationHelperForCurrentUser->getReachableScopes(ActivityVoter::SEE, $center), ]; } diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityDocumentACLAwareRepositoryInterface.php b/src/Bundle/ChillActivityBundle/Repository/ActivityDocumentACLAwareRepositoryInterface.php index 9f4a9c0f8..dcd45c016 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityDocumentACLAwareRepositoryInterface.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityDocumentACLAwareRepositoryInterface.php @@ -14,24 +14,23 @@ namespace Chill\ActivityBundle\Repository; use Chill\DocStoreBundle\GenericDoc\FetchQuery; use Chill\DocStoreBundle\GenericDoc\FetchQueryInterface; use Chill\PersonBundle\Entity\Person; -use DateTimeImmutable; /** - * Gives queries usable for fetching documents, with ACL aware + * Gives queries usable for fetching documents, with ACL aware. */ interface ActivityDocumentACLAwareRepositoryInterface { /** - * Return a fetch query for querying document's activities for a person + * Return a fetch query for querying document's activities for a person. * * This method must check the rights to see a document: the user must be allowed to see the given activities */ - public function buildFetchQueryActivityDocumentLinkedToPersonFromPersonContext(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null): FetchQueryInterface; + public function buildFetchQueryActivityDocumentLinkedToPersonFromPersonContext(Person $person, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null): FetchQueryInterface; /** - * Return a fetch query for querying document's activities for an activity in accompanying periods, but for a given person + * Return a fetch query for querying document's activities for an activity in accompanying periods, but for a given person. * * This method must check the rights to see a document: the user must be allowed to see the given accompanying periods */ - public function buildFetchQueryActivityDocumentLinkedToAccompanyingPeriodFromPersonContext(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null): FetchQuery; + public function buildFetchQueryActivityDocumentLinkedToAccompanyingPeriodFromPersonContext(Person $person, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null): FetchQuery; } diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityPresenceRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityPresenceRepository.php index 3ed96074b..ae3296e7f 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityPresenceRepository.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityPresenceRepository.php @@ -34,7 +34,7 @@ class ActivityPresenceRepository implements ActivityPresenceRepositoryInterface return $this->repository->findAll(); } - public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array + public function findBy(array $criteria, array $orderBy = null, int $limit = null, int $offset = null): array { return $this->findBy($criteria, $orderBy, $limit, $offset); } diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityPresenceRepositoryInterface.php b/src/Bundle/ChillActivityBundle/Repository/ActivityPresenceRepositoryInterface.php index 228d70856..d2daa1d5d 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityPresenceRepositoryInterface.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityPresenceRepositoryInterface.php @@ -25,7 +25,7 @@ interface ActivityPresenceRepositoryInterface /** * @return array|ActivityPresence[] */ - public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array; + public function findBy(array $criteria, array $orderBy = null, int $limit = null, int $offset = null): array; public function findOneBy(array $criteria): ?ActivityPresence; diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityRepository.php index 5a6e16cd5..a7025d4a9 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityRepository.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityRepository.php @@ -62,7 +62,7 @@ class ActivityRepository extends ServiceEntityRepository ->setParameter('period', $period); foreach ($orderBy as $k => $dir) { - $qb->addOrderBy('a.' . $k, $dir); + $qb->addOrderBy('a.'.$k, $dir); } $qb->setMaxResults($limit)->setFirstResult($offset); @@ -90,7 +90,7 @@ class ActivityRepository extends ServiceEntityRepository ->setParameter('person', $person); foreach ($orderBy as $k => $dir) { - $qb->addOrderBy('a.' . $k, $dir); + $qb->addOrderBy('a.'.$k, $dir); } $qb->setMaxResults($limit)->setFirstResult($offset); diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepository.php index 49d3e2cd7..6f7453a74 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepository.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepository.php @@ -11,13 +11,9 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Repository; -use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Entity\ActivityType; -use Chill\PersonBundle\Entity\AccompanyingPeriod; -use Chill\PersonBundle\Entity\Person; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; -use Doctrine\ORM\Query\Expr\Join; final class ActivityTypeRepository implements ActivityTypeRepositoryInterface { @@ -52,7 +48,7 @@ final class ActivityTypeRepository implements ActivityTypeRepositoryInterface /** * @return array|ActivityType[] */ - public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array + public function findBy(array $criteria, array $orderBy = null, int $limit = null, int $offset = null): array { return $this->repository->findBy($criteria, $orderBy, $limit, $offset); } diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepositoryInterface.php b/src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepositoryInterface.php index 574faea22..899535ad6 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepositoryInterface.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepositoryInterface.php @@ -12,8 +12,6 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Repository; use Chill\ActivityBundle\Entity\ActivityType; -use Chill\PersonBundle\Entity\AccompanyingPeriod; -use Chill\PersonBundle\Entity\Person; use Doctrine\Persistence\ObjectRepository; interface ActivityTypeRepositoryInterface extends ObjectRepository diff --git a/src/Bundle/ChillActivityBundle/Security/Authorization/ActivityVoter.php b/src/Bundle/ChillActivityBundle/Security/Authorization/ActivityVoter.php index 06cbb7145..bf2ed78a0 100644 --- a/src/Bundle/ChillActivityBundle/Security/Authorization/ActivityVoter.php +++ b/src/Bundle/ChillActivityBundle/Security/Authorization/ActivityVoter.php @@ -21,12 +21,9 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; use Chill\PersonBundle\Security\Authorization\PersonVoter; -use RuntimeException; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Security; -use function in_array; - class ActivityVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface { /** @@ -145,11 +142,11 @@ class ActivityVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn return $this->voterHelper->voteOnAttribute(self::CREATE_ACCOMPANYING_COURSE, $subject->getAccompanyingPeriod(), $token); } } else { - throw new RuntimeException('Could not determine context of activity.'); + throw new \RuntimeException('Could not determine context of activity.'); } } elseif ($subject instanceof AccompanyingPeriod) { if (AccompanyingPeriod::STEP_CLOSED === $subject->getStep()) { - if (in_array($attribute, [self::UPDATE, self::CREATE, self::DELETE], true)) { + if (\in_array($attribute, [self::UPDATE, self::CREATE, self::DELETE], true)) { return false; } } diff --git a/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php b/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php index f508d215a..46e466ae1 100644 --- a/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php +++ b/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php @@ -18,7 +18,6 @@ use Chill\DocGeneratorBundle\Context\Exception\UnexpectedTypeException; use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate; use Chill\DocGeneratorBundle\Service\Context\BaseContextData; use Chill\DocStoreBundle\Entity\StoredObject; -use Chill\DocStoreBundle\Repository\DocumentCategoryRepository; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; @@ -127,7 +126,7 @@ class ActivityContext implements 'multiple' => false, 'required' => false, 'expanded' => true, - 'label' => $options[$key . 'Label'], + 'label' => $options[$key.'Label'], 'placeholder' => $this->translator->trans('Any person selected'), ]); } @@ -210,7 +209,7 @@ class ActivityContext implements if ($options['thirdParty']) { $data['thirdParty'] = $this->normalizer->normalize($contextGenerationData['thirdParty'], 'docgen', [ 'docgen:expects' => ThirdParty::class, - 'groups' => 'docgen:read' + 'groups' => 'docgen:read', ]); } @@ -253,7 +252,7 @@ class ActivityContext implements { $options = $template->getOptions(); - return $options['mainPerson'] || $options['person1'] || $options['person2'] || $options ['thirdParty']; + return $options['mainPerson'] || $options['person1'] || $options['person2'] || $options['thirdParty']; } public function storeGenerated(DocGeneratorTemplate $template, StoredObject $storedObject, object $entity, array $contextGenerationData): void diff --git a/src/Bundle/ChillActivityBundle/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContext.php b/src/Bundle/ChillActivityBundle/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContext.php index 2a953eebd..221d1f4b2 100644 --- a/src/Bundle/ChillActivityBundle/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContext.php +++ b/src/Bundle/ChillActivityBundle/Service/DocGenerator/ListActivitiesByAccompanyingPeriodContext.php @@ -32,13 +32,11 @@ use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository; use Chill\PersonBundle\Service\DocGenerator\AccompanyingPeriodContext; use Chill\ThirdPartyBundle\Entity\ThirdParty; use Chill\ThirdPartyBundle\Repository\ThirdPartyRepository; -use DateTime; use libphonenumber\PhoneNumber; use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; -use function in_array; /** * @implements DocGeneratorContextWithPublicFormInterface @@ -122,7 +120,8 @@ class ListActivitiesByAccompanyingPeriodContext implements $activities, function ($activity) use ($user) { $activityUsernames = array_map(static fn ($user) => $user['username'], $activity['users'] ?? []); - return in_array($user->getUsername(), $activityUsernames, true); + + return \in_array($user->getUsername(), $activityUsernames, true); } ) ); @@ -139,7 +138,7 @@ class ListActivitiesByAccompanyingPeriodContext implements function ($work) use ($user) { $workUsernames = array_map(static fn ($user) => $user['username'], $work['referrers'] ?? []); - return in_array($user->getUsername(), $workUsernames, true); + return \in_array($user->getUsername(), $workUsernames, true); } ) ); @@ -163,6 +162,7 @@ class ListActivitiesByAccompanyingPeriodContext implements if ($myWorksOnly && isset($contextGenerationData['creator'])) { $data['course']['works'] = $this->filterWorksByUser($data['course']['works'], $contextGenerationData['creator']); } + return $data; } @@ -216,7 +216,7 @@ class ListActivitiesByAccompanyingPeriodContext implements $activity = $row[0]; $activity['date'] = $this->normalizer->normalize($activity['date'], 'docgen', [ - AbstractNormalizer::GROUPS => ['docgen:read'], 'docgen:expects' => DateTime::class, + AbstractNormalizer::GROUPS => ['docgen:read'], 'docgen:expects' => \DateTime::class, ]); if (null === $activity['location']) { @@ -229,8 +229,8 @@ class ListActivitiesByAccompanyingPeriodContext implements $activity['location']['type'] = 'location'; foreach (['1', '2'] as $key) { - $activity['location']['phonenumber' . $key] = $this->normalizer->normalize( - $activity['location']['phonenumber' . $key], + $activity['location']['phonenumber'.$key] = $this->normalizer->normalize( + $activity['location']['phonenumber'.$key], 'docgen', [AbstractNormalizer::GROUPS => ['docgen:read'], 'docgen:expects' => PhoneNumber::class] ); diff --git a/src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/AccompanyingPeriodActivityGenericDocProvider.php b/src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/AccompanyingPeriodActivityGenericDocProvider.php index e85710797..2c6c9a691 100644 --- a/src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/AccompanyingPeriodActivityGenericDocProvider.php +++ b/src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/AccompanyingPeriodActivityGenericDocProvider.php @@ -22,10 +22,8 @@ use Chill\DocStoreBundle\GenericDoc\GenericDocForPersonProviderInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; -use DateTimeImmutable; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\EntityManagerInterface; -use Doctrine\ORM\Mapping\MappingException; use Symfony\Component\Security\Core\Security; final readonly class AccompanyingPeriodActivityGenericDocProvider implements GenericDocForAccompanyingPeriodProviderInterface, GenericDocForPersonProviderInterface @@ -38,7 +36,7 @@ final readonly class AccompanyingPeriodActivityGenericDocProvider implements Gen private ActivityDocumentACLAwareRepositoryInterface $activityDocumentACLAwareRepository, ) {} - public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface + public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null, string $origin = null): FetchQueryInterface { $storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class); $activityMetadata = $this->em->getClassMetadata(Activity::class); @@ -83,7 +81,7 @@ final readonly class AccompanyingPeriodActivityGenericDocProvider implements Gen if (null !== $content) { $query->addWhereClause( 'doc_obj.title ilike ?', - ['%' . $content . '%'], + ['%'.$content.'%'], [Types::STRING] ); } @@ -91,10 +89,6 @@ final readonly class AccompanyingPeriodActivityGenericDocProvider implements Gen return $query; } - /** - * @param AccompanyingPeriod $accompanyingPeriod - * @return bool - */ public function isAllowedForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod): bool { return $this->security->isGranted(ActivityVoter::SEE, $accompanyingPeriod); @@ -105,7 +99,7 @@ final readonly class AccompanyingPeriodActivityGenericDocProvider implements Gen return $this->security->isGranted(AccompanyingPeriodVoter::SEE, $person); } - public function buildFetchQueryForPerson(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface + public function buildFetchQueryForPerson(Person $person, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null, string $origin = null): FetchQueryInterface { return $this->activityDocumentACLAwareRepository ->buildFetchQueryActivityDocumentLinkedToAccompanyingPeriodFromPersonContext($person, $startDate, $endDate, $content); diff --git a/src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/PersonActivityGenericDocProvider.php b/src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/PersonActivityGenericDocProvider.php index f4a7c4afa..b84345375 100644 --- a/src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/PersonActivityGenericDocProvider.php +++ b/src/Bundle/ChillActivityBundle/Service/GenericDoc/Providers/PersonActivityGenericDocProvider.php @@ -11,15 +11,11 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Service\GenericDoc\Providers; -use Chill\ActivityBundle\Repository\ActivityDocumentACLAwareRepository; use Chill\ActivityBundle\Repository\ActivityDocumentACLAwareRepositoryInterface; use Chill\ActivityBundle\Security\Authorization\ActivityVoter; use Chill\DocStoreBundle\GenericDoc\FetchQueryInterface; use Chill\DocStoreBundle\GenericDoc\GenericDocForPersonProviderInterface; -use Chill\DocStoreBundle\Repository\PersonDocumentACLAwareRepositoryInterface; use Chill\PersonBundle\Entity\Person; -use DateTimeImmutable; -use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\Security\Core\Security; final readonly class PersonActivityGenericDocProvider implements GenericDocForPersonProviderInterface @@ -27,11 +23,11 @@ final readonly class PersonActivityGenericDocProvider implements GenericDocForPe public const KEY = 'person_activity_document'; public function __construct( - private Security $security, + private Security $security, private ActivityDocumentACLAwareRepositoryInterface $personActivityDocumentACLAwareRepository, ) {} - public function buildFetchQueryForPerson(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface + public function buildFetchQueryForPerson(Person $person, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null, string $origin = null): FetchQueryInterface { return $this->personActivityDocumentACLAwareRepository->buildFetchQueryActivityDocumentLinkedToPersonFromPersonContext( $person, @@ -41,10 +37,6 @@ final readonly class PersonActivityGenericDocProvider implements GenericDocForPe ); } - /** - * @param Person $person - * @return bool - */ public function isAllowedForPerson(Person $person): bool { return $this->security->isGranted(ActivityVoter::SEE, $person); diff --git a/src/Bundle/ChillActivityBundle/Service/GenericDoc/Renderers/AccompanyingPeriodActivityGenericDocRenderer.php b/src/Bundle/ChillActivityBundle/Service/GenericDoc/Renderers/AccompanyingPeriodActivityGenericDocRenderer.php index 4cfefd05d..93649cea8 100644 --- a/src/Bundle/ChillActivityBundle/Service/GenericDoc/Renderers/AccompanyingPeriodActivityGenericDocRenderer.php +++ b/src/Bundle/ChillActivityBundle/Service/GenericDoc/Renderers/AccompanyingPeriodActivityGenericDocRenderer.php @@ -17,7 +17,6 @@ use Chill\ActivityBundle\Service\GenericDoc\Providers\PersonActivityGenericDocPr use Chill\DocStoreBundle\GenericDoc\GenericDocDTO; use Chill\DocStoreBundle\GenericDoc\Twig\GenericDocRendererInterface; use Chill\DocStoreBundle\Repository\StoredObjectRepository; -use Chill\PersonBundle\Entity\AccompanyingPeriod; final readonly class AccompanyingPeriodActivityGenericDocRenderer implements GenericDocRendererInterface { @@ -25,7 +24,7 @@ final readonly class AccompanyingPeriodActivityGenericDocRenderer implements Gen public function supports(GenericDocDTO $genericDocDTO, $options = []): bool { - return $genericDocDTO->key === AccompanyingPeriodActivityGenericDocProvider::KEY || $genericDocDTO->key === PersonActivityGenericDocProvider::KEY; + return AccompanyingPeriodActivityGenericDocProvider::KEY === $genericDocDTO->key || PersonActivityGenericDocProvider::KEY === $genericDocDTO->key; } public function getTemplate(GenericDocDTO $genericDocDTO, $options = []): string diff --git a/src/Bundle/ChillActivityBundle/Templating/Entity/ActivityReasonRender.php b/src/Bundle/ChillActivityBundle/Templating/Entity/ActivityReasonRender.php index c60a8d286..aa7783d2d 100644 --- a/src/Bundle/ChillActivityBundle/Templating/Entity/ActivityReasonRender.php +++ b/src/Bundle/ChillActivityBundle/Templating/Entity/ActivityReasonRender.php @@ -12,7 +12,6 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Templating\Entity; use Chill\ActivityBundle\Entity\ActivityReason; -use Chill\MainBundle\Templating\Entity\AbstractChillEntityRender; use Chill\MainBundle\Templating\Entity\BoxUtilsChillEntityRenderTrait; use Chill\MainBundle\Templating\Entity\ChillEntityRenderInterface; use Chill\MainBundle\Templating\TranslatableStringHelper; @@ -38,21 +37,21 @@ class ActivityReasonRender implements ChillEntityRenderInterface public function renderBox($entity, array $options): string { return - $this->getDefaultOpeningBox('activity-reason') . - '' . - ' ' . - '' . + $this->getDefaultOpeningBox('activity-reason'). + ''. + ' '. + ''. $this->translatableStringHelper->localize( $entity->getCategory()->getName() - ) . - '' . - ' > ' . - '' . + ). + ''. + ' > '. + ''. $this->translatableStringHelper->localize( $entity->getName() - ) . - '' . - '' . + ). + ''. + ''. $this->getDefaultClosingBox(); } @@ -63,10 +62,10 @@ class ActivityReasonRender implements ChillEntityRenderInterface if (null !== $entity->getCategory()) { $category = $this->translatableStringHelper->localize( $entity->getCategory()->getName() - ) . ' > '; + ).' > '; } - return $category . + return $category. $this->translatableStringHelper->localize( $entity->getName() ); diff --git a/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityControllerTest.php b/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityControllerTest.php index 4b5d25514..38aa49cdf 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityControllerTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityControllerTest.php @@ -12,14 +12,12 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Tests\Controller; use Chill\ActivityBundle\Entity\ActivityType; -use RuntimeException; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\Security\Core\Role\Role; -use function count; -use function in_array; /** * @internal + * * @coversNothing */ final class ActivityControllerTest extends WebTestCase @@ -206,19 +204,19 @@ final class ActivityControllerTest extends WebTestCase $container = self::$kernel->getContainer(); $em = $container->get('doctrine.orm.entity_manager'); - //get the social PermissionGroup, and remove CHILL_ACTIVITY_* + // get the social PermissionGroup, and remove CHILL_ACTIVITY_* $socialPermissionGroup = $em ->getRepository(\Chill\MainBundle\Entity\PermissionsGroup::class) ->findOneByName('social'); $withoutActivityPermissionGroup = (new \Chill\MainBundle\Entity\PermissionsGroup()) ->setName('social without activity'); - //copy role scopes where ACTIVITY is not present + // copy role scopes where ACTIVITY is not present foreach ($socialPermissionGroup->getRoleScopes() as $roleScope) { if (!strpos((string) $roleScope->getRole(), 'ACTIVITY')) { $withoutActivityPermissionGroup->addRoleScope($roleScope); } } - //create groupCenter + // create groupCenter $groupCenter = new \Chill\MainBundle\Entity\GroupCenter(); $groupCenter->setCenter($em->getRepository(\Chill\MainBundle\Entity\Center::class) ->findOneBy(['name' => 'Center A'])) @@ -226,7 +224,7 @@ final class ActivityControllerTest extends WebTestCase $em->persist($withoutActivityPermissionGroup); $em->persist($groupCenter); - //create user + // create user $faker = \Faker\Factory::create(); $username = $faker->name; $user = new \Chill\MainBundle\Entity\User(); @@ -251,9 +249,8 @@ final class ActivityControllerTest extends WebTestCase $activities = $em->getRepository(\Chill\ActivityBundle\Entity\Activity::class) ->findBy(['person' => $person]); - if (count($activities) === 0) { - throw new RuntimeException('We need activities associated with this ' - . 'person. Did you forget to add fixtures ?'); + if (0 === \count($activities)) { + throw new \RuntimeException('We need activities associated with this person. Did you forget to add fixtures ?'); } return $activities; @@ -285,8 +282,7 @@ final class ActivityControllerTest extends WebTestCase ]); if (null === $person) { - throw new RuntimeException('We need a person with firstname Gérard and' - . ' lastname Depardieu. Did you add fixtures ?'); + throw new \RuntimeException('We need a person with firstname Gérard and lastname Depardieu. Did you add fixtures ?'); } return $person; @@ -306,7 +302,7 @@ final class ActivityControllerTest extends WebTestCase $reason = $reasons[array_rand($reasons)]; - if (in_array($reason->getId(), $excludeIds, true)) { + if (\in_array($reason->getId(), $excludeIds, true)) { return $this->getRandomActivityReason($excludeIds); } @@ -340,8 +336,7 @@ final class ActivityControllerTest extends WebTestCase ->findOneByUsername($username); if (null === $user) { - throw new RuntimeException("The user with username {$username} " - . 'does not exists in database. Did you add fixtures ?'); + throw new \RuntimeException("The user with username {$username} ".'does not exists in database. Did you add fixtures ?'); } $center = self::$kernel->getContainer() @@ -369,13 +364,12 @@ final class ActivityControllerTest extends WebTestCase array_map(static fn ($s) => $s->getId(), $reachableScopesUpdate) ); - if (count($reachableScopesId) === 0) { - throw new RuntimeException('there are not scope reachable for ' - . 'both CHILL_ACTIVITY_UPDATE and CHILL_ACTIVITY_DELETE'); + if (0 === \count($reachableScopesId)) { + throw new \RuntimeException('there are not scope reachable for both CHILL_ACTIVITY_UPDATE and CHILL_ACTIVITY_DELETE'); } foreach ($reachableScopesUpdate as $scope) { - if (in_array($scope->getId(), $reachableScopesId, true)) { + if (\in_array($scope->getId(), $reachableScopesId, true)) { $reachableScopes[] = $scope; } } diff --git a/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityReasonCategoryControllerTest.php b/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityReasonCategoryControllerTest.php index cea8482dc..81378b5ef 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityReasonCategoryControllerTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityReasonCategoryControllerTest.php @@ -15,6 +15,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; /** * @internal + * * @coversNothing */ final class ActivityReasonCategoryControllerTest extends WebTestCase diff --git a/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityReasonControllerTest.php b/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityReasonControllerTest.php index 338e92c87..ce37d3fb7 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityReasonControllerTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityReasonControllerTest.php @@ -15,6 +15,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; /** * @internal + * * @coversNothing */ final class ActivityReasonControllerTest extends WebTestCase diff --git a/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityTypeControllerTest.php b/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityTypeControllerTest.php index 911198b1e..23de2d17c 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityTypeControllerTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Controller/ActivityTypeControllerTest.php @@ -15,6 +15,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; /** * @internal + * * @coversNothing */ final class ActivityTypeControllerTest extends WebTestCase diff --git a/src/Bundle/ChillActivityBundle/Tests/Entity/ActivityTest.php b/src/Bundle/ChillActivityBundle/Tests/Entity/ActivityTest.php index 3d91c3da9..6610b64ff 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Entity/ActivityTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Entity/ActivityTest.php @@ -22,6 +22,7 @@ use Prophecy\PhpUnit\ProphecyTrait; /** * @internal + * * @coversNothing */ final class ActivityTest extends TestCase diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialActionAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialActionAggregatorTest.php index 657c9441e..6cb0eb299 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialActionAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialActionAggregatorTest.php @@ -18,6 +18,7 @@ use Doctrine\ORM\EntityManagerInterface; /** * @internal + * * @coversNothing */ final class BySocialActionAggregatorTest extends AbstractAggregatorTest diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialIssueAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialIssueAggregatorTest.php index 86c999cf3..583e950a6 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialIssueAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialIssueAggregatorTest.php @@ -18,6 +18,7 @@ use Doctrine\ORM\EntityManagerInterface; /** * @internal + * * @coversNothing */ final class BySocialIssueAggregatorTest extends AbstractAggregatorTest diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ActivityTypeAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ActivityTypeAggregatorTest.php index 7fbe4a91d..bb0906be6 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ActivityTypeAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ActivityTypeAggregatorTest.php @@ -12,7 +12,6 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Tests\Export\Aggregator; use Chill\ActivityBundle\Entity\Activity; -use Chill\ActivityBundle\Entity\ActivityType; use Chill\ActivityBundle\Export\Aggregator\ActivityTypeAggregator; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Doctrine\ORM\EntityManagerInterface; @@ -22,6 +21,7 @@ use Prophecy\PhpUnit\ProphecyTrait; * Add tests for ActivityTypeAggregator. * * @internal + * * @coversNothing */ final class ActivityTypeAggregatorTest extends AbstractAggregatorTest diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ActivityUserAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ActivityUserAggregatorTest.php index a0df16868..0cd7fe14d 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ActivityUserAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ActivityUserAggregatorTest.php @@ -21,6 +21,7 @@ use Prophecy\PhpUnit\ProphecyTrait; * Add tests for ActivityUsernAggregator. * * @internal + * * @coversNothing */ final class ActivityUserAggregatorTest extends AbstractAggregatorTest diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ByThirdpartyAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ByThirdpartyAggregatorTest.php index e3bec0c06..0558c3f2b 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ByThirdpartyAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ByThirdpartyAggregatorTest.php @@ -18,6 +18,7 @@ use Doctrine\ORM\EntityManagerInterface; /** * @internal + * * @coversNothing */ final class ByThirdpartyAggregatorTest extends AbstractAggregatorTest diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ByUserAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ByUserAggregatorTest.php index 04a2d68bf..3e8359ab8 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ByUserAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ByUserAggregatorTest.php @@ -18,6 +18,7 @@ use Doctrine\ORM\EntityManagerInterface; /** * @internal + * * @coversNothing */ final class ByUserAggregatorTest extends AbstractAggregatorTest diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/CreatorScopeAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/CreatorScopeAggregatorTest.php index ca4d0baa5..49c1d746f 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/CreatorScopeAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/CreatorScopeAggregatorTest.php @@ -18,6 +18,7 @@ use Doctrine\ORM\EntityManagerInterface; /** * @internal + * * @coversNothing */ final class CreatorScopeAggregatorTest extends AbstractAggregatorTest diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/DateAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/DateAggregatorTest.php index 586edb86f..db3a3ff76 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/DateAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/DateAggregatorTest.php @@ -18,6 +18,7 @@ use Doctrine\ORM\EntityManagerInterface; /** * @internal + * * @coversNothing */ final class DateAggregatorTest extends AbstractAggregatorTest diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/JobScopeAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/JobScopeAggregatorTest.php index 3771e6e32..69d511ace 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/JobScopeAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/JobScopeAggregatorTest.php @@ -12,18 +12,19 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Tests\Export\Aggregator; use Chill\ActivityBundle\Entity\Activity; -use Chill\ActivityBundle\Export\Aggregator\CreatorScopeAggregator; use Chill\ActivityBundle\Export\Aggregator\JobScopeAggregator; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Doctrine\ORM\EntityManagerInterface; /** * @internal + * * @coversNothing */ final class JobScopeAggregatorTest extends AbstractAggregatorTest { private JobScopeAggregator $aggregator; + protected function setUp(): void { self::bootKernel(); diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/LocationTypeAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/LocationTypeAggregatorTest.php index 299f28b77..663901edd 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/LocationTypeAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/LocationTypeAggregatorTest.php @@ -18,6 +18,7 @@ use Doctrine\ORM\EntityManagerInterface; /** * @internal + * * @coversNothing */ final class LocationTypeAggregatorTest extends AbstractAggregatorTest diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/PersonAggregators/ActivityReasonAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/PersonAggregators/ActivityReasonAggregatorTest.php index 426a3929f..004de0b99 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/PersonAggregators/ActivityReasonAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/PersonAggregators/ActivityReasonAggregatorTest.php @@ -19,6 +19,7 @@ use Prophecy\PhpUnit\ProphecyTrait; /** * @internal + * * @coversNothing */ final class ActivityReasonAggregatorTest extends AbstractAggregatorTest diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToACP/AvgActivityDurationTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToACP/AvgActivityDurationTest.php index 2eb2176b0..5f9b635ee 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToACP/AvgActivityDurationTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToACP/AvgActivityDurationTest.php @@ -16,6 +16,7 @@ use Chill\MainBundle\Test\Export\AbstractExportTest; /** * @internal + * * @coversNothing */ final class AvgActivityDurationTest extends AbstractExportTest diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToACP/AvgActivityVisitDurationTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToACP/AvgActivityVisitDurationTest.php index 59b4384cf..b15462912 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToACP/AvgActivityVisitDurationTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToACP/AvgActivityVisitDurationTest.php @@ -16,6 +16,7 @@ use Chill\MainBundle\Test\Export\AbstractExportTest; /** * @internal + * * @coversNothing */ final class AvgActivityVisitDurationTest extends AbstractExportTest diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToACP/CountActivityTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToACP/CountActivityTest.php index f03bbb956..46279ebd8 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToACP/CountActivityTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToACP/CountActivityTest.php @@ -16,6 +16,7 @@ use Chill\MainBundle\Test\Export\AbstractExportTest; /** * @internal + * * @coversNothing */ final class CountActivityTest extends AbstractExportTest diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToACP/SumActivityDurationTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToACP/SumActivityDurationTest.php index 24a5133b6..c4f91f52e 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToACP/SumActivityDurationTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToACP/SumActivityDurationTest.php @@ -16,6 +16,7 @@ use Chill\MainBundle\Test\Export\AbstractExportTest; /** * @internal + * * @coversNothing */ final class SumActivityDurationTest extends AbstractExportTest diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToACP/SumActivityVisitDurationTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToACP/SumActivityVisitDurationTest.php index 1940140ac..6bd7e9d19 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToACP/SumActivityVisitDurationTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToACP/SumActivityVisitDurationTest.php @@ -16,6 +16,7 @@ use Chill\MainBundle\Test\Export\AbstractExportTest; /** * @internal + * * @coversNothing */ final class SumActivityVisitDurationTest extends AbstractExportTest diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToPerson/CountActivityTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToPerson/CountActivityTest.php index 864ff55ba..61ae15604 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToPerson/CountActivityTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToPerson/CountActivityTest.php @@ -16,6 +16,7 @@ use Chill\MainBundle\Test\Export\AbstractExportTest; /** * @internal + * * @coversNothing */ final class CountActivityTest extends AbstractExportTest diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToPerson/ListActivityTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToPerson/ListActivityTest.php index afa3da111..f474b1fe6 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToPerson/ListActivityTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToPerson/ListActivityTest.php @@ -17,6 +17,7 @@ use Prophecy\PhpUnit\ProphecyTrait; /** * @internal + * * @coversNothing */ final class ListActivityTest extends AbstractExportTest diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToPerson/StatActivityDurationTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToPerson/StatActivityDurationTest.php index 44d327ffd..11fb84a9a 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToPerson/StatActivityDurationTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Export/LinkedToPerson/StatActivityDurationTest.php @@ -18,6 +18,7 @@ use Chill\MainBundle\Test\Export\AbstractExportTest; * Test the "sum" part of StatActivityDuration. * * @internal + * * @coversNothing */ final class StatActivityDurationTest extends AbstractExportTest diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/ActivityTypeFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/ActivityTypeFilterTest.php index 92257f6ce..347d7466f 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/ActivityTypeFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/ActivityTypeFilterTest.php @@ -13,7 +13,6 @@ namespace Chill\ActivityBundle\Tests\Export\Filter\ACPFilters; use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Entity\ActivityType; -use Chill\ActivityBundle\Export\Filter\ActivityTypeFilter; use Chill\MainBundle\Test\Export\AbstractFilterTest; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Doctrine\Common\Collections\ArrayCollection; @@ -22,6 +21,7 @@ use Doctrine\ORM\Query\Expr; /** * @internal + * * @coversNothing */ final class ActivityTypeFilterTest extends AbstractFilterTest diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/ByCreatorFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/ByCreatorFilterTest.php index 225949e2c..0b0c1f029 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/ByCreatorFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/ByCreatorFilterTest.php @@ -19,6 +19,7 @@ use Doctrine\ORM\EntityManagerInterface; /** * @internal + * * @coversNothing */ final class ByCreatorFilterTest extends AbstractFilterTest diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/BySocialActionFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/BySocialActionFilterTest.php index 48bd32455..e6ec47666 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/BySocialActionFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/BySocialActionFilterTest.php @@ -19,6 +19,7 @@ use Doctrine\ORM\EntityManagerInterface; /** * @internal + * * @coversNothing */ final class BySocialActionFilterTest extends AbstractFilterTest diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/BySocialIssueFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/BySocialIssueFilterTest.php index ee2360a4e..47f45ceb5 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/BySocialIssueFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/BySocialIssueFilterTest.php @@ -20,6 +20,7 @@ use Doctrine\ORM\EntityManagerInterface; /** * @internal + * * @coversNothing */ final class BySocialIssueFilterTest extends AbstractFilterTest diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityDateFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityDateFilterTest.php index 88bcc9bb7..4cefb136a 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityDateFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityDateFilterTest.php @@ -15,11 +15,11 @@ use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Export\Filter\ActivityDateFilter; use Chill\MainBundle\Service\RollingDate\RollingDate; use Chill\MainBundle\Test\Export\AbstractFilterTest; -use DateTime; use Doctrine\ORM\EntityManagerInterface; /** * @internal + * * @coversNothing */ final class ActivityDateFilterTest extends AbstractFilterTest @@ -54,10 +54,9 @@ final class ActivityDateFilterTest extends AbstractFilterTest $em = self::$container->get(EntityManagerInterface::class); - yield - $em->createQueryBuilder() - ->select('count(activity.id)') - ->from(Activity::class, 'activity'); + yield $em->createQueryBuilder() + ->select('count(activity.id)') + ->from(Activity::class, 'activity'); self::ensureKernelShutdown(); } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityReasonFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityReasonFilterTest.php index 6282200de..3d1f1fa2d 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityReasonFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityReasonFilterTest.php @@ -20,6 +20,7 @@ use Symfony\Component\HttpFoundation\RequestStack; /** * @internal + * * @coversNothing */ final class ActivityReasonFilterTest extends AbstractFilterTest @@ -56,7 +57,7 @@ final class ActivityReasonFilterTest extends AbstractFilterTest ->get(EntityManagerInterface::class); $reasons = $em->createQuery('SELECT reason ' - . 'FROM ChillActivityBundle:ActivityReason reason') + .'FROM ChillActivityBundle:ActivityReason reason') ->getResult(); // generate an array of 5 different combination of results @@ -76,11 +77,11 @@ final class ActivityReasonFilterTest extends AbstractFilterTest yield $em->createQueryBuilder() ->select('count(activity.id)') ->from('ChillActivityBundle:Activity', 'activity'); - yield $em->createQueryBuilder() + yield $em->createQueryBuilder() ->select('count(activity.id)') ->from('ChillActivityBundle:Activity', 'activity') ->join('activity.reasons', 'reasons'); - yield $em->createQueryBuilder() + yield $em->createQueryBuilder() ->select('count(activity.id)') ->from('ChillActivityBundle:Activity', 'activity') ->join('activity.reasons', 'reasons') diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityTypeFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityTypeFilterTest.php index e0b590e75..5f94b4579 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityTypeFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityTypeFilterTest.php @@ -20,6 +20,7 @@ use Doctrine\ORM\EntityManagerInterface; /** * @internal + * * @coversNothing */ final class ActivityTypeFilterTest extends AbstractFilterTest @@ -67,10 +68,9 @@ final class ActivityTypeFilterTest extends AbstractFilterTest $em = self::$container->get(EntityManagerInterface::class); - yield - $em->createQueryBuilder() - ->select('count(activity.id)') - ->from(Activity::class, 'activity'); + yield $em->createQueryBuilder() + ->select('count(activity.id)') + ->from(Activity::class, 'activity'); self::ensureKernelShutdown(); } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ByCreatorFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ByCreatorFilterTest.php index 2a00bc2aa..d5073b625 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ByCreatorFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ByCreatorFilterTest.php @@ -19,6 +19,7 @@ use Doctrine\ORM\EntityManagerInterface; /** * @internal + * * @coversNothing */ final class ByCreatorFilterTest extends AbstractFilterTest diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/EmergencyFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/EmergencyFilterTest.php index 22b109207..5ef1879a7 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/EmergencyFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/EmergencyFilterTest.php @@ -18,6 +18,7 @@ use Doctrine\ORM\EntityManagerInterface; /** * @internal + * * @coversNothing */ final class EmergencyFilterTest extends AbstractFilterTest diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/LocationTypeFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/LocationTypeFilterTest.php index 94537acb2..bf52ceee1 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/LocationTypeFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/LocationTypeFilterTest.php @@ -19,6 +19,7 @@ use Doctrine\ORM\EntityManagerInterface; /** * @internal + * * @coversNothing */ final class LocationTypeFilterTest extends AbstractFilterTest diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/PersonFilters/ActivityReasonFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/PersonFilters/ActivityReasonFilterTest.php index 6c28b846e..6ad78579e 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/PersonFilters/ActivityReasonFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/PersonFilters/ActivityReasonFilterTest.php @@ -20,6 +20,7 @@ use Doctrine\ORM\EntityManagerInterface; /** * @internal + * * @coversNothing */ final class ActivityReasonFilterTest extends AbstractFilterTest diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilterTest.php index df14c2baf..34a9c8303 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilterTest.php @@ -15,11 +15,11 @@ use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Entity\ActivityReason; use Chill\ActivityBundle\Export\Filter\PersonFilters\PersonHavingActivityBetweenDateFilter; use Chill\MainBundle\Test\Export\AbstractFilterTest; -use DateTime; use Doctrine\ORM\EntityManagerInterface; /** * @internal + * * @coversNothing */ final class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest @@ -54,8 +54,8 @@ final class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest foreach ($array as $a) { $data[] = [ - 'date_from' => DateTime::createFromFormat('Y-m-d', '2021-07-01'), - 'date_to' => DateTime::createFromFormat('Y-m-d', '2022-07-01'), + 'date_from' => \DateTime::createFromFormat('Y-m-d', '2021-07-01'), + 'date_to' => \DateTime::createFromFormat('Y-m-d', '2022-07-01'), 'reasons' => [$a], ]; } @@ -75,8 +75,7 @@ final class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest $em->createQueryBuilder() ->select('count(activity.id)') ->from(Activity::class, 'activity') - ->join('activity.person', 'person') - , + ->join('activity.person', 'person'), ]; } } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/PersonHavingActivityBetweenDateFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/PersonHavingActivityBetweenDateFilterTest.php index 1552b951f..a2ea7c158 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/PersonHavingActivityBetweenDateFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/PersonHavingActivityBetweenDateFilterTest.php @@ -14,15 +14,14 @@ namespace Chill\ActivityBundle\Tests\Export\Filter; use Chill\ActivityBundle\Export\Filter\PersonFilters\PersonHavingActivityBetweenDateFilter; use Chill\ActivityBundle\Repository\ActivityReasonRepository; use Chill\MainBundle\Test\Export\AbstractFilterTest; -use DateTime; use Doctrine\ORM\EntityManagerInterface; use Doctrine\Persistence\ManagerRegistry; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; -use function array_slice; /** * @internal + * * @coversNothing */ final class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest @@ -51,8 +50,8 @@ final class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest public function getFormData() { - $date_from = DateTime::createFromFormat('Y-m-d', '2015-01-15'); - $date_to = new DateTime(); // today + $date_from = \DateTime::createFromFormat('Y-m-d', '2015-01-15'); + $date_to = new \DateTime(); // today $reasons = $this->getActivityReasons(); $data = []; @@ -61,7 +60,7 @@ final class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest $data[] = [ 'date_from' => $date_from, 'date_to' => $date_to, - 'reasons' => array_slice($reasons, 0, 1 + $i), + 'reasons' => \array_slice($reasons, 0, 1 + $i), ]; } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/SentReceivedFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/SentReceivedFilterTest.php index 2c87b00ce..f368e69fa 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/SentReceivedFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/SentReceivedFilterTest.php @@ -18,6 +18,7 @@ use Doctrine\ORM\EntityManagerInterface; /** * @internal + * * @coversNothing */ final class SentReceivedFilterTest extends AbstractFilterTest diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/UserFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/UserFilterTest.php index d49739c7e..ef8f4c6b2 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/UserFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/UserFilterTest.php @@ -19,6 +19,7 @@ use Doctrine\ORM\EntityManagerInterface; /** * @internal + * * @coversNothing */ final class UserFilterTest extends AbstractFilterTest diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/UserScopeFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/UserScopeFilterTest.php index 0e38e92a6..858931327 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/UserScopeFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/UserScopeFilterTest.php @@ -19,6 +19,7 @@ use Doctrine\ORM\EntityManagerInterface; /** * @internal + * * @coversNothing */ final class UserScopeFilterTest extends AbstractFilterTest diff --git a/src/Bundle/ChillActivityBundle/Tests/Form/ActivityTypeTest.php b/src/Bundle/ChillActivityBundle/Tests/Form/ActivityTypeTest.php index bdaef0bbf..3d1b31f08 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Form/ActivityTypeTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Form/ActivityTypeTest.php @@ -13,14 +13,13 @@ namespace Chill\ActivityBundle\Tests\Form; use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Form\ActivityType; -use DateTime; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Component\Form\Extension\Core\Type\FormType; use Symfony\Component\Security\Core\Authentication\Token\AbstractToken; -use Symfony\Component\Security\Core\Role\Role; /** * @internal + * * @coversNothing */ final class ActivityTypeTest extends KernelTestCase @@ -140,7 +139,7 @@ final class ActivityTypeTest extends KernelTestCase public function testFormWithActivityHavingDifferentTime() { $activity = new Activity(); - $activity->setDurationTime(DateTime::createFromFormat('U', 60)); + $activity->setDurationTime(\DateTime::createFromFormat('U', 60)); $builder = $this->container ->get('form.factory') diff --git a/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityReasonTest.php b/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityReasonTest.php index 1bfa2878c..014c3ae9f 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityReasonTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityReasonTest.php @@ -20,6 +20,7 @@ use Symfony\Component\Form\Test\TypeTestCase; * Test translatableActivityReason. * * @internal + * * @coversNothing */ final class TranslatableActivityReasonTest extends TypeTestCase diff --git a/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityTypeTest.php b/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityTypeTest.php index 313d77617..80779d909 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityTypeTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Form/Type/TranslatableActivityTypeTest.php @@ -18,6 +18,7 @@ use Symfony\Component\Form\Extension\Core\Type\FormType; /** * @internal + * * @coversNothing */ final class TranslatableActivityTypeTest extends KernelTestCase diff --git a/src/Bundle/ChillActivityBundle/Tests/Repository/ActivityACLAwareRepositoryTest.php b/src/Bundle/ChillActivityBundle/Tests/Repository/ActivityACLAwareRepositoryTest.php index e7b2117d4..88eb3e7f8 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Repository/ActivityACLAwareRepositoryTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Repository/ActivityACLAwareRepositoryTest.php @@ -33,6 +33,7 @@ use Symfony\Component\Security\Core\Security; /** * @internal + * * @coversNothing */ class ActivityACLAwareRepositoryTest extends KernelTestCase @@ -182,7 +183,7 @@ class ActivityACLAwareRepositoryTest extends KernelTestCase if (null === $person = $this->entityManager->createQueryBuilder() ->select('p')->from(Person::class, 'p')->setMaxResults(1) ->getQuery()->getSingleResult()) { - throw new \RuntimeException("person not found"); + throw new \RuntimeException('person not found'); } /** @var AccompanyingPeriod $period1 */ @@ -193,7 +194,7 @@ class ActivityACLAwareRepositoryTest extends KernelTestCase ->setMaxResults(1) ->getQuery() ->getSingleResult()) { - throw new \RuntimeException("no period found"); + throw new \RuntimeException('no period found'); } /** @var AccompanyingPeriod $period2 */ @@ -206,7 +207,7 @@ class ActivityACLAwareRepositoryTest extends KernelTestCase ->setMaxResults(1) ->getQuery() ->getSingleResult()) { - throw new \RuntimeException("no second period found"); + throw new \RuntimeException('no second period found'); } // add a period $period1->addPerson($person); @@ -222,7 +223,7 @@ class ActivityACLAwareRepositoryTest extends KernelTestCase ->setMaxResults(2) ->getQuery() ->getResult()) { - throw new \RuntimeException("no types"); + throw new \RuntimeException('no types'); } if ([] === $jobs = $this->entityManager @@ -233,7 +234,7 @@ class ActivityACLAwareRepositoryTest extends KernelTestCase ->getQuery() ->getResult() ) { - throw new \RuntimeException("no jobs found"); + throw new \RuntimeException('no jobs found'); } if (null === $user = $this->entityManager @@ -244,19 +245,19 @@ class ActivityACLAwareRepositoryTest extends KernelTestCase ->getQuery() ->getSingleResult() ) { - throw new \RuntimeException("no user found"); + throw new \RuntimeException('no user found'); } if ([] === $centers = $this->entityManager->createQueryBuilder() ->select('c')->from(Center::class, 'c')->setMaxResults(2)->getQuery() ->getResult()) { - throw new \RuntimeException("no centers found"); + throw new \RuntimeException('no centers found'); } if ([] === $scopes = $this->entityManager->createQueryBuilder() ->select('s')->from(Scope::class, 's')->setMaxResults(2)->getQuery() ->getResult()) { - throw new \RuntimeException("no scopes found"); + throw new \RuntimeException('no scopes found'); } yield [$person, $user, $centers, $scopes, ActivityVoter::SEE, 0, 5, ['date' => 'DESC'], []]; @@ -279,7 +280,7 @@ class ActivityACLAwareRepositoryTest extends KernelTestCase ->setMaxResults(1) ->getQuery() ->getSingleResult()) { - throw new \RuntimeException("no period found"); + throw new \RuntimeException('no period found'); } if ([] === $types = $this->entityManager @@ -289,7 +290,7 @@ class ActivityACLAwareRepositoryTest extends KernelTestCase ->setMaxResults(2) ->getQuery() ->getResult()) { - throw new \RuntimeException("no types"); + throw new \RuntimeException('no types'); } if ([] === $jobs = $this->entityManager @@ -300,7 +301,7 @@ class ActivityACLAwareRepositoryTest extends KernelTestCase ->getQuery() ->getResult() ) { - throw new \RuntimeException("no jobs found"); + throw new \RuntimeException('no jobs found'); } if (null === $user = $this->entityManager @@ -311,7 +312,7 @@ class ActivityACLAwareRepositoryTest extends KernelTestCase ->getQuery() ->getSingleResult() ) { - throw new \RuntimeException("no user found"); + throw new \RuntimeException('no user found'); } yield [$period, $user, ActivityVoter::SEE, 0, 10, ['date' => 'DESC'], []]; diff --git a/src/Bundle/ChillActivityBundle/Tests/Repository/ActivityDocumentACLAwareRepositoryTest.php b/src/Bundle/ChillActivityBundle/Tests/Repository/ActivityDocumentACLAwareRepositoryTest.php index 74f1d2bd0..c32714641 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Repository/ActivityDocumentACLAwareRepositoryTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Repository/ActivityDocumentACLAwareRepositoryTest.php @@ -20,7 +20,6 @@ use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; use Doctrine\ORM\EntityManagerInterface; -use phpseclib3\Math\BinaryField; use Prophecy\Argument; use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; @@ -28,6 +27,7 @@ use Symfony\Component\Security\Core\Security; /** * @internal + * * @coversNothing */ class ActivityDocumentACLAwareRepositoryTest extends KernelTestCase @@ -104,22 +104,22 @@ class ActivityDocumentACLAwareRepositoryTest extends KernelTestCase { $this->setUp(); - if (null === $person = $this->entityManager->createQuery("SELECT p FROM " . Person::class . " p WHERE SIZE(p.accompanyingPeriodParticipations) > 0 ") + if (null === $person = $this->entityManager->createQuery('SELECT p FROM '.Person::class.' p WHERE SIZE(p.accompanyingPeriodParticipations) > 0 ') ->setMaxResults(1) ->getSingleResult()) { - throw new \RuntimeException("no person in dtabase"); + throw new \RuntimeException('no person in dtabase'); } - if ([] === $scopes = $this->entityManager->createQuery("SELECT s FROM " . Scope::class . " s ")->setMaxResults(5)->getResult()) { - throw new \RuntimeException("no scopes in database"); + if ([] === $scopes = $this->entityManager->createQuery('SELECT s FROM '.Scope::class.' s ')->setMaxResults(5)->getResult()) { + throw new \RuntimeException('no scopes in database'); } yield [$person, [], true, null, null, null]; yield [$person, $scopes, true, null, null, null]; - yield [$person, $scopes, true, new \DateTimeImmutable("1 month ago"), null, null]; - yield [$person, $scopes, true, new \DateTimeImmutable("1 month ago"), new \DateTimeImmutable("1 week ago"), null]; - yield [$person, $scopes, true, new \DateTimeImmutable("1 month ago"), new \DateTimeImmutable("1 week ago"), "content"]; - yield [$person, $scopes, true, null, new \DateTimeImmutable("1 week ago"), "content"]; - yield [$person, [], true, new \DateTimeImmutable("1 month ago"), new \DateTimeImmutable("1 week ago"), "content"]; + yield [$person, $scopes, true, new \DateTimeImmutable('1 month ago'), null, null]; + yield [$person, $scopes, true, new \DateTimeImmutable('1 month ago'), new \DateTimeImmutable('1 week ago'), null]; + yield [$person, $scopes, true, new \DateTimeImmutable('1 month ago'), new \DateTimeImmutable('1 week ago'), 'content']; + yield [$person, $scopes, true, null, new \DateTimeImmutable('1 week ago'), 'content']; + yield [$person, [], true, new \DateTimeImmutable('1 month ago'), new \DateTimeImmutable('1 week ago'), 'content']; } } diff --git a/src/Bundle/ChillActivityBundle/Tests/Security/Authorization/ActivityVoterTest.php b/src/Bundle/ChillActivityBundle/Tests/Security/Authorization/ActivityVoterTest.php index 1fb90a4ae..b907363a3 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Security/Authorization/ActivityVoterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Security/Authorization/ActivityVoterTest.php @@ -24,6 +24,7 @@ use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface; /** * @internal + * * @coversNothing */ final class ActivityVoterTest extends KernelTestCase @@ -127,7 +128,7 @@ final class ActivityVoterTest extends KernelTestCase /** * @dataProvider dataProvider_testVoteAction * - * @param type $expectedResult + * @param type $expectedResult * @param string $attribute * @param string $message */ @@ -156,11 +157,11 @@ final class ActivityVoterTest extends KernelTestCase * * @return \Symfony\Component\Security\Core\Authentication\Token\TokenInterface */ - protected function prepareToken(?User $user = null) + protected function prepareToken(User $user = null) { $token = $this->prophet->prophesize(); $token - ->willImplement('\\' . \Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class); + ->willImplement('\\'.\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class); if (null === $user) { $token->getUser()->willReturn(null); diff --git a/src/Bundle/ChillActivityBundle/Tests/Timeline/TimelineProviderTest.php b/src/Bundle/ChillActivityBundle/Tests/Timeline/TimelineProviderTest.php index 989565262..b7796c9ba 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Timeline/TimelineProviderTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Timeline/TimelineProviderTest.php @@ -15,6 +15,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; /** * @internal + * * @coversNothing */ final class TimelineProviderTest extends WebTestCase diff --git a/src/Bundle/ChillActivityBundle/Timeline/TimelineActivityProvider.php b/src/Bundle/ChillActivityBundle/Timeline/TimelineActivityProvider.php index 5e1e84595..23a75e9fe 100644 --- a/src/Bundle/ChillActivityBundle/Timeline/TimelineActivityProvider.php +++ b/src/Bundle/ChillActivityBundle/Timeline/TimelineActivityProvider.php @@ -19,16 +19,9 @@ use Chill\MainBundle\Timeline\TimelineProviderInterface; use Chill\MainBundle\Timeline\TimelineSingleQuery; use Chill\PersonBundle\Entity\Person; use Doctrine\ORM\EntityManagerInterface; -use LogicException; -use RuntimeException; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; -use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\Security\Core\User\UserInterface; -use function implode; -use function in_array; -use function strtr; - class TimelineActivityProvider implements TimelineProviderInterface { private const SUPPORTED_CONTEXTS = ['center', 'person']; @@ -42,7 +35,7 @@ class TimelineActivityProvider implements TimelineProviderInterface protected ActivityACLAwareRepository $aclAwareRepository ) { if (!$storage->getToken()->getUser() instanceof User) { - throw new RuntimeException('A user should be authenticated !'); + throw new \RuntimeException('A user should be authenticated !'); } $this->user = $storage->getToken()->getUser(); @@ -61,10 +54,10 @@ class TimelineActivityProvider implements TimelineProviderInterface return TimelineSingleQuery::fromArray([ 'id' => $metadataActivity->getTableName() - . '.' . $metadataActivity->getColumnName('id'), + .'.'.$metadataActivity->getColumnName('id'), 'type' => 'activity', 'date' => $metadataActivity->getTableName() - . '.' . $metadataActivity->getColumnName('date'), + .'.'.$metadataActivity->getColumnName('date'), 'FROM' => $this->getFromClausePerson(), 'WHERE' => $where, 'parameters' => $parameters, @@ -106,17 +99,12 @@ class TimelineActivityProvider implements TimelineProviderInterface /** * Check if the context is supported. * - * @throws LogicException if the context is not supported + * @throws \LogicException if the context is not supported */ private function checkContext(string $context) { - if (false === in_array($context, self::SUPPORTED_CONTEXTS, true)) { - throw new LogicException( - sprintf( - "The context '%s' is not supported. Currently only 'person' is supported", - $context - ) - ); + if (false === \in_array($context, self::SUPPORTED_CONTEXTS, true)) { + throw new \LogicException(sprintf("The context '%s' is not supported. Currently only 'person' is supported", $context)); } } @@ -151,8 +139,8 @@ class TimelineActivityProvider implements TimelineProviderInterface // loop on reachable scopes foreach ($reachableScopes as $scope) { - /** @phpstan-ignore-next-line */ - if (in_array($scope->getId(), $scopes_ids, true)) { + /* @phpstan-ignore-next-line */ + if (\in_array($scope->getId(), $scopes_ids, true)) { continue; } $scopes_ids[] = '?'; @@ -160,13 +148,13 @@ class TimelineActivityProvider implements TimelineProviderInterface } return [ - strtr( + \strtr( $whereClause, [ '{activity.person_id}' => $associationMapping['joinColumns'][0]['name'], - '{activity.scope_id}' => $metadataActivity->getTableName() . '.' . + '{activity.scope_id}' => $metadataActivity->getTableName().'.'. $metadataActivity->getAssociationMapping('scope')['joinColumns'][0]['name'], - '{scopes_ids}' => implode(', ', $scopes_ids), + '{scopes_ids}' => \implode(', ', $scopes_ids), ] ), $parameters, diff --git a/src/Bundle/ChillActivityBundle/Validator/Constraints/ActivityValidity.php b/src/Bundle/ChillActivityBundle/Validator/Constraints/ActivityValidity.php index bb1dbc9d3..aafe5f9b5 100644 --- a/src/Bundle/ChillActivityBundle/Validator/Constraints/ActivityValidity.php +++ b/src/Bundle/ChillActivityBundle/Validator/Constraints/ActivityValidity.php @@ -39,6 +39,6 @@ class ActivityValidity extends Constraint public function makeIsRequiredMessage(string $property) { - return self::ROOT_MESSAGE . $property . self::IS_REQUIRED_MESSAGE; + return self::ROOT_MESSAGE.$property.self::IS_REQUIRED_MESSAGE; } } diff --git a/src/Bundle/ChillActivityBundle/Validator/Constraints/ActivityValidityValidator.php b/src/Bundle/ChillActivityBundle/Validator/Constraints/ActivityValidityValidator.php index 11b4b61e0..21ee6185e 100644 --- a/src/Bundle/ChillActivityBundle/Validator/Constraints/ActivityValidityValidator.php +++ b/src/Bundle/ChillActivityBundle/Validator/Constraints/ActivityValidityValidator.php @@ -18,9 +18,6 @@ use Symfony\Component\Validator\ConstraintValidator; use Symfony\Component\Validator\Exception\UnexpectedTypeException; use Symfony\Component\Validator\Exception\UnexpectedValueException; -use function array_merge; -use function count; - class ActivityValidityValidator extends ConstraintValidator { public function validate($activity, Constraint $constraint) @@ -33,106 +30,106 @@ class ActivityValidityValidator extends ConstraintValidator throw new UnexpectedValueException($activity, Activity::class); } - if ($activity->getActivityType()->getPersonsVisible() === 2 && count($activity->getPersons()) === 0) { + if (2 === $activity->getActivityType()->getPersonsVisible() && 0 === \count($activity->getPersons())) { $this->context ->buildViolation($constraint->noPersonsMessage) ->addViolation(); } - if ($activity->getActivityType()->getUsersVisible() === 2 && count($activity->getUsers()) === 0) { + if (2 === $activity->getActivityType()->getUsersVisible() && 0 === \count($activity->getUsers())) { $this->context ->buildViolation($constraint->noUsersMessage) ->addViolation(); } - if ($activity->getActivityType()->getThirdPartiesVisible() === 2 && count($activity->getThirdParties()) === 0) { + if (2 === $activity->getActivityType()->getThirdPartiesVisible() && 0 === \count($activity->getThirdParties())) { $this->context ->buildViolation($constraint->noThirdPartiesMessage) ->addViolation(); } - if ($activity->getActivityType()->getUserVisible() === 2 && null === $activity->getUser()) { + if (2 === $activity->getActivityType()->getUserVisible() && null === $activity->getUser()) { $this->context ->buildViolation($constraint->makeIsRequiredMessage('user')) ->addViolation(); } - if ($activity->getActivityType()->getDateVisible() === 2 && null === $activity->getDate()) { + if (2 === $activity->getActivityType()->getDateVisible() && null === $activity->getDate()) { $this->context ->buildViolation($constraint->makeIsRequiredMessage('date')) ->addViolation(); } - if ($activity->getActivityType()->getLocationVisible() === 2 && null === $activity->getLocation()) { + if (2 === $activity->getActivityType()->getLocationVisible() && null === $activity->getLocation()) { $this->context ->buildViolation($constraint->makeIsRequiredMessage('location')) ->addViolation(); } - if ($activity->getActivityType()->getDurationTimeVisible() === 2 && null === $activity->getDurationTime()) { + if (2 === $activity->getActivityType()->getDurationTimeVisible() && null === $activity->getDurationTime()) { $this->context ->buildViolation($constraint->makeIsRequiredMessage('duration time')) ->addViolation(); } - if ($activity->getActivityType()->getTravelTimeVisible() === 2 && null === $activity->getTravelTime()) { + if (2 === $activity->getActivityType()->getTravelTimeVisible() && null === $activity->getTravelTime()) { $this->context ->buildViolation($constraint->makeIsRequiredMessage('travel time')) ->addViolation(); } - if ($activity->getActivityType()->getAttendeeVisible() === 2 && null === $activity->getAttendee()) { + if (2 === $activity->getActivityType()->getAttendeeVisible() && null === $activity->getAttendee()) { $this->context ->buildViolation($constraint->makeIsRequiredMessage('attendee')) ->addViolation(); } - if ($activity->getActivityType()->getReasonsVisible() === 2 && null === $activity->getReasons()) { + if (2 === $activity->getActivityType()->getReasonsVisible() && null === $activity->getReasons()) { $this->context ->buildViolation($constraint->makeIsRequiredMessage('reasons')) ->addViolation(); } - if ($activity->getActivityType()->getCommentVisible() === 2 && null === $activity->getComment()) { + if (2 === $activity->getActivityType()->getCommentVisible() && null === $activity->getComment()) { $this->context ->buildViolation($constraint->makeIsRequiredMessage('comment')) ->addViolation(); } - if ($activity->getActivityType()->getSentReceivedVisible() === 2 && null === $activity->getSentReceived()) { + if (2 === $activity->getActivityType()->getSentReceivedVisible() && null === $activity->getSentReceived()) { $this->context ->buildViolation($constraint->makeIsRequiredMessage('sent/received')) ->addViolation(); } - if ($activity->getActivityType()->getDocumentsVisible() === 2 && null === $activity->getDocuments()) { + if (2 === $activity->getActivityType()->getDocumentsVisible() && null === $activity->getDocuments()) { $this->context ->buildViolation($constraint->makeIsRequiredMessage('document')) ->addViolation(); } - if ($activity->getActivityType()->getEmergencyVisible() === 2 && null === $activity->getEmergency()) { + if (2 === $activity->getActivityType()->getEmergencyVisible() && null === $activity->getEmergency()) { $this->context ->buildViolation($constraint->makeIsRequiredMessage('emergency')) ->addViolation(); } - if ($activity->getActivityType()->getSocialIssuesVisible() === 2 && $activity->getSocialIssues()->count() === 0) { + if (2 === $activity->getActivityType()->getSocialIssuesVisible() && 0 === $activity->getSocialIssues()->count()) { $this->context ->buildViolation($constraint->socialIssuesMessage) ->addViolation(); } - if ($activity->getActivityType()->getSocialActionsVisible() === 2 && $activity->getSocialActions()->count() === 0) { + if (2 === $activity->getActivityType()->getSocialActionsVisible() && 0 === $activity->getSocialActions()->count()) { // check if a social action may be added $actions = []; foreach ($activity->getSocialIssues() as $socialIssue) { /** @var SocialIssue $socialIssue */ - $actions = array_merge($actions, $socialIssue->getRecursiveSocialActions()->toArray()); + $actions = \array_merge($actions, $socialIssue->getRecursiveSocialActions()->toArray()); } - if (0 < count($actions)) { + if (0 < \count($actions)) { $this->context ->buildViolation($constraint->socialActionsMessage) ->addViolation(); diff --git a/src/Bundle/ChillActivityBundle/migrations/Version20150701091248.php b/src/Bundle/ChillActivityBundle/migrations/Version20150701091248.php index f96762748..5a050035a 100644 --- a/src/Bundle/ChillActivityBundle/migrations/Version20150701091248.php +++ b/src/Bundle/ChillActivityBundle/migrations/Version20150701091248.php @@ -22,7 +22,7 @@ class Version20150701091248 extends AbstractMigration public function down(Schema $schema): void { // this down() migration is auto-generated, please modify it to your needs - $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('ALTER TABLE Activity DROP CONSTRAINT FK_55026B0C59BB1592'); $this->addSql('ALTER TABLE ActivityReason DROP CONSTRAINT FK_654A2FCD12469DE2'); @@ -40,7 +40,7 @@ class Version20150701091248 extends AbstractMigration public function up(Schema $schema): void { // this up() migration is auto-generated, please modify it to your needs - $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('CREATE SEQUENCE Activity_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); $this->addSql('CREATE SEQUENCE ActivityReason_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); diff --git a/src/Bundle/ChillActivityBundle/migrations/Version20150702093317.php b/src/Bundle/ChillActivityBundle/migrations/Version20150702093317.php index f8dc40e95..053e4ecc8 100644 --- a/src/Bundle/ChillActivityBundle/migrations/Version20150702093317.php +++ b/src/Bundle/ChillActivityBundle/migrations/Version20150702093317.php @@ -22,7 +22,7 @@ class Version20150702093317 extends AbstractMigration public function down(Schema $schema): void { // this down() migration is auto-generated, please modify it to your needs - $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('ALTER TABLE ActivityReasonCategory DROP COLUMN name;'); $this->addSql('ALTER TABLE ActivityReasonCategory ADD COLUMN label VARCHAR(255) NOT NULL;'); @@ -35,7 +35,7 @@ class Version20150702093317 extends AbstractMigration public function up(Schema $schema): void { // this up() migration is auto-generated, please modify it to your needs - $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('ALTER TABLE ActivityReasonCategory DROP COLUMN label;'); $this->addSql('ALTER TABLE ActivityReasonCategory ADD COLUMN name JSON;'); diff --git a/src/Bundle/ChillActivityBundle/migrations/Version20150704091347.php b/src/Bundle/ChillActivityBundle/migrations/Version20150704091347.php index 6509701cc..78204fa67 100644 --- a/src/Bundle/ChillActivityBundle/migrations/Version20150704091347.php +++ b/src/Bundle/ChillActivityBundle/migrations/Version20150704091347.php @@ -22,7 +22,7 @@ class Version20150704091347 extends AbstractMigration public function down(Schema $schema): void { // this down() migration is auto-generated, please modify it to your needs - $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('ALTER TABLE Activity ALTER COLUMN remark SET NOT NULL;'); $this->addSql('ALTER TABLE Activity ALTER COLUMN attendee DROP NOT NULL;'); @@ -31,7 +31,7 @@ class Version20150704091347 extends AbstractMigration public function up(Schema $schema): void { // this up() migration is auto-generated, please modify it to your needs - $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('ALTER TABLE Activity ALTER COLUMN remark DROP NOT NULL;'); $this->addSql('ALTER TABLE Activity ALTER COLUMN attendee DROP NOT NULL;'); diff --git a/src/Bundle/ChillActivityBundle/migrations/Version20160222103457.php b/src/Bundle/ChillActivityBundle/migrations/Version20160222103457.php index 1531230c1..ceb0e59e6 100644 --- a/src/Bundle/ChillActivityBundle/migrations/Version20160222103457.php +++ b/src/Bundle/ChillActivityBundle/migrations/Version20160222103457.php @@ -25,14 +25,14 @@ class Version20160222103457 extends AbstractMigration public function down(Schema $schema): void { $this->abortIf( - $this->connection->getDatabasePlatform()->getName() !== 'postgresql', + 'postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.' ); $this->addSql('ALTER TABLE Activity ADD reason_id INT DEFAULT NULL'); $this->addSql('ALTER TABLE Activity ADD CONSTRAINT ' - . 'fk_55026b0c59bb1592 FOREIGN KEY (reason_id) ' - . 'REFERENCES activityreason (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + .'fk_55026b0c59bb1592 FOREIGN KEY (reason_id) ' + .'REFERENCES activityreason (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); $this->addSql('CREATE INDEX idx_55026b0c59bb1592 ON Activity (reason_id)'); // try to keep at least on activity reason... @@ -52,29 +52,29 @@ class Version20160222103457 extends AbstractMigration public function up(Schema $schema): void { $this->abortIf( - $this->connection->getDatabasePlatform()->getName() !== 'postgresql', + 'postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.' ); // create the new table activity reason $this->addSql( 'CREATE TABLE activity_activityreason (' - . 'activity_id INT NOT NULL, ' - . 'activityreason_id INT NOT NULL, ' - . 'PRIMARY KEY(activity_id, activityreason_id))' + .'activity_id INT NOT NULL, ' + .'activityreason_id INT NOT NULL, ' + .'PRIMARY KEY(activity_id, activityreason_id))' ); $this->addSql('CREATE INDEX IDX_338A864381C06096 ON activity_activityreason (activity_id)'); $this->addSql('CREATE INDEX IDX_338A8643D771E0FC ON activity_activityreason (activityreason_id)'); $this->addSql('ALTER TABLE activity_activityreason ' - . 'ADD CONSTRAINT FK_338A864381C06096 FOREIGN KEY (activity_id) ' - . 'REFERENCES Activity (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + .'ADD CONSTRAINT FK_338A864381C06096 FOREIGN KEY (activity_id) ' + .'REFERENCES Activity (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); $this->addSql('ALTER TABLE activity_activityreason ' - . 'ADD CONSTRAINT FK_338A8643D771E0FC FOREIGN KEY (activityreason_id) ' - . 'REFERENCES ActivityReason (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + .'ADD CONSTRAINT FK_338A8643D771E0FC FOREIGN KEY (activityreason_id) ' + .'REFERENCES ActivityReason (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); // migrate old data to new table $this->addSql('INSERT INTO activity_activityreason (activity_id, activityreason_id) ' - . 'SELECT id, reason_id FROM activity WHERE reason_id IS NOT NULL'); + .'SELECT id, reason_id FROM activity WHERE reason_id IS NOT NULL'); // remove old column $this->addSql('ALTER TABLE activity DROP CONSTRAINT fk_55026b0c59bb1592'); diff --git a/src/Bundle/ChillActivityBundle/migrations/Version20210422073711.php b/src/Bundle/ChillActivityBundle/migrations/Version20210422073711.php index ec321faa7..9be59b2b9 100644 --- a/src/Bundle/ChillActivityBundle/migrations/Version20210422073711.php +++ b/src/Bundle/ChillActivityBundle/migrations/Version20210422073711.php @@ -14,8 +14,6 @@ namespace Chill\Migrations\Activity; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; -use function count; - /** * Auto-generated Migration: Please modify to your needs! */ @@ -49,8 +47,8 @@ final class Version20210422073711 extends AbstractMigration 'Domicile erronéee', ]; - for ($i = 1; count($list) >= $i; ++$i) { - $this->addSql('INSERT INTO activitytpresence VALUES(' . $i . ", json_build_object('fr', '" . $list[$i - 1] . "'), true)"); + for ($i = 1; \count($list) >= $i; ++$i) { + $this->addSql('INSERT INTO activitytpresence VALUES('.$i.", json_build_object('fr', '".$list[$i - 1]."'), true)"); } $this->addSql('ALTER TABLE activity ADD emergency BOOLEAN NOT NULL DEFAULT false'); diff --git a/src/Bundle/ChillActivityBundle/migrations/Version20210422123846.php b/src/Bundle/ChillActivityBundle/migrations/Version20210422123846.php index 18711bad0..110ca24b2 100644 --- a/src/Bundle/ChillActivityBundle/migrations/Version20210422123846.php +++ b/src/Bundle/ChillActivityBundle/migrations/Version20210422123846.php @@ -58,7 +58,7 @@ final class Version20210422123846 extends AbstractMigration $this->addSql('ALTER TABLE activity_thirdparty ADD CONSTRAINT FK_C6F0DE0381C06096 FOREIGN KEY (activity_id) REFERENCES activity (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); $this->addSql('ALTER TABLE activity_thirdparty ADD CONSTRAINT FK_C6F0DE03C7D3A8E6 FOREIGN KEY (thirdparty_id) REFERENCES chill_3party.third_party (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); $this->addSql('ALTER TABLE activity_document ADD CONSTRAINT FK_78633A7881C06096 FOREIGN KEY (activity_id) REFERENCES activity (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); - //$this->addSql('ALTER TABLE activity_document ADD CONSTRAINT FK_78633A78C33F7837 FOREIGN KEY (document_id) REFERENCES Document (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + // $this->addSql('ALTER TABLE activity_document ADD CONSTRAINT FK_78633A78C33F7837 FOREIGN KEY (document_id) REFERENCES Document (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); $this->addSql('ALTER TABLE activity_user ADD CONSTRAINT FK_8E570DDB81C06096 FOREIGN KEY (activity_id) REFERENCES activity (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); $this->addSql('ALTER TABLE activity_user ADD CONSTRAINT FK_8E570DDBA76ED395 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); diff --git a/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityCategoryController.php b/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityCategoryController.php index 009a9f2c8..602ef1204 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityCategoryController.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityCategoryController.php @@ -23,7 +23,7 @@ class AsideActivityCategoryController extends CRUDController { protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator) { - /** @var QueryBuilder $query */ + /* @var QueryBuilder $query */ $query->addOrderBy('e.ordering', 'ASC'); return $query; diff --git a/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php b/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php index 64301151b..c29a5a6dc 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Controller/AsideActivityController.php @@ -16,7 +16,6 @@ use Chill\AsideActivityBundle\Repository\AsideActivityCategoryRepository; use Chill\MainBundle\CRUD\Controller\CRUDController; use Chill\MainBundle\Pagination\PaginatorInterface; use Chill\MainBundle\Templating\Listing\FilterOrderHelper; -use DateTime; use Symfony\Component\HttpFoundation\Request; final class AsideActivityController extends CRUDController @@ -31,7 +30,7 @@ final class AsideActivityController extends CRUDController $asideActivity->setLocation($this->getUser()->getCurrentLocation()); $duration = $request->query->get('duration', '300'); - $duration = DateTime::createFromFormat('U', $duration); + $duration = \DateTime::createFromFormat('U', $duration); $asideActivity->setDuration($duration); $categoryId = $request->query->get('type', 7); @@ -48,7 +47,7 @@ final class AsideActivityController extends CRUDController return $asideActivity; } - protected function buildQueryEntities(string $action, Request $request, ?FilterOrderHelper $filterOrder = null) + protected function buildQueryEntities(string $action, Request $request, FilterOrderHelper $filterOrder = null) { $qb = parent::buildQueryEntities($action, $request); diff --git a/src/Bundle/ChillAsideActivityBundle/src/DataFixtures/ORM/LoadAsideActivity.php b/src/Bundle/ChillAsideActivityBundle/src/DataFixtures/ORM/LoadAsideActivity.php index 4c11c25ef..12c82be00 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/DataFixtures/ORM/LoadAsideActivity.php +++ b/src/Bundle/ChillAsideActivityBundle/src/DataFixtures/ORM/LoadAsideActivity.php @@ -14,14 +14,10 @@ namespace Chill\AsideActivityBundle\DataFixtures\ORM; use Chill\AsideActivityBundle\Entity\AsideActivity; use Chill\MainBundle\DataFixtures\ORM\LoadUsers; use Chill\MainBundle\Repository\UserRepository; -use DateInterval; -use DateTimeImmutable; use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Common\DataFixtures\DependentFixtureInterface; use Doctrine\Persistence\ObjectManager; -use function random_int; - class LoadAsideActivity extends Fixture implements DependentFixtureInterface { public function __construct(private readonly UserRepository $userRepository) {} @@ -42,15 +38,15 @@ class LoadAsideActivity extends Fixture implements DependentFixtureInterface $activity = new AsideActivity(); $activity ->setAgent($user) - ->setCreatedAt(new DateTimeImmutable('now')) + ->setCreatedAt(new \DateTimeImmutable('now')) ->setCreatedBy($user) - ->setUpdatedAt(new DateTimeImmutable('now')) + ->setUpdatedAt(new \DateTimeImmutable('now')) ->setUpdatedBy($user) ->setType( $this->getReference('aside_activity_category_0') ) - ->setDate((new DateTimeImmutable('today')) - ->sub(new DateInterval('P' . random_int(1, 100) . 'D'))); + ->setDate((new \DateTimeImmutable('today')) + ->sub(new \DateInterval('P'.\random_int(1, 100).'D'))); $manager->persist($activity); } diff --git a/src/Bundle/ChillAsideActivityBundle/src/DataFixtures/ORM/LoadAsideActivityCategory.php b/src/Bundle/ChillAsideActivityBundle/src/DataFixtures/ORM/LoadAsideActivityCategory.php index 1d15adbc1..3e6b4247a 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/DataFixtures/ORM/LoadAsideActivityCategory.php +++ b/src/Bundle/ChillAsideActivityBundle/src/DataFixtures/ORM/LoadAsideActivityCategory.php @@ -27,7 +27,7 @@ class LoadAsideActivityCategory extends \Doctrine\Bundle\FixturesBundle\Fixture $category = new AsideActivityCategory(); $category->setTitle(['fr' => $label]); $manager->persist($category); - $this->setReference('aside_activity_category_' . $key, $category); + $this->setReference('aside_activity_category_'.$key, $category); } $manager->flush(); diff --git a/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/ChillAsideActivityExtension.php b/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/ChillAsideActivityExtension.php index 927de1845..056f29ba1 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/ChillAsideActivityExtension.php +++ b/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/ChillAsideActivityExtension.php @@ -26,7 +26,7 @@ final class ChillAsideActivityExtension extends Extension implements PrependExte $container->setParameter('chill_aside_activity.form.time_duration', $config['form']['time_duration']); - $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../config')); + $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../config')); $loader->load('services.yaml'); $loader->load('services/form.yaml'); $loader->load('services/menu.yaml'); @@ -100,7 +100,7 @@ final class ChillAsideActivityExtension extends Extension implements PrependExte protected function prependRoute(ContainerBuilder $container) { - //declare routes for task bundle + // declare routes for task bundle $container->prependExtensionConfig('chill_main', [ 'routing' => [ 'resources' => [ diff --git a/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/Configuration.php b/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/Configuration.php index 2e2398c3e..241a545a8 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillAsideActivityBundle/src/DependencyInjection/Configuration.php @@ -14,8 +14,6 @@ namespace Chill\AsideActivityBundle\DependencyInjection; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; -use function is_int; - class Configuration implements ConfigurationInterface { public function getConfigTreeBuilder() @@ -132,7 +130,7 @@ class Configuration implements ConfigurationInterface ->info('The number of seconds of this duration. Must be an integer.') ->cannotBeEmpty() ->validate() - ->ifTrue(static fn ($data) => !is_int($data))->thenInvalid('The value %s is not a valid integer') + ->ifTrue(static fn ($data) => !\is_int($data))->thenInvalid('The value %s is not a valid integer') ->end() ->end() ->scalarNode('label') diff --git a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivity.php b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivity.php index 3841811eb..2bb8a985d 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivity.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivity.php @@ -15,19 +15,21 @@ use Chill\MainBundle\Doctrine\Model\TrackCreationInterface; use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\Location; -use DateTimeInterface; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; /** * @ORM\Entity + * * @ORM\Table(schema="chill_asideactivity") */ class AsideActivity implements TrackCreationInterface, TrackUpdateInterface { /** * @ORM\ManyToOne(targetEntity=User::class) + * * @ORM\JoinColumn(nullable=false) + * * @Assert\NotBlank */ private \Chill\MainBundle\Entity\User $agent; @@ -39,6 +41,7 @@ class AsideActivity implements TrackCreationInterface, TrackUpdateInterface /** * @ORM\ManyToOne(targetEntity=User::class) + * * @ORM\JoinColumn(nullable=false) */ private \Chill\MainBundle\Entity\User $createdBy; @@ -51,17 +54,20 @@ class AsideActivity implements TrackCreationInterface, TrackUpdateInterface /** * @ORM\Column(type="time", nullable=true) */ - private ?DateTimeInterface $duration = null; + private ?\DateTimeInterface $duration = null; /** * @ORM\Id + * * @ORM\GeneratedValue + * * @ORM\Column(type="integer") */ private ?int $id = null; /** * @ORM\ManyToOne(targetEntity=Location::class) + * * @ORM\JoinColumn(nullable=true) */ private ?Location $location = null; @@ -73,6 +79,7 @@ class AsideActivity implements TrackCreationInterface, TrackUpdateInterface /** * @ORM\ManyToOne(targetEntity=AsideActivityCategory::class, inversedBy="asideActivities") + * * @ORM\JoinColumn(nullable=false) */ private ?\Chill\AsideActivityBundle\Entity\AsideActivityCategory $type = null; @@ -92,7 +99,7 @@ class AsideActivity implements TrackCreationInterface, TrackUpdateInterface return $this->agent; } - public function getCreatedAt(): ?DateTimeInterface + public function getCreatedAt(): ?\DateTimeInterface { return $this->createdAt; } @@ -102,12 +109,12 @@ class AsideActivity implements TrackCreationInterface, TrackUpdateInterface return $this->createdBy; } - public function getDate(): ?DateTimeInterface + public function getDate(): ?\DateTimeInterface { return $this->date; } - public function getDuration(): ?DateTimeInterface + public function getDuration(): ?\DateTimeInterface { return $this->duration; } @@ -132,7 +139,7 @@ class AsideActivity implements TrackCreationInterface, TrackUpdateInterface return $this->type; } - public function getUpdatedAt(): ?DateTimeInterface + public function getUpdatedAt(): ?\DateTimeInterface { return $this->updatedAt; } @@ -149,7 +156,7 @@ class AsideActivity implements TrackCreationInterface, TrackUpdateInterface return $this; } - public function setCreatedAt(DateTimeInterface $createdAt): self + public function setCreatedAt(\DateTimeInterface $createdAt): self { $this->createdAt = $createdAt; @@ -163,14 +170,14 @@ class AsideActivity implements TrackCreationInterface, TrackUpdateInterface return $this; } - public function setDate(DateTimeInterface $date): self + public function setDate(\DateTimeInterface $date): self { $this->date = $date; return $this; } - public function setDuration(?DateTimeInterface $duration): self + public function setDuration(?\DateTimeInterface $duration): self { $this->duration = $duration; @@ -198,7 +205,7 @@ class AsideActivity implements TrackCreationInterface, TrackUpdateInterface return $this; } - public function setUpdatedAt(DateTimeInterface $updatedAt): self + public function setUpdatedAt(\DateTimeInterface $updatedAt): self { $this->updatedAt = $updatedAt; diff --git a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php index 44777f110..be71d73f9 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php @@ -19,19 +19,23 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface; /** * @ORM\Entity + * * @ORM\Table(schema="chill_asideactivity") */ class AsideActivityCategory { /** * @ORM\OneToMany(targetEntity=AsideActivityCategory::class, mappedBy="parent") + * * @var Collection */ private Collection $children; /** * @ORM\Id + * * @ORM\GeneratedValue + * * @ORM\Column(type="integer") */ private int $id; @@ -50,6 +54,7 @@ class AsideActivityCategory /** * @ORM\ManyToOne(targetEntity=AsideActivityCategory::class, inversedBy="children") + * * @ORM\JoinColumn(nullable=true) */ private ?AsideActivityCategory $parent = null; diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByActivityTypeAggregator.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByActivityTypeAggregator.php index 614b0ec79..4271ae118 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByActivityTypeAggregator.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByActivityTypeAggregator.php @@ -45,6 +45,7 @@ class ByActivityTypeAggregator implements AggregatorInterface { // No form needed } + public function getFormDefaultData(): array { return []; diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByLocationAggregator.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByLocationAggregator.php index cbf732274..b5ca1022b 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByLocationAggregator.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByLocationAggregator.php @@ -14,7 +14,6 @@ namespace Chill\AsideActivityBundle\Export\Aggregator; use Chill\AsideActivityBundle\Export\Declarations; use Chill\MainBundle\Export\AggregatorInterface; use Chill\MainBundle\Repository\LocationRepository; -use Closure; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; @@ -22,25 +21,16 @@ class ByLocationAggregator implements AggregatorInterface { public function __construct(private readonly LocationRepository $locationRepository) {} - /** - * @inheritDoc - */ public function buildForm(FormBuilderInterface $builder): void { // no form } - /** - * @inheritDoc - */ public function getFormDefaultData(): array { return []; } - /** - * @inheritDoc - */ public function getLabels($key, array $values, $data) { return function ($value): string { @@ -55,42 +45,27 @@ class ByLocationAggregator implements AggregatorInterface }; } - /** - * @inheritDoc - */ public function getQueryKeys($data): array { return ['by_aside_activity_location_aggregator']; } - /** - * @inheritDoc - */ public function getTitle(): string { return 'export.aggregator.Group by aside activity location'; } - /** - * @inheritDoc - */ public function addRole(): ?string { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data): void { $qb->addSelect('IDENTITY(aside.location) AS by_aside_activity_location_aggregator') ->addGroupBy('by_aside_activity_location_aggregator'); } - /** - * @inheritDoc - */ public function applyOn(): string { return Declarations::ASIDE_ACTIVITY_TYPE; diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserJobAggregator.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserJobAggregator.php index ae4fb8477..c3883b18a 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserJobAggregator.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserJobAggregator.php @@ -39,7 +39,7 @@ class ByUserJobAggregator implements AggregatorInterface $p = self::PREFIX; $qb - ->leftJoin("aside.agent", "{$p}_user") + ->leftJoin('aside.agent', "{$p}_user") ->leftJoin( UserJobHistory::class, "{$p}_history", @@ -49,10 +49,10 @@ class ByUserJobAggregator implements AggregatorInterface // job_at based on aside.date ->andWhere( $qb->expr()->andX( - $qb->expr()->lte("{$p}_history.startDate", "aside.date"), + $qb->expr()->lte("{$p}_history.startDate", 'aside.date'), $qb->expr()->orX( $qb->expr()->isNull("{$p}_history.endDate"), - $qb->expr()->gt("{$p}_history.endDate", "aside.date") + $qb->expr()->gt("{$p}_history.endDate", 'aside.date') ) ) ) @@ -93,7 +93,7 @@ class ByUserJobAggregator implements AggregatorInterface public function getQueryKeys($data): array { - return [self::PREFIX . '_select']; + return [self::PREFIX.'_select']; } public function getTitle(): string diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserScopeAggregator.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserScopeAggregator.php index 6c9690791..a99d2b75f 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserScopeAggregator.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserScopeAggregator.php @@ -39,7 +39,7 @@ class ByUserScopeAggregator implements AggregatorInterface $p = self::PREFIX; $qb - ->leftJoin("aside.agent", "{$p}_user") + ->leftJoin('aside.agent', "{$p}_user") ->leftJoin( UserScopeHistory::class, "{$p}_history", @@ -48,10 +48,10 @@ class ByUserScopeAggregator implements AggregatorInterface ) ->andWhere( $qb->expr()->andX( - $qb->expr()->lte("{$p}_history.startDate", "aside.date"), + $qb->expr()->lte("{$p}_history.startDate", 'aside.date'), $qb->expr()->orX( $qb->expr()->isNull("{$p}_history.endDate"), - $qb->expr()->gt("{$p}_history.endDate", "aside.date") + $qb->expr()->gt("{$p}_history.endDate", 'aside.date') ) ) ) @@ -92,7 +92,7 @@ class ByUserScopeAggregator implements AggregatorInterface public function getQueryKeys($data): array { - return [self::PREFIX . '_select']; + return [self::PREFIX.'_select']; } public function getTitle(): string diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/AvgAsideActivityDuration.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/AvgAsideActivityDuration.php index b3c3f0eb2..70922b6ae 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/AvgAsideActivityDuration.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/AvgAsideActivityDuration.php @@ -18,7 +18,6 @@ use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; use Doctrine\ORM\Query; -use LogicException; use Symfony\Component\Form\FormBuilderInterface; class AvgAsideActivityDuration implements ExportInterface, GroupedExportInterface @@ -50,7 +49,7 @@ class AvgAsideActivityDuration implements ExportInterface, GroupedExportInterfac public function getLabels($key, array $values, $data) { if ('export_avg_aside_activity_duration' !== $key) { - throw new LogicException("the key {$key} is not used by this export"); + throw new \LogicException("the key {$key} is not used by this export"); } return static fn ($value) => '_header' === $value ? 'Average duration aside activities' : $value; diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php index cfe5082aa..6d1eed5fe 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/CountAsideActivity.php @@ -18,7 +18,6 @@ use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; use Doctrine\ORM\Query; -use LogicException; use Symfony\Component\Form\FormBuilderInterface; class CountAsideActivity implements ExportInterface, GroupedExportInterface @@ -26,6 +25,7 @@ class CountAsideActivity implements ExportInterface, GroupedExportInterface public function __construct(private readonly AsideActivityRepository $repository) {} public function buildForm(FormBuilderInterface $builder) {} + public function getFormDefaultData(): array { return []; @@ -49,7 +49,7 @@ class CountAsideActivity implements ExportInterface, GroupedExportInterface public function getLabels($key, array $values, $data) { if ('export_result' !== $key) { - throw new LogicException("the key {$key} is not used by this export"); + throw new \LogicException("the key {$key} is not used by this export"); } $labels = array_combine($values, $values); diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/ListAsideActivity.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/ListAsideActivity.php index 0981c6bf8..33155c62f 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/ListAsideActivity.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/ListAsideActivity.php @@ -26,11 +26,8 @@ use Chill\MainBundle\Repository\CenterRepositoryInterface; use Chill\MainBundle\Repository\LocationRepository; use Chill\MainBundle\Repository\ScopeRepositoryInterface; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; -use DateTimeInterface; use Doctrine\ORM\AbstractQuery; use Doctrine\ORM\EntityManagerInterface; -use Doctrine\ORM\QueryBuilder; -use LogicException; use Symfony\Component\Form\FormBuilderInterface; final readonly class ListAsideActivity implements ListInterface, GroupedExportInterface @@ -74,28 +71,28 @@ final readonly class ListAsideActivity implements ListInterface, GroupedExportIn return match ($key) { 'id', 'note' => static function ($value) use ($key) { if ('_header' === $value) { - return 'export.aside_activity.' . $key; + return 'export.aside_activity.'.$key; } return $value ?? ''; }, 'duration' => static function ($value) use ($key) { if ('_header' === $value) { - return 'export.aside_activity.' . $key; + return 'export.aside_activity.'.$key; } if (null === $value) { return ''; } - if ($value instanceof DateTimeInterface) { + if ($value instanceof \DateTimeInterface) { return $value->format('H:i:s'); } return $value; }, - 'createdAt', 'updatedAt', 'date' => $this->dateTimeHelper->getLabel('export.aside_activity.' . $key), - 'agent_id', 'creator_id' => $this->userHelper->getLabel($key, $values, 'export.aside_activity.' . $key), + 'createdAt', 'updatedAt', 'date' => $this->dateTimeHelper->getLabel('export.aside_activity.'.$key), + 'agent_id', 'creator_id' => $this->userHelper->getLabel($key, $values, 'export.aside_activity.'.$key), 'aside_activity_type' => function ($value) { if ('_header' === $value) { return 'export.aside_activity.aside_activity_type'; @@ -135,13 +132,13 @@ final readonly class ListAsideActivity implements ListInterface, GroupedExportIn } if (null === $value || '' === $value || null === $c = $this->centerRepository->find($value)) { - /** @var Center $c */ + /* @var Center $c */ return ''; } return $c->getName(); }, - default => throw new LogicException('this key is not supported : ' . $key), + default => throw new \LogicException('this key is not supported : '.$key), }; } diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/SumAsideActivityDuration.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/SumAsideActivityDuration.php index 316dedc45..0fd318902 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/SumAsideActivityDuration.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/SumAsideActivityDuration.php @@ -18,7 +18,6 @@ use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; use Doctrine\ORM\Query; -use LogicException; use Symfony\Component\Form\FormBuilderInterface; class SumAsideActivityDuration implements ExportInterface, GroupedExportInterface @@ -26,6 +25,7 @@ class SumAsideActivityDuration implements ExportInterface, GroupedExportInterfac public function __construct(private readonly AsideActivityRepository $repository) {} public function buildForm(FormBuilderInterface $builder) {} + public function getFormDefaultData(): array { return []; @@ -49,7 +49,7 @@ class SumAsideActivityDuration implements ExportInterface, GroupedExportInterfac public function getLabels($key, array $values, $data) { if ('export_sum_aside_activity_duration' !== $key) { - throw new LogicException("the key {$key} is not used by this export"); + throw new \LogicException("the key {$key} is not used by this export"); } return static fn ($value) => '_header' === $value ? 'Sum duration aside activities' : $value; diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByActivityTypeFilter.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByActivityTypeFilter.php index 5b2bb49ae..b78640d49 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByActivityTypeFilter.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByActivityTypeFilter.php @@ -66,6 +66,7 @@ class ByActivityTypeFilter implements FilterInterface }, ]); } + public function getFormDefaultData(): array { return []; diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByDateFilter.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByDateFilter.php index 99e79b028..8f3c9c305 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByDateFilter.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByDateFilter.php @@ -82,14 +82,14 @@ class ByDateFilter implements FilterInterface if (null === $date_from) { $form->get('date_from')->addError(new FormError( $this->translator->trans('This field ' - . 'should not be empty') + .'should not be empty') )); } if (null === $date_to) { $form->get('date_to')->addError(new FormError( $this->translator->trans('This field ' - . 'should not be empty') + .'should not be empty') )); } @@ -100,13 +100,14 @@ class ByDateFilter implements FilterInterface ) { $form->get('date_to')->addError(new FormError( $this->translator->trans('export.filter.This date should be after ' - . 'the date given in "Implied in an aside activity after ' - . 'this date" field') + .'the date given in "Implied in an aside activity after ' + .'this date" field') )); } } }); } + public function getFormDefaultData(): array { return ['date_from' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), 'date_to' => new RollingDate(RollingDate::T_TODAY)]; diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByLocationFilter.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByLocationFilter.php index a1f51273c..0be041dc9 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByLocationFilter.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByLocationFilter.php @@ -16,9 +16,7 @@ use Chill\MainBundle\Entity\Location; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Form\Type\PickUserLocationType; -use Chill\MainBundle\Repository\LocationRepository; use Doctrine\ORM\QueryBuilder; -use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Security\Core\Security; @@ -28,26 +26,17 @@ final readonly class ByLocationFilter implements FilterInterface private Security $security ) {} - /** - * @inheritDoc - */ public function getTitle(): string { return 'export.filter.Filter by aside activity location'; } - /** - * @inheritDoc - */ public function buildForm(FormBuilderInterface $builder): void { $builder ->add('locations', PickUserLocationType::class); } - /** - * @inheritDoc - */ public function getFormDefaultData(): array { $user = $this->security->getUser(); @@ -63,9 +52,6 @@ final readonly class ByLocationFilter implements FilterInterface ]; } - /** - * @inheritDoc - */ public function describeAction($data, $format = 'string'): array { $locations = $data['locations']->map(fn (Location $l): string => $l->getName()); @@ -75,17 +61,11 @@ final readonly class ByLocationFilter implements FilterInterface ]]; } - /** - * @inheritDoc - */ public function addRole(): ?string { return null; } - /** - * @inheritDoc - */ public function alterQuery(QueryBuilder $qb, $data): void { $clause = $qb->expr()->in('aside.location', ':locations'); @@ -94,9 +74,6 @@ final readonly class ByLocationFilter implements FilterInterface $qb->setParameter('locations', $data['locations']); } - /** - * @inheritDoc - */ public function applyOn(): string { return Declarations::ASIDE_ACTIVITY_TYPE; diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserFilter.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserFilter.php index a46bad3b5..8dd1a8eac 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserFilter.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserFilter.php @@ -48,6 +48,7 @@ class ByUserFilter implements FilterInterface 'label' => 'Creators', ]); } + public function getFormDefaultData(): array { return []; diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserJobFilter.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserJobFilter.php index 69aaa376f..3d5bb6530 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserJobFilter.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserJobFilter.php @@ -41,19 +41,19 @@ class ByUserJobFilter implements FilterInterface $qb ->andWhere( $qb->expr()->exists( - "SELECT 1 FROM " . AsideActivity::class . " {$p}_act " - . "JOIN {$p}_act.agent {$p}_user " - . "JOIN " . UserJobHistory::class . " {$p}_history WITH {$p}_history.user = {$p}_user " - . "WHERE {$p}_act = aside " + 'SELECT 1 FROM '.AsideActivity::class." {$p}_act " + ."JOIN {$p}_act.agent {$p}_user " + .'JOIN '.UserJobHistory::class." {$p}_history WITH {$p}_history.user = {$p}_user " + ."WHERE {$p}_act = aside " // job_at based on aside.date - . "AND {$p}_history.startDate <= aside.date " - . "AND ({$p}_history.endDate IS NULL OR {$p}_history.endDate > aside.date) " - . "AND {$p}_history.job IN ( :{$p}_jobs )" + ."AND {$p}_history.startDate <= aside.date " + ."AND ({$p}_history.endDate IS NULL OR {$p}_history.endDate > aside.date) " + ."AND {$p}_history.job IN ( :{$p}_jobs )" ) ) ->setParameter( "{$p}_jobs", - $data["jobs"], + $data['jobs'], ); } diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserScopeFilter.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserScopeFilter.php index bcaabdcea..846814785 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserScopeFilter.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserScopeFilter.php @@ -43,19 +43,19 @@ class ByUserScopeFilter implements FilterInterface $qb ->andWhere( $qb->expr()->exists( - "SELECT 1 FROM " . AsideActivity::class . " {$p}_act " - . "JOIN {$p}_act.agent {$p}_user " - . "JOIN " . UserScopeHistory::class . " {$p}_history WITH {$p}_history.user = {$p}_user " - . "WHERE {$p}_act = aside " + 'SELECT 1 FROM '.AsideActivity::class." {$p}_act " + ."JOIN {$p}_act.agent {$p}_user " + .'JOIN '.UserScopeHistory::class." {$p}_history WITH {$p}_history.user = {$p}_user " + ."WHERE {$p}_act = aside " // scope_at based on aside.date - . "AND {$p}_history.startDate <= aside.date " - . "AND ({$p}_history.endDate IS NULL OR {$p}_history.endDate > aside.date) " - . "AND {$p}_history.scope IN ( :{$p}_scopes )" + ."AND {$p}_history.startDate <= aside.date " + ."AND ({$p}_history.endDate IS NULL OR {$p}_history.endDate > aside.date) " + ."AND {$p}_history.scope IN ( :{$p}_scopes )" ) ) ->setParameter( "{$p}_scopes", - $data["scopes"], + $data['scopes'], ); } diff --git a/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php b/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php index d1be3adcf..d6fcb821c 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php @@ -13,16 +13,10 @@ namespace Chill\AsideActivityBundle\Form; use Chill\AsideActivityBundle\Entity\AsideActivity; use Chill\AsideActivityBundle\Form\Type\PickAsideActivityCategoryType; -use Chill\MainBundle\Entity\Location; use Chill\MainBundle\Form\Type\ChillDateType; use Chill\MainBundle\Form\Type\ChillTextareaType; use Chill\MainBundle\Form\Type\PickUserDynamicType; use Chill\MainBundle\Form\Type\PickUserLocationType; -use DateInterval; -use DateTime; -use DateTimeImmutable; -use DateTimeZone; -use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToTimestampTransformer; @@ -32,8 +26,6 @@ use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvents; use Symfony\Component\OptionsResolver\OptionsResolver; -use function in_array; - final class AsideActivityFormType extends AbstractType { private readonly array $timeChoices; @@ -68,7 +60,7 @@ final class AsideActivityFormType extends AbstractType ChillDateType::class, [ 'label' => 'date', - 'data' => new DateTime(), + 'data' => new \DateTime(), 'required' => true, ] ) @@ -98,16 +90,16 @@ final class AsideActivityFormType extends AbstractType ) { // set the timezone to GMT, and fix the difference between current and GMT // the datetimetransformer will then handle timezone as GMT - $timezoneUTC = new DateTimeZone('GMT'); - /** @var DateTimeImmutable $data */ - $data = $formEvent->getData() ?? DateTime::createFromFormat('U', '300'); + $timezoneUTC = new \DateTimeZone('GMT'); + /** @var \DateTimeImmutable $data */ + $data = $formEvent->getData() ?? \DateTime::createFromFormat('U', '300'); $seconds = $data->getTimezone()->getOffset($data); $data->setTimeZone($timezoneUTC); - $data->add(new DateInterval('PT' . $seconds . 'S')); + $data->add(new \DateInterval('PT'.$seconds.'S')); // test if the timestamp is in the choices. // If not, recreate the field with the new timestamp - if (!in_array($data->getTimestamp(), $timeChoices, true)) { + if (!\in_array($data->getTimestamp(), $timeChoices, true)) { // the data are not in the possible values. add them $timeChoices[$data->format('H:i')] = $data->getTimestamp(); $form = $builder->create($fieldName, ChoiceType::class, [...$durationTimeOptions, 'choices' => $timeChoices, 'auto_initialize' => false]); diff --git a/src/Bundle/ChillAsideActivityBundle/src/Menu/SectionMenuBuilder.php b/src/Bundle/ChillAsideActivityBundle/src/Menu/SectionMenuBuilder.php index 2bdff5a1c..a32d52303 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Menu/SectionMenuBuilder.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Menu/SectionMenuBuilder.php @@ -23,9 +23,6 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface { public function __construct(protected TranslatorInterface $translator, public AuthorizationCheckerInterface $authorizationChecker) {} - /** - * @param $menuId - */ public function buildMenu($menuId, MenuItem $menu, array $parameters) { if ($this->authorizationChecker->isGranted('ROLE_USER')) { diff --git a/src/Bundle/ChillAsideActivityBundle/src/Repository/AsideActivityCategoryRepository.php b/src/Bundle/ChillAsideActivityBundle/src/Repository/AsideActivityCategoryRepository.php index 6735606ce..533e567b4 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Repository/AsideActivityCategoryRepository.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Repository/AsideActivityCategoryRepository.php @@ -49,7 +49,7 @@ class AsideActivityCategoryRepository implements ObjectRepository * * @return AsideActivityCategory[] */ - public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array + public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): array { return $this->repository->findBy($criteria, $orderBy, $limit, $offset); } diff --git a/src/Bundle/ChillAsideActivityBundle/src/Templating/Entity/CategoryRender.php b/src/Bundle/ChillAsideActivityBundle/src/Templating/Entity/CategoryRender.php index 2c485f066..2598c4e01 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Templating/Entity/CategoryRender.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Templating/Entity/CategoryRender.php @@ -14,7 +14,6 @@ namespace Chill\AsideActivityBundle\Templating\Entity; use Chill\AsideActivityBundle\Entity\AsideActivityCategory; use Chill\MainBundle\Templating\Entity\ChillEntityRenderInterface; use Chill\MainBundle\Templating\TranslatableStringHelper; -use Symfony\Component\Templating\EngineInterface; /** * @implements ChillEntityRenderInterface diff --git a/src/Bundle/ChillAsideActivityBundle/src/Tests/Controller/AsideActivityControllerTest.php b/src/Bundle/ChillAsideActivityBundle/src/Tests/Controller/AsideActivityControllerTest.php index bce883126..4a772775f 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Tests/Controller/AsideActivityControllerTest.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Tests/Controller/AsideActivityControllerTest.php @@ -14,13 +14,11 @@ namespace Chill\AsideActivityBundle\Tests\Controller; use Chill\AsideActivityBundle\Entity\AsideActivity; use Chill\MainBundle\Test\PrepareClientTrait; use Doctrine\ORM\EntityManagerInterface; -use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -use function array_pop; -use function shuffle; /** * @internal + * * @coversNothing */ final class AsideActivityControllerTest extends WebTestCase @@ -49,13 +47,13 @@ final class AsideActivityControllerTest extends WebTestCase ->getQuery() ->getResult(); - shuffle($asideActivityIds); + \shuffle($asideActivityIds); - yield [array_pop($asideActivityIds)['id']]; + yield [\array_pop($asideActivityIds)['id']]; - yield [array_pop($asideActivityIds)['id']]; + yield [\array_pop($asideActivityIds)['id']]; - yield [array_pop($asideActivityIds)['id']]; + yield [\array_pop($asideActivityIds)['id']]; self::ensureKernelShutdown(); } diff --git a/src/Bundle/ChillAsideActivityBundle/src/Tests/Export/Export/ListAsideActivityTest.php b/src/Bundle/ChillAsideActivityBundle/src/Tests/Export/Export/ListAsideActivityTest.php index 6bd29ef1d..29ea8d1f6 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Tests/Export/Export/ListAsideActivityTest.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Tests/Export/Export/ListAsideActivityTest.php @@ -12,12 +12,12 @@ declare(strict_types=1); namespace Chill\AsideActivityBundle\Tests\Export\Export; use Chill\AsideActivityBundle\Export\Export\ListAsideActivity; -use Chill\MainBundle\Test\Export\AbstractExportTest; use Doctrine\ORM\AbstractQuery; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; /** * @internal + * * @coversNothing */ class ListAsideActivityTest extends KernelTestCase @@ -38,6 +38,6 @@ class ListAsideActivityTest extends KernelTestCase $results = $qb->getQuery()->getResult(AbstractQuery::HYDRATE_ARRAY); - self::assertIsArray($results, "smoke test: test that the result is an array"); + self::assertIsArray($results, 'smoke test: test that the result is an array'); } } diff --git a/src/Bundle/ChillBudgetBundle/Calculator/CalculatorInterface.php b/src/Bundle/ChillBudgetBundle/Calculator/CalculatorInterface.php index 2662b896a..3b5a687a6 100644 --- a/src/Bundle/ChillBudgetBundle/Calculator/CalculatorInterface.php +++ b/src/Bundle/ChillBudgetBundle/Calculator/CalculatorInterface.php @@ -17,7 +17,7 @@ use Chill\BudgetBundle\Entity\Resource; interface CalculatorInterface { /** - * @param array $elements + * @param array $elements */ public function calculate(array $elements): ?CalculatorResult; diff --git a/src/Bundle/ChillBudgetBundle/Calculator/CalculatorManager.php b/src/Bundle/ChillBudgetBundle/Calculator/CalculatorManager.php index 7987bdfdf..477f23189 100644 --- a/src/Bundle/ChillBudgetBundle/Calculator/CalculatorManager.php +++ b/src/Bundle/ChillBudgetBundle/Calculator/CalculatorManager.php @@ -11,14 +11,8 @@ declare(strict_types=1); namespace Chill\BudgetBundle\Calculator; -use Chill\BudgetBundle\Entity\AbstractElement; use Chill\BudgetBundle\Entity\Charge; use Chill\BudgetBundle\Entity\Resource; -use OutOfBoundsException; - -use function array_key_exists; -use function array_keys; -use function implode; class CalculatorManager { @@ -42,7 +36,7 @@ class CalculatorManager } /** - * @param array $elements + * @param array $elements * * @return CalculatorResult[] */ @@ -63,9 +57,8 @@ class CalculatorManager public function getCalculator(string $alias): CalculatorInterface { - if (false === array_key_exists($alias, $this->calculators)) { - throw new OutOfBoundsException("The calculator with alias '{$alias}' does " - . 'not exists. Possible values are ' . implode(', ', array_keys($this->calculators))); + if (false === \array_key_exists($alias, $this->calculators)) { + throw new \OutOfBoundsException("The calculator with alias '{$alias}' does ".'not exists. Possible values are '.\implode(', ', \array_keys($this->calculators))); } return $this->calculators[$alias]; diff --git a/src/Bundle/ChillBudgetBundle/Controller/AbstractElementController.php b/src/Bundle/ChillBudgetBundle/Controller/AbstractElementController.php index 27fc65dec..38d4d82f5 100644 --- a/src/Bundle/ChillBudgetBundle/Controller/AbstractElementController.php +++ b/src/Bundle/ChillBudgetBundle/Controller/AbstractElementController.php @@ -23,8 +23,6 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Contracts\Translation\TranslatorInterface; -use function get_class; - abstract class AbstractElementController extends AbstractController { public function __construct(protected EntityManagerInterface $em, protected TranslatorInterface $translator, protected LoggerInterface $chillMainLogger) {} @@ -38,7 +36,7 @@ abstract class AbstractElementController extends AbstractController protected function _delete(AbstractElement $element, Request $request, mixed $template, mixed $flashMessage): Response { $this->denyAccessUnlessGranted(BudgetElementVoter::DELETE, $element, 'You are not ' - . 'allowed to delete this item'); + .'allowed to delete this item'); $form = $this->createDeleteForm(); @@ -50,7 +48,7 @@ abstract class AbstractElementController extends AbstractController $indexPage = 'chill_budget_elements_household_index'; } - if ($request->getMethod() === Request::METHOD_DELETE) { + if (Request::METHOD_DELETE === $request->getMethod()) { $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { diff --git a/src/Bundle/ChillBudgetBundle/Controller/Admin/ChargeKindController.php b/src/Bundle/ChillBudgetBundle/Controller/Admin/ChargeKindController.php index e1989176d..642b7cc61 100644 --- a/src/Bundle/ChillBudgetBundle/Controller/Admin/ChargeKindController.php +++ b/src/Bundle/ChillBudgetBundle/Controller/Admin/ChargeKindController.php @@ -20,7 +20,7 @@ class ChargeKindController extends CRUDController { protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator) { - /** @var QueryBuilder $query */ + /* @var QueryBuilder $query */ $query->addOrderBy('e.ordering', 'ASC'); return $query; diff --git a/src/Bundle/ChillBudgetBundle/Controller/Admin/ResourceKindController.php b/src/Bundle/ChillBudgetBundle/Controller/Admin/ResourceKindController.php index 90b8e750a..0762f8252 100644 --- a/src/Bundle/ChillBudgetBundle/Controller/Admin/ResourceKindController.php +++ b/src/Bundle/ChillBudgetBundle/Controller/Admin/ResourceKindController.php @@ -20,7 +20,7 @@ class ResourceKindController extends CRUDController { protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator) { - /** @var QueryBuilder $query */ + /* @var QueryBuilder $query */ $query->addOrderBy('e.ordering', 'ASC'); return $query; diff --git a/src/Bundle/ChillBudgetBundle/Controller/ChargeController.php b/src/Bundle/ChillBudgetBundle/Controller/ChargeController.php index 4f057a939..39e96d4a8 100644 --- a/src/Bundle/ChillBudgetBundle/Controller/ChargeController.php +++ b/src/Bundle/ChillBudgetBundle/Controller/ChargeController.php @@ -15,14 +15,13 @@ use Chill\BudgetBundle\Entity\Charge; use Chill\BudgetBundle\Form\ChargeType; use Chill\PersonBundle\Entity\Household\Household; use Chill\PersonBundle\Entity\Person; -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Symfony\Component\HttpFoundation\Request; class ChargeController extends AbstractElementController { /** - * * @return \Symfony\Component\HttpFoundation\Response + * * @\Symfony\Component\Routing\Annotation\Route("{_locale}/budget/charge/{id}/delete", name="chill_budget_charge_delete") */ public function deleteAction(Request $request, Charge $charge) @@ -36,8 +35,8 @@ class ChargeController extends AbstractElementController } /** - * * @return \Symfony\Component\HttpFoundation\Response + * * @\Symfony\Component\Routing\Annotation\Route("{_locale}/budget/charge/{id}/edit", name="chill_budget_charge_edit") */ public function editAction(Request $request, Charge $charge) @@ -51,8 +50,8 @@ class ChargeController extends AbstractElementController } /** - * * @return \Symfony\Component\HttpFoundation\Response + * * @\Symfony\Component\Routing\Annotation\Route("{_locale}/budget/charge/by-person/{id}/new", name="chill_budget_charge_new") */ public function newAction(Request $request, Person $person) @@ -66,8 +65,8 @@ class ChargeController extends AbstractElementController } /** - * * @return \Symfony\Component\HttpFoundation\Response + * * @\Symfony\Component\Routing\Annotation\Route("{_locale}/budget/charge/by-household/{id}/new", name="chill_budget_charge_household_new") */ public function newHouseholdAction(Request $request, Household $household) @@ -81,8 +80,8 @@ class ChargeController extends AbstractElementController } /** - * * @return \Symfony\Component\HttpFoundation\Response + * * @\Symfony\Component\Routing\Annotation\Route("{_locale}/budget/charge/{id}/view", name="chill_budget_charge_view") */ public function viewAction(Charge $charge) diff --git a/src/Bundle/ChillBudgetBundle/Controller/ElementController.php b/src/Bundle/ChillBudgetBundle/Controller/ElementController.php index 3e8b36f6c..26acbf8a5 100644 --- a/src/Bundle/ChillBudgetBundle/Controller/ElementController.php +++ b/src/Bundle/ChillBudgetBundle/Controller/ElementController.php @@ -12,22 +12,12 @@ declare(strict_types=1); namespace Chill\BudgetBundle\Controller; use Chill\BudgetBundle\Calculator\CalculatorManager; -use Chill\BudgetBundle\Entity\Charge; -use Chill\BudgetBundle\Entity\Resource; use Chill\BudgetBundle\Repository\ChargeRepository; use Chill\BudgetBundle\Repository\ResourceRepository; use Chill\BudgetBundle\Security\Authorization\BudgetElementVoter; use Chill\PersonBundle\Entity\Household\Household; use Chill\PersonBundle\Entity\Person; -use DateTime; -use Doctrine\ORM\EntityManagerInterface; -use Psr\Log\LoggerInterface; -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Contracts\Translation\TranslatorInterface; - -use function array_merge; -use function count; class ElementController extends AbstractController { @@ -43,9 +33,9 @@ class ElementController extends AbstractController $charges = $this->chargeRepository->findAllByEntity($person); $resources = $this->resourceRepository->findAllByEntity($person); - $elements = array_merge($charges, $resources); + $elements = \array_merge($charges, $resources); - if (count($elements) > 0) { + if (\count($elements) > 0) { $results = $this->calculator->calculateDefault($elements); } @@ -67,9 +57,9 @@ class ElementController extends AbstractController $charges = $this->chargeRepository->findAllByEntity($household); $resources = $this->resourceRepository->findAllByEntity($household); - $elements = array_merge($charges, $resources); + $elements = \array_merge($charges, $resources); - if (count($elements) > 0) { + if (\count($elements) > 0) { $results = $this->calculator->calculateDefault($elements); } diff --git a/src/Bundle/ChillBudgetBundle/Controller/ResourceController.php b/src/Bundle/ChillBudgetBundle/Controller/ResourceController.php index eb02c3635..f67d92a43 100644 --- a/src/Bundle/ChillBudgetBundle/Controller/ResourceController.php +++ b/src/Bundle/ChillBudgetBundle/Controller/ResourceController.php @@ -15,7 +15,6 @@ use Chill\BudgetBundle\Entity\Resource; use Chill\BudgetBundle\Form\ResourceType; use Chill\PersonBundle\Entity\Household\Household; use Chill\PersonBundle\Entity\Person; -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; diff --git a/src/Bundle/ChillBudgetBundle/DependencyInjection/ChillBudgetExtension.php b/src/Bundle/ChillBudgetBundle/DependencyInjection/ChillBudgetExtension.php index 57976f846..6a8842b64 100644 --- a/src/Bundle/ChillBudgetBundle/DependencyInjection/ChillBudgetExtension.php +++ b/src/Bundle/ChillBudgetBundle/DependencyInjection/ChillBudgetExtension.php @@ -34,7 +34,7 @@ class ChillBudgetExtension extends Extension implements PrependExtensionInterfac $configuration = $this->getConfiguration($configs, $container); $config = $this->processConfiguration($configuration, $configs); - $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../config')); + $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../config')); $loader->load('services/form.yaml'); $loader->load('services/repository.yaml'); $loader->load('services/security.yaml'); @@ -60,7 +60,7 @@ class ChillBudgetExtension extends Extension implements PrependExtensionInterfac */ public function prependRoutes(ContainerBuilder $container) { - //add routes for custom bundle + // add routes for custom bundle $container->prependExtensionConfig('chill_main', [ 'routing' => [ 'resources' => [ diff --git a/src/Bundle/ChillBudgetBundle/Entity/AbstractElement.php b/src/Bundle/ChillBudgetBundle/Entity/AbstractElement.php index 619a6cdd7..52a52c99f 100644 --- a/src/Bundle/ChillBudgetBundle/Entity/AbstractElement.php +++ b/src/Bundle/ChillBudgetBundle/Entity/AbstractElement.php @@ -14,8 +14,6 @@ namespace Chill\BudgetBundle\Entity; use Chill\PersonBundle\Entity\Household\Household; use Chill\PersonBundle\Entity\Person; use DateTime; -use DateTimeImmutable; -use DateTimeInterface; use Doctrine\ORM\Mapping as ORM; use Ramsey\Uuid\Type\Decimal; use Symfony\Component\Validator\Constraints as Assert; @@ -29,9 +27,11 @@ abstract class AbstractElement { /** * @ORM\Column(name="amount", type="decimal", precision=10, scale=2) + * * @Assert\GreaterThan( * value=0 * ) + * * @Assert\NotNull( * message="The amount cannot be empty" * ) @@ -45,12 +45,13 @@ abstract class AbstractElement /** * @ORM\Column(name="endDate", type="datetime_immutable", nullable=true) + * * @Assert\GreaterThan( * propertyPath="startDate", * message="The budget element's end date must be after the start date" * ) */ - private ?DateTimeImmutable $endDate = null; + private ?\DateTimeImmutable $endDate = null; /** * @ORM\ManyToOne( @@ -68,16 +69,17 @@ abstract class AbstractElement /** * @ORM\Column(name="startDate", type="datetime_immutable") + * * @Assert\Date */ - private DateTimeImmutable $startDate; + private \DateTimeImmutable $startDate; /** * @ORM\Column(name="type", type="string", length=255) */ private string $type = ''; - /*Getters and Setters */ + /* Getters and Setters */ public function getAmount(): float { @@ -89,7 +91,7 @@ abstract class AbstractElement return $this->comment; } - public function getEndDate(): ?DateTimeImmutable + public function getEndDate(): ?\DateTimeImmutable { return $this->endDate; } @@ -104,7 +106,7 @@ abstract class AbstractElement return $this->person; } - public function getStartDate(): DateTimeImmutable + public function getStartDate(): \DateTimeImmutable { return $this->startDate; } @@ -130,17 +132,17 @@ abstract class AbstractElement return $this; } - public function setComment(?string $comment = null): self + public function setComment(string $comment = null): self { $this->comment = $comment; return $this; } - public function setEndDate(?DateTimeInterface $endDate = null): self + public function setEndDate(\DateTimeInterface $endDate = null): self { - if ($endDate instanceof DateTime) { - $this->endDate = DateTimeImmutable::createFromMutable($endDate); + if ($endDate instanceof \DateTime) { + $this->endDate = \DateTimeImmutable::createFromMutable($endDate); } elseif (null === $endDate) { $this->endDate = null; } else { @@ -164,10 +166,10 @@ abstract class AbstractElement return $this; } - public function setStartDate(DateTimeInterface $startDate): self + public function setStartDate(\DateTimeInterface $startDate): self { - if ($startDate instanceof DateTime) { - $this->startDate = DateTimeImmutable::createFromMutable($startDate); + if ($startDate instanceof \DateTime) { + $this->startDate = \DateTimeImmutable::createFromMutable($startDate); } elseif (null === $startDate) { $this->startDate = null; } else { diff --git a/src/Bundle/ChillBudgetBundle/Entity/Charge.php b/src/Bundle/ChillBudgetBundle/Entity/Charge.php index 6040cb328..68ee65d19 100644 --- a/src/Bundle/ChillBudgetBundle/Entity/Charge.php +++ b/src/Bundle/ChillBudgetBundle/Entity/Charge.php @@ -13,13 +13,13 @@ namespace Chill\BudgetBundle\Entity; use Chill\MainBundle\Entity\HasCentersInterface; use Chill\PersonBundle\Entity\Person; -use DateTimeImmutable; use Doctrine\ORM\Mapping as ORM; /** * Charge. * * @ORM\Table(name="chill_budget.charge") + * * @ORM\Entity(repositoryClass="Chill\BudgetBundle\Repository\ChargeRepository") */ class Charge extends AbstractElement implements HasCentersInterface @@ -41,6 +41,7 @@ class Charge extends AbstractElement implements HasCentersInterface /** * @ORM\ManyToOne(targetEntity=ChargeKind::class, inversedBy="AbstractElement") + * * @ORM\JoinColumn */ private ?ChargeKind $charge = null; @@ -52,14 +53,16 @@ class Charge extends AbstractElement implements HasCentersInterface /** * @ORM\Column(name="id", type="integer") + * * @ORM\Id + * * @ORM\GeneratedValue(strategy="AUTO") */ private ?int $id = null; public function __construct() { - $this->setStartDate(new DateTimeImmutable('today')); + $this->setStartDate(new \DateTimeImmutable('today')); } public function getCenters(): array diff --git a/src/Bundle/ChillBudgetBundle/Entity/ChargeKind.php b/src/Bundle/ChillBudgetBundle/Entity/ChargeKind.php index b6ebcf347..308575677 100644 --- a/src/Bundle/ChillBudgetBundle/Entity/ChargeKind.php +++ b/src/Bundle/ChillBudgetBundle/Entity/ChargeKind.php @@ -21,14 +21,18 @@ use Symfony\Component\Validator\Constraints as Assert; * @ORM\Table(name="chill_budget.charge_type", * uniqueConstraints={@ORM\UniqueConstraint(name="charge_kind_unique_type_idx", fields={"kind"})} * ) + * * @ORM\Entity + * * @UniqueEntity(fields={"kind"}) */ class ChargeKind { /** * @ORM\Id + * * @ORM\GeneratedValue + * * @ORM\Column(type="integer") */ private ?int $id = null; @@ -40,7 +44,9 @@ class ChargeKind /** * @ORM\Column(type="string", length=255, options={"default": ""}, nullable=false) + * * @Assert\Regex(pattern="/^[a-z0-9\-_]{1,}$/", message="budget.admin.form.kind.only_alphanumeric") + * * @Assert\Length(min=3) */ private string $kind = ''; diff --git a/src/Bundle/ChillBudgetBundle/Entity/Resource.php b/src/Bundle/ChillBudgetBundle/Entity/Resource.php index 28b8645e0..c4845ed1b 100644 --- a/src/Bundle/ChillBudgetBundle/Entity/Resource.php +++ b/src/Bundle/ChillBudgetBundle/Entity/Resource.php @@ -13,33 +13,36 @@ namespace Chill\BudgetBundle\Entity; use Chill\MainBundle\Entity\HasCentersInterface; use Chill\PersonBundle\Entity\Person; -use DateTimeImmutable; use Doctrine\ORM\Mapping as ORM; /** * Resource. * * @ORM\Table(name="chill_budget.resource") + * * @ORM\Entity(repositoryClass="Chill\BudgetBundle\Repository\ResourceRepository") */ class Resource extends AbstractElement implements HasCentersInterface { /** * @ORM\Column(name="id", type="integer") + * * @ORM\Id + * * @ORM\GeneratedValue(strategy="AUTO") */ private ?int $id = null; /** * @ORM\ManyToOne(targetEntity=ResourceKind::class, inversedBy="AbstractElement") + * * @ORM\JoinColumn */ private ?ResourceKind $resource = null; public function __construct() { - $this->setStartDate(new DateTimeImmutable('today')); + $this->setStartDate(new \DateTimeImmutable('today')); } public function getCenters(): array diff --git a/src/Bundle/ChillBudgetBundle/Entity/ResourceKind.php b/src/Bundle/ChillBudgetBundle/Entity/ResourceKind.php index 4b90be5e1..78e0e6a32 100644 --- a/src/Bundle/ChillBudgetBundle/Entity/ResourceKind.php +++ b/src/Bundle/ChillBudgetBundle/Entity/ResourceKind.php @@ -19,16 +19,21 @@ use Symfony\Component\Validator\Constraints as Assert; * Type of resource. * * @ORM\Table(name="chill_budget.resource_type", uniqueConstraints={ + * * @ORM\UniqueConstraint(name="resource_kind_unique_type_idx", fields={"kind"}) * }) + * * @ORM\Entity + * * @UniqueEntity(fields={"kind"}) */ class ResourceKind { /** * @ORM\Id + * * @ORM\GeneratedValue + * * @ORM\Column(type="integer") */ private ?int $id = null; @@ -40,7 +45,9 @@ class ResourceKind /** * @ORM\Column(type="string", length=255, nullable=false, options={"default": ""}) + * * @Assert\Regex(pattern="/^[a-z0-9\-_]{1,}$/", message="budget.admin.form.kind.only_alphanumeric") + * * @Assert\Length(min=3) */ private string $kind = ''; diff --git a/src/Bundle/ChillBudgetBundle/Repository/ChargeKindRepository.php b/src/Bundle/ChillBudgetBundle/Repository/ChargeKindRepository.php index a0c23a4ad..577be07db 100644 --- a/src/Bundle/ChillBudgetBundle/Repository/ChargeKindRepository.php +++ b/src/Bundle/ChillBudgetBundle/Repository/ChargeKindRepository.php @@ -66,7 +66,7 @@ final class ChargeKindRepository implements ChargeKindRepositoryInterface * * @return array */ - public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array + public function findBy(array $criteria, array $orderBy = null, int $limit = null, int $offset = null): array { return $this->repository->findBy($criteria, $orderBy, $limit, $offset); } diff --git a/src/Bundle/ChillBudgetBundle/Repository/ChargeKindRepositoryInterface.php b/src/Bundle/ChillBudgetBundle/Repository/ChargeKindRepositoryInterface.php index f92851eba..7a930bea8 100644 --- a/src/Bundle/ChillBudgetBundle/Repository/ChargeKindRepositoryInterface.php +++ b/src/Bundle/ChillBudgetBundle/Repository/ChargeKindRepositoryInterface.php @@ -34,12 +34,9 @@ interface ChargeKindRepositoryInterface extends ObjectRepository public function findAllByType(string $type): array; /** - * @param int|null $limit - * @param int|null $offset - * * @return array */ - public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array; + public function findBy(array $criteria, array $orderBy = null, int $limit = null, int $offset = null): array; public function findOneBy(array $criteria): ?ChargeKind; diff --git a/src/Bundle/ChillBudgetBundle/Repository/ChargeRepository.php b/src/Bundle/ChillBudgetBundle/Repository/ChargeRepository.php index 475657f68..3154a772d 100644 --- a/src/Bundle/ChillBudgetBundle/Repository/ChargeRepository.php +++ b/src/Bundle/ChillBudgetBundle/Repository/ChargeRepository.php @@ -14,7 +14,6 @@ namespace Chill\BudgetBundle\Repository; use Chill\BudgetBundle\Entity\Charge; use Chill\PersonBundle\Entity\Household\Household; use Chill\PersonBundle\Entity\Person; -use DateTime; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Persistence\ManagerRegistry; @@ -46,7 +45,7 @@ class ChargeRepository extends ServiceEntityRepository return $qb->getQuery()->getResult(); } - public function findByEntityAndDate($entity, DateTime $date, $sort = null) + public function findByEntityAndDate($entity, \DateTime $date, $sort = null) { $qb = $this->createQueryBuilder('c'); diff --git a/src/Bundle/ChillBudgetBundle/Repository/ResourceKindRepository.php b/src/Bundle/ChillBudgetBundle/Repository/ResourceKindRepository.php index 1ac419e30..e10913195 100644 --- a/src/Bundle/ChillBudgetBundle/Repository/ResourceKindRepository.php +++ b/src/Bundle/ChillBudgetBundle/Repository/ResourceKindRepository.php @@ -54,7 +54,7 @@ final class ResourceKindRepository implements ResourceKindRepositoryInterface public function findOneByKind(string $kind): ?ResourceKind { - return $this->repository->findOneBy(['kind' => $kind]) ; + return $this->repository->findOneBy(['kind' => $kind]); } /** @@ -71,7 +71,7 @@ final class ResourceKindRepository implements ResourceKindRepositoryInterface * * @return list */ - public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array + public function findBy(array $criteria, array $orderBy = null, int $limit = null, int $offset = null): array { return $this->repository->findBy($criteria, $orderBy, $limit, $offset); } diff --git a/src/Bundle/ChillBudgetBundle/Repository/ResourceKindRepositoryInterface.php b/src/Bundle/ChillBudgetBundle/Repository/ResourceKindRepositoryInterface.php index dac46ff35..d639d54ee 100644 --- a/src/Bundle/ChillBudgetBundle/Repository/ResourceKindRepositoryInterface.php +++ b/src/Bundle/ChillBudgetBundle/Repository/ResourceKindRepositoryInterface.php @@ -34,12 +34,9 @@ interface ResourceKindRepositoryInterface extends ObjectRepository public function findAllByType(string $type): array; /** - * @param int|null $limit - * @param int|null $offset - * * @return list */ - public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array; + public function findBy(array $criteria, array $orderBy = null, int $limit = null, int $offset = null): array; public function findOneBy(array $criteria): ?ResourceKind; diff --git a/src/Bundle/ChillBudgetBundle/Repository/ResourceRepository.php b/src/Bundle/ChillBudgetBundle/Repository/ResourceRepository.php index 6ecf13d28..2ba95e340 100644 --- a/src/Bundle/ChillBudgetBundle/Repository/ResourceRepository.php +++ b/src/Bundle/ChillBudgetBundle/Repository/ResourceRepository.php @@ -14,9 +14,7 @@ namespace Chill\BudgetBundle\Repository; use Chill\BudgetBundle\Entity\Resource; use Chill\PersonBundle\Entity\Household\Household; use Chill\PersonBundle\Entity\Person; -use DateTime; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; -use Doctrine\ORM\EntityRepository; use Doctrine\Persistence\ManagerRegistry; /** @@ -33,7 +31,7 @@ class ResourceRepository extends ServiceEntityRepository } /** - * @return Resource[] + * @return resource[] */ public function findAllByEntity(Household|Person $entity): array { @@ -47,7 +45,7 @@ class ResourceRepository extends ServiceEntityRepository return $qb->getQuery()->getResult(); } - public function findByEntityAndDate(Household|Person $entity, DateTime $date, $sort = null) + public function findByEntityAndDate(Household|Person $entity, \DateTime $date, $sort = null) { $qb = $this->createQueryBuilder('c'); diff --git a/src/Bundle/ChillBudgetBundle/Security/Authorization/BudgetElementVoter.php b/src/Bundle/ChillBudgetBundle/Security/Authorization/BudgetElementVoter.php index 11d465421..f2340b8b9 100644 --- a/src/Bundle/ChillBudgetBundle/Security/Authorization/BudgetElementVoter.php +++ b/src/Bundle/ChillBudgetBundle/Security/Authorization/BudgetElementVoter.php @@ -20,8 +20,6 @@ use Chill\PersonBundle\Entity\Household\Household; use Chill\PersonBundle\Entity\Person; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; -use UnexpectedValueException; - class BudgetElementVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface { final public const CREATE = 'CHILL_BUDGET_ELEMENT_CREATE'; @@ -91,6 +89,6 @@ class BudgetElementVoter extends AbstractChillVoter implements ProvideRoleHierar return false; } - throw new UnexpectedValueException('This subject is not supported, or is an element not associated with person or household'); + throw new \UnexpectedValueException('This subject is not supported, or is an element not associated with person or household'); } } diff --git a/src/Bundle/ChillBudgetBundle/Service/Summary/SummaryBudget.php b/src/Bundle/ChillBudgetBundle/Service/Summary/SummaryBudget.php index b1357680b..a57f7fb29 100644 --- a/src/Bundle/ChillBudgetBundle/Service/Summary/SummaryBudget.php +++ b/src/Bundle/ChillBudgetBundle/Service/Summary/SummaryBudget.php @@ -20,9 +20,6 @@ use Chill\PersonBundle\Entity\Household\Household; use Chill\PersonBundle\Entity\Person; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Query\ResultSetMapping; -use LogicException; -use RuntimeException; -use function count; /** * Helps to find a summary of the budget: the sum of resources and charges. @@ -49,7 +46,7 @@ final readonly class SummaryBudget implements SummaryBudgetInterface } $personIds = $household->getCurrentPersons()->map(static fn (Person $p) => $p->getId()); - $ids = implode(', ', array_fill(0, count($personIds), '?')); + $ids = implode(', ', array_fill(0, \count($personIds), '?')); $parameters = [...$personIds, $household->getId()]; @@ -127,7 +124,7 @@ final readonly class SummaryBudget implements SummaryBudgetInterface $chargeKind = $this->chargeKindRepository->find($row['kind_id']); if (null === $chargeKind) { - throw new RuntimeException('charge kind not found: ' . $row['kind_id']); + throw new \RuntimeException('charge kind not found: '.$row['kind_id']); } $result[$chargeKind->getKind()] = [ 'sum' => (float) $row['sum'], @@ -143,7 +140,7 @@ final readonly class SummaryBudget implements SummaryBudgetInterface $resourceKind = $this->resourceKindRepository->find($row['kind_id']); if (null === $resourceKind) { - throw new RuntimeException('charge kind not found: ' . $row['kind_id']); + throw new \RuntimeException('charge kind not found: '.$row['kind_id']); } $result[$resourceKind->getKind()] = [ @@ -156,7 +153,7 @@ final readonly class SummaryBudget implements SummaryBudgetInterface return $result; default: - throw new LogicException(); + throw new \LogicException(); } } } diff --git a/src/Bundle/ChillBudgetBundle/Templating/BudgetElementTypeRender.php b/src/Bundle/ChillBudgetBundle/Templating/BudgetElementTypeRender.php index c9c592a31..26871b0f4 100644 --- a/src/Bundle/ChillBudgetBundle/Templating/BudgetElementTypeRender.php +++ b/src/Bundle/ChillBudgetBundle/Templating/BudgetElementTypeRender.php @@ -15,7 +15,6 @@ use Chill\BudgetBundle\Entity\ChargeKind; use Chill\BudgetBundle\Entity\ResourceKind; use Chill\MainBundle\Templating\Entity\ChillEntityRenderInterface; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; -use Symfony\Component\Templating\EngineInterface; /** * @implements ChillEntityRenderInterface diff --git a/src/Bundle/ChillBudgetBundle/Tests/Controller/ElementControllerTest.php b/src/Bundle/ChillBudgetBundle/Tests/Controller/ElementControllerTest.php index 6cdafa2c3..52fae812e 100644 --- a/src/Bundle/ChillBudgetBundle/Tests/Controller/ElementControllerTest.php +++ b/src/Bundle/ChillBudgetBundle/Tests/Controller/ElementControllerTest.php @@ -15,6 +15,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; /** * @internal + * * @coversNothing */ final class ElementControllerTest extends WebTestCase diff --git a/src/Bundle/ChillBudgetBundle/Tests/Service/Summary/SummaryBudgetTest.php b/src/Bundle/ChillBudgetBundle/Tests/Service/Summary/SummaryBudgetTest.php index 7d90bf575..7fb437e05 100644 --- a/src/Bundle/ChillBudgetBundle/Tests/Service/Summary/SummaryBudgetTest.php +++ b/src/Bundle/ChillBudgetBundle/Tests/Service/Summary/SummaryBudgetTest.php @@ -20,15 +20,12 @@ use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Chill\PersonBundle\Entity\Household\Household; use Chill\PersonBundle\Entity\Household\HouseholdMember; use Chill\PersonBundle\Entity\Person; -use DateTimeImmutable; use Doctrine\ORM\AbstractQuery; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Query; use PHPUnit\Framework\TestCase; use Prophecy\Argument; use Prophecy\PhpUnit\ProphecyTrait; -use ReflectionClass; -use RuntimeException; /** * @internal @@ -74,7 +71,7 @@ final class SummaryBudgetTest extends TestCase return $queryCharges->reveal(); } - throw new RuntimeException('this query does not have a stub counterpart: ' . $args[0]); + throw new \RuntimeException('this query does not have a stub counterpart: '.$args[0]); }); $chargeRepository = $this->prophesize(ChargeKindRepositoryInterface::class); @@ -99,18 +96,18 @@ final class SummaryBudgetTest extends TestCase $translatableStringHelper->localize(Argument::type('array'))->will(static fn ($arg) => $arg[0]['fr']); $person = new Person(); - $personReflection = new ReflectionClass($person); + $personReflection = new \ReflectionClass($person); $personIdReflection = $personReflection->getProperty('id'); $personIdReflection->setAccessible(true); $personIdReflection->setValue($person, 1); $household = new Household(); - $householdReflection = new ReflectionClass($household); + $householdReflection = new \ReflectionClass($household); $householdId = $householdReflection->getProperty('id'); $householdId->setAccessible(true); $householdId->setValue($household, 1); $householdMember = (new HouseholdMember())->setPerson($person) - ->setStartDate(new DateTimeImmutable('1 month ago')); + ->setStartDate(new \DateTimeImmutable('1 month ago')); $household->addMember($householdMember); $summaryBudget = new SummaryBudget( diff --git a/src/Bundle/ChillBudgetBundle/migrations/Version20221207105407.php b/src/Bundle/ChillBudgetBundle/migrations/Version20221207105407.php index cfe3a0089..1d2707120 100644 --- a/src/Bundle/ChillBudgetBundle/migrations/Version20221207105407.php +++ b/src/Bundle/ChillBudgetBundle/migrations/Version20221207105407.php @@ -32,7 +32,7 @@ final class Version20221207105407 extends AbstractMigration implements Container return 'Use new budget admin entities'; } - public function setContainer(?ContainerInterface $container = null) + public function setContainer(ContainerInterface $container = null) { $this->container = $container; } diff --git a/src/Bundle/ChillCalendarBundle/Command/AzureGrantAdminConsentAndAcquireToken.php b/src/Bundle/ChillCalendarBundle/Command/AzureGrantAdminConsentAndAcquireToken.php index 110adccdc..c9bf020b1 100644 --- a/src/Bundle/ChillCalendarBundle/Command/AzureGrantAdminConsentAndAcquireToken.php +++ b/src/Bundle/ChillCalendarBundle/Command/AzureGrantAdminConsentAndAcquireToken.php @@ -66,8 +66,8 @@ class AzureGrantAdminConsentAndAcquireToken extends Command $output->writeln('Token information:'); $output->writeln($token->getToken()); - $output->writeln('Expires at: ' . $token->getExpires()); - $output->writeln('To inspect the token content, go to https://jwt.ms/#access_token=' . urlencode($token->getToken())); + $output->writeln('Expires at: '.$token->getExpires()); + $output->writeln('To inspect the token content, go to https://jwt.ms/#access_token='.urlencode($token->getToken())); return 0; } diff --git a/src/Bundle/ChillCalendarBundle/Command/MapAndSubscribeUserCalendarCommand.php b/src/Bundle/ChillCalendarBundle/Command/MapAndSubscribeUserCalendarCommand.php index 193b04934..4964f0064 100644 --- a/src/Bundle/ChillCalendarBundle/Command/MapAndSubscribeUserCalendarCommand.php +++ b/src/Bundle/ChillCalendarBundle/Command/MapAndSubscribeUserCalendarCommand.php @@ -21,11 +21,8 @@ namespace Chill\CalendarBundle\Command; use Chill\CalendarBundle\Exception\UserAbsenceSyncException; use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\EventsOnUserSubscriptionCreator; use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\MapCalendarToUser; -use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\MSGraphUserRepository; use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\MSUserAbsenceSync; use Chill\MainBundle\Repository\UserRepositoryInterface; -use DateInterval; -use DateTimeImmutable; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Component\Console\Command\Command; @@ -48,19 +45,19 @@ final class MapAndSubscribeUserCalendarCommand extends Command public function execute(InputInterface $input, OutputInterface $output): int { - $this->logger->info(self::class . ' execute command'); + $this->logger->info(self::class.' execute command'); $limit = 50; $offset = 0; - /** @var DateInterval $interval the interval before the end of the expiration */ - $interval = new DateInterval('P1D'); - $expiration = (new DateTimeImmutable('now'))->add(new DateInterval($input->getOption('subscription-duration'))); + /** @var \DateInterval $interval the interval before the end of the expiration */ + $interval = new \DateInterval('P1D'); + $expiration = (new \DateTimeImmutable('now'))->add(new \DateInterval($input->getOption('subscription-duration'))); $users = $this->userRepository->findAllAsArray('fr'); $created = 0; $renewed = 0; - $this->logger->info(self::class . ' start user to get - renew', [ - 'expiration' => $expiration->format(DateTimeImmutable::ATOM), + $this->logger->info(self::class.' start user to get - renew', [ + 'expiration' => $expiration->format(\DateTimeImmutable::ATOM), ]); foreach ($users as $u) { @@ -73,8 +70,8 @@ final class MapAndSubscribeUserCalendarCommand extends Command $user = $this->userRepository->find($u['id']); if (null === $user) { - $this->logger->error("could not find user by id", ['uid' => $u['id']]); - $output->writeln("could not find user by id : " . $u['id']); + $this->logger->error('could not find user by id', ['uid' => $u['id']]); + $output->writeln('could not find user by id : '.$u['id']); continue; } @@ -83,8 +80,8 @@ final class MapAndSubscribeUserCalendarCommand extends Command // if user still does not have userid, continue if (!$this->mapCalendarToUser->hasUserId($user)) { - $this->logger->warning("user does not have a counterpart on ms api", ['userId' => $user->getId(), 'email' => $user->getEmail()]); - $output->writeln(sprintf("giving up for user with email %s and id %s", $user->getEmail(), $user->getId())); + $this->logger->warning('user does not have a counterpart on ms api', ['userId' => $user->getId(), 'email' => $user->getEmail()]); + $output->writeln(sprintf('giving up for user with email %s and id %s', $user->getEmail(), $user->getId())); continue; } @@ -94,15 +91,15 @@ final class MapAndSubscribeUserCalendarCommand extends Command try { $this->userAbsenceSync->syncUserAbsence($user); } catch (UserAbsenceSyncException $e) { - $this->logger->error("could not sync user absence", ['userId' => $user->getId(), 'email' => $user->getEmail(), 'exception' => $e->getTraceAsString(), "message" => $e->getMessage()]); - $output->writeln(sprintf("Could not sync user absence: id: %s and email: %s", $user->getId(), $user->getEmail())); + $this->logger->error('could not sync user absence', ['userId' => $user->getId(), 'email' => $user->getEmail(), 'exception' => $e->getTraceAsString(), 'message' => $e->getMessage()]); + $output->writeln(sprintf('Could not sync user absence: id: %s and email: %s', $user->getId(), $user->getEmail())); throw $e; } // we first try to renew an existing subscription, if any. // if not, or if it fails, we try to create a new one if ($this->mapCalendarToUser->hasActiveSubscription($user)) { - $this->logger->debug(self::class . ' renew a subscription for', [ + $this->logger->debug(self::class.' renew a subscription for', [ 'userId' => $user->getId(), 'username' => $user->getUsernameCanonical(), ]); @@ -114,7 +111,7 @@ final class MapAndSubscribeUserCalendarCommand extends Command if (0 !== $expirationTs) { ++$renewed; } else { - $this->logger->warning(self::class . ' could not renew subscription for a user', [ + $this->logger->warning(self::class.' could not renew subscription for a user', [ 'userId' => $user->getId(), 'username' => $user->getUsernameCanonical(), ]); @@ -122,7 +119,7 @@ final class MapAndSubscribeUserCalendarCommand extends Command } if (!$this->mapCalendarToUser->hasActiveSubscription($user)) { - $this->logger->debug(self::class . ' create a subscription for', [ + $this->logger->debug(self::class.' create a subscription for', [ 'userId' => $user->getId(), 'username' => $user->getUsernameCanonical(), ]); @@ -134,14 +131,13 @@ final class MapAndSubscribeUserCalendarCommand extends Command if (0 !== $expirationTs) { ++$created; } else { - $this->logger->warning(self::class . ' could not create subscription for a user', [ + $this->logger->warning(self::class.' could not create subscription for a user', [ 'userId' => $user->getId(), 'username' => $user->getUsernameCanonical(), ]); } } - if (0 === $offset % $limit) { $this->em->flush(); $this->em->clear(); @@ -151,12 +147,12 @@ final class MapAndSubscribeUserCalendarCommand extends Command $this->em->flush(); $this->em->clear(); - $this->logger->warning(self::class . ' process executed', [ + $this->logger->warning(self::class.' process executed', [ 'created' => $created, 'renewed' => $renewed, ]); - $output->writeln("users synchronized"); + $output->writeln('users synchronized'); return 0; } diff --git a/src/Bundle/ChillCalendarBundle/Command/SendTestShortMessageOnCalendarCommand.php b/src/Bundle/ChillCalendarBundle/Command/SendTestShortMessageOnCalendarCommand.php index e39ff2d75..bfbdd2abd 100644 --- a/src/Bundle/ChillCalendarBundle/Command/SendTestShortMessageOnCalendarCommand.php +++ b/src/Bundle/ChillCalendarBundle/Command/SendTestShortMessageOnCalendarCommand.php @@ -26,8 +26,6 @@ use Chill\MainBundle\Repository\UserRepositoryInterface; use Chill\MainBundle\Service\ShortMessage\ShortMessageTransporterInterface; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Repository\PersonRepository; -use DateInterval; -use DateTimeImmutable; use libphonenumber\PhoneNumber; use libphonenumber\PhoneNumberFormat; use libphonenumber\PhoneNumberType; @@ -38,8 +36,6 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ConfirmationQuestion; use Symfony\Component\Console\Question\Question; -use UnexpectedValueException; -use function count; class SendTestShortMessageOnCalendarCommand extends Command { @@ -74,20 +70,20 @@ class SendTestShortMessageOnCalendarCommand extends Command // start date $question = new Question('When will start the appointment ? (default: "1 hour") ', '1 hour'); - $startDate = new DateTimeImmutable($helper->ask($input, $output, $question)); + $startDate = new \DateTimeImmutable($helper->ask($input, $output, $question)); if (false === $startDate) { - throw new UnexpectedValueException('could not create a date with this date and time'); + throw new \UnexpectedValueException('could not create a date with this date and time'); } $calendar->setStartDate($startDate); // end date $question = new Question('How long will last the appointment ? (default: "PT30M") ', 'PT30M'); - $interval = new DateInterval($helper->ask($input, $output, $question)); + $interval = new \DateInterval($helper->ask($input, $output, $question)); if (false === $interval) { - throw new UnexpectedValueException('could not create the interval'); + throw new \UnexpectedValueException('could not create the interval'); } $calendar->setEndDate($calendar->getStartDate()->add($interval)); @@ -97,17 +93,17 @@ class SendTestShortMessageOnCalendarCommand extends Command $question ->setValidator(function ($answer): Person { if (!is_numeric($answer)) { - throw new UnexpectedValueException('the answer must be numeric'); + throw new \UnexpectedValueException('the answer must be numeric'); } if (0 >= (int) $answer) { - throw new UnexpectedValueException('the answer must be greater than zero'); + throw new \UnexpectedValueException('the answer must be greater than zero'); } $person = $this->personRepository->find((int) $answer); if (null === $person) { - throw new UnexpectedValueException('The person is not found'); + throw new \UnexpectedValueException('The person is not found'); } return $person; @@ -121,17 +117,17 @@ class SendTestShortMessageOnCalendarCommand extends Command $question ->setValidator(function ($answer): User { if (!is_numeric($answer)) { - throw new UnexpectedValueException('the answer must be numeric'); + throw new \UnexpectedValueException('the answer must be numeric'); } if (0 >= (int) $answer) { - throw new UnexpectedValueException('the answer must be greater than zero'); + throw new \UnexpectedValueException('the answer must be greater than zero'); } $user = $this->userRepository->find((int) $answer); if (null === $user) { - throw new UnexpectedValueException('The user is not found'); + throw new \UnexpectedValueException('The user is not found'); } return $user; @@ -150,13 +146,13 @@ class SendTestShortMessageOnCalendarCommand extends Command $question->setNormalizer(function ($answer): PhoneNumber { if (null === $answer) { - throw new UnexpectedValueException('The person is not found'); + throw new \UnexpectedValueException('The person is not found'); } $phone = $this->phoneNumberUtil->parse($answer, 'BE'); if (!$this->phoneNumberUtil->isPossibleNumberForType($phone, PhoneNumberType::MOBILE)) { - throw new UnexpectedValueException('Phone number si not a mobile'); + throw new \UnexpectedValueException('Phone number si not a mobile'); } return $phone; @@ -169,7 +165,7 @@ class SendTestShortMessageOnCalendarCommand extends Command $messages = $this->messageForCalendarBuilder->buildMessageForCalendar($calendar); - if (0 === count($messages)) { + if (0 === \count($messages)) { $output->writeln('no message to send to this user'); } diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarAPIController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarAPIController.php index 8d315b02f..1729c215b 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarAPIController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarAPIController.php @@ -15,7 +15,6 @@ use Chill\CalendarBundle\Repository\CalendarRepository; use Chill\MainBundle\CRUD\Controller\ApiController; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Serializer\Model\Collection; -use DateTimeImmutable; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -40,8 +39,8 @@ class CalendarAPIController extends ApiController throw new BadRequestHttpException('You must provide a dateFrom parameter'); } - if (false === $dateFrom = DateTimeImmutable::createFromFormat( - DateTimeImmutable::ATOM, + if (false === $dateFrom = \DateTimeImmutable::createFromFormat( + \DateTimeImmutable::ATOM, $request->query->get('dateFrom') )) { throw new BadRequestHttpException('dateFrom not parsable'); @@ -51,8 +50,8 @@ class CalendarAPIController extends ApiController throw new BadRequestHttpException('You must provide a dateTo parameter'); } - if (false === $dateTo = DateTimeImmutable::createFromFormat( - DateTimeImmutable::ATOM, + if (false === $dateTo = \DateTimeImmutable::createFromFormat( + \DateTimeImmutable::ATOM, $request->query->get('dateTo') )) { throw new BadRequestHttpException('dateTo not parsable'); diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php index b80d298a4..f4694614f 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php @@ -30,11 +30,8 @@ use Chill\PersonBundle\Repository\PersonRepository; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; use Chill\PersonBundle\Security\Authorization\PersonVoter; use Chill\ThirdPartyBundle\Entity\ThirdParty; -use DateTimeImmutable; -use Exception; use http\Exception\UnexpectedValueException; use Psr\Log\LoggerInterface; -use RuntimeException; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Form; @@ -82,12 +79,12 @@ class CalendarController extends AbstractController $view = '@ChillCalendar/Calendar/confirm_deleteByPerson.html.twig'; $redirectRoute = $this->generateUrl('chill_calendar_calendar_list_by_person', ['id' => $person->getId()]); } else { - throw new RuntimeException('nor person or accompanying period'); + throw new \RuntimeException('nor person or accompanying period'); } $form = $this->createDeleteForm($entity); - if ($request->getMethod() === Request::METHOD_DELETE) { + if (Request::METHOD_DELETE === $request->getMethod()) { $form->handleRequest($request); if ($form->isValid()) { @@ -138,7 +135,7 @@ class CalendarController extends AbstractController $view = '@ChillCalendar/Calendar/editByPerson.html.twig'; $redirectRoute = $this->generateUrl('chill_calendar_calendar_list_by_person', ['id' => $person->getId()]); } else { - throw new RuntimeException('no person nor accompanying period'); + throw new \RuntimeException('no person nor accompanying period'); } $form = $this->createForm(CalendarType::class, $entity) @@ -148,7 +145,7 @@ class CalendarController extends AbstractController $templates = $this->docGeneratorTemplateRepository->findByEntity(Calendar::class); foreach ($templates as $template) { - $form->add('save_and_generate_doc_' . $template->getId(), SubmitType::class, [ + $form->add('save_and_generate_doc_'.$template->getId(), SubmitType::class, [ 'label' => $this->translatableStringHelper->localize($template->getName()), ]); } @@ -165,7 +162,7 @@ class CalendarController extends AbstractController } foreach ($templates as $template) { - if ($form->get('save_and_generate_doc_' . $template->getId())->isClicked()) { + if ($form->get('save_and_generate_doc_'.$template->getId())->isClicked()) { return $this->redirectToRoute('chill_docgenerator_generate_from_template', [ 'entityClassName' => Calendar::class, 'entityId' => $entity->getId(), @@ -327,7 +324,7 @@ class CalendarController extends AbstractController $form->add('save_and_upload_doc', SubmitType::class); foreach ($templates as $template) { - $form->add('save_and_generate_doc_' . $template->getId(), SubmitType::class, [ + $form->add('save_and_generate_doc_'.$template->getId(), SubmitType::class, [ 'label' => $this->translatableStringHelper->localize($template->getName()), ]); } @@ -342,12 +339,12 @@ class CalendarController extends AbstractController if ($form->get('save_and_upload_doc')->isClicked()) { return $this->redirectToRoute('chill_calendar_calendardoc_new', [ - 'id' => $entity->getId() + 'id' => $entity->getId(), ]); } foreach ($templates as $template) { - if ($form->get('save_and_generate_doc_' . $template->getId())->isClicked()) { + if ($form->get('save_and_generate_doc_'.$template->getId())->isClicked()) { return $this->redirectToRoute('chill_docgenerator_generate_from_template', [ 'entityClassName' => Calendar::class, 'entityId' => $entity->getId(), @@ -392,7 +389,7 @@ class CalendarController extends AbstractController */ public function showAction(Request $request, int $id): Response { - throw new Exception('not implemented'); + throw new \Exception('not implemented'); $view = null; $em = $this->getDoctrine()->getManager(); @@ -453,7 +450,7 @@ class CalendarController extends AbstractController 'entity' => $entity, 'user' => $user, 'activityData' => $activityData, - //'delete_form' => $deleteForm->createView(), + // 'delete_form' => $deleteForm->createView(), ]); } @@ -498,12 +495,12 @@ class CalendarController extends AbstractController 'returnPath' => $request->query->get('returnPath', null), ]; - if ($calendar->getContext() === 'accompanying_period') { + if ('accompanying_period' === $calendar->getContext()) { $routeParams['accompanying_period_id'] = $calendar->getAccompanyingPeriod()->getId(); - } elseif ($calendar->getContext() === 'person') { + } elseif ('person' === $calendar->getContext()) { $routeParams['person_id'] = $calendar->getPerson()->getId(); } else { - throw new RuntimeException('context not found for this calendar'); + throw new \RuntimeException('context not found for this calendar'); } return $this->redirectToRoute('chill_activity_activity_new', $routeParams); @@ -512,7 +509,7 @@ class CalendarController extends AbstractController private function buildListFilterOrder(): FilterOrderHelper { $filterOrder = $this->filterOrderHelperFactory->create(self::class); - $filterOrder->addDateRange('startDate', null, new DateTimeImmutable('3 days ago'), null); + $filterOrder->addDateRange('startDate', null, new \DateTimeImmutable('3 days ago'), null); return $filterOrder->build(); } diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarDocController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarDocController.php index 6582fac28..d0f5e623d 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarDocController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarDocController.php @@ -16,7 +16,6 @@ use Chill\CalendarBundle\Entity\CalendarDoc; use Chill\CalendarBundle\Form\CalendarDocCreateType; use Chill\CalendarBundle\Form\CalendarDocEditType; use Chill\CalendarBundle\Security\Voter\CalendarDocVoter; -use Chill\DocGeneratorBundle\Repository\DocGeneratorTemplateRepository; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\FormFactoryInterface; @@ -27,9 +26,6 @@ use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Security\Core\Security; -use Symfony\Component\Serializer\SerializerInterface; -use Symfony\Component\Templating\EngineInterface; -use UnexpectedValueException; final readonly class CalendarDocController { @@ -69,7 +65,7 @@ final readonly class CalendarDocController break; default: - throw new UnexpectedValueException('Unsupported context'); + throw new \UnexpectedValueException('Unsupported context'); } $calendarDocDTO = new CalendarDoc\CalendarDocCreateDTO(); @@ -186,7 +182,7 @@ final readonly class CalendarDocController break; default: - throw new UnexpectedValueException('Unsupported context'); + throw new \UnexpectedValueException('Unsupported context'); } $calendarDocEditDTO = new CalendarDoc\CalendarDocEditDTO($calendarDoc); diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarRangeAPIController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarRangeAPIController.php index e7e688ae3..459d8f6aa 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarRangeAPIController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarRangeAPIController.php @@ -15,12 +15,10 @@ use Chill\CalendarBundle\Repository\CalendarRangeRepository; use Chill\MainBundle\CRUD\Controller\ApiController; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Serializer\Model\Collection; -use DateTimeImmutable; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; - use Symfony\Component\Routing\Annotation\Route; class CalendarRangeAPIController extends ApiController @@ -35,15 +33,15 @@ class CalendarRangeAPIController extends ApiController */ public function availableRanges(User $user, Request $request, string $_format): JsonResponse { - //return new JsonResponse(['ok' => true], 200, [], false); + // return new JsonResponse(['ok' => true], 200, [], false); $this->denyAccessUnlessGranted('ROLE_USER'); if (!$request->query->has('dateFrom')) { throw new BadRequestHttpException('You must provide a dateFrom parameter'); } - if (false === $dateFrom = DateTimeImmutable::createFromFormat( - DateTimeImmutable::ATOM, + if (false === $dateFrom = \DateTimeImmutable::createFromFormat( + \DateTimeImmutable::ATOM, $request->query->get('dateFrom') )) { throw new BadRequestHttpException('dateFrom not parsable'); @@ -53,8 +51,8 @@ class CalendarRangeAPIController extends ApiController throw new BadRequestHttpException('You must provide a dateTo parameter'); } - if (false === $dateTo = DateTimeImmutable::createFromFormat( - DateTimeImmutable::ATOM, + if (false === $dateTo = \DateTimeImmutable::createFromFormat( + \DateTimeImmutable::ATOM, $request->query->get('dateTo') )) { throw new BadRequestHttpException('dateTo not parsable'); diff --git a/src/Bundle/ChillCalendarBundle/Controller/InviteApiController.php b/src/Bundle/ChillCalendarBundle/Controller/InviteApiController.php index a3069044b..784a6f6ce 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/InviteApiController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/InviteApiController.php @@ -31,7 +31,6 @@ use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\Messenger\MessageBusInterface; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Security\Core\Security; -use function in_array; class InviteApiController { @@ -58,7 +57,7 @@ class InviteApiController throw new AccessDeniedHttpException('not allowed to answer on this invitation'); } - if (!in_array($answer, Invite::STATUSES, true)) { + if (!\in_array($answer, Invite::STATUSES, true)) { throw new BadRequestHttpException('answer not valid'); } diff --git a/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarMSGraphSyncController.php b/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarMSGraphSyncController.php index 20b7a4a55..e7d423abd 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarMSGraphSyncController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarMSGraphSyncController.php @@ -19,13 +19,11 @@ declare(strict_types=1); namespace Chill\CalendarBundle\Controller; use Chill\CalendarBundle\Messenger\Message\MSGraphChangeNotificationMessage; -use JsonException; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\Messenger\MessageBusInterface; use Symfony\Component\Routing\Annotation\Route; -use const JSON_THROW_ON_ERROR; class RemoteCalendarMSGraphSyncController { @@ -44,8 +42,8 @@ class RemoteCalendarMSGraphSyncController } try { - $body = json_decode($request->getContent(), true, 512, JSON_THROW_ON_ERROR); - } catch (JsonException $e) { + $body = json_decode($request->getContent(), true, 512, \JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { throw new BadRequestHttpException('could not decode json', $e); } diff --git a/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarProxyController.php b/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarProxyController.php index e4b030c40..673912c0a 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarProxyController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/RemoteCalendarProxyController.php @@ -22,14 +22,12 @@ use Chill\CalendarBundle\RemoteCalendar\Connector\RemoteCalendarConnectorInterfa use Chill\MainBundle\Entity\User; use Chill\MainBundle\Pagination\PaginatorFactory; use Chill\MainBundle\Serializer\Model\Collection; -use DateTimeImmutable; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Serializer\SerializerInterface; -use function count; /** * Contains method to get events (Calendar) from remote calendar. @@ -47,8 +45,8 @@ class RemoteCalendarProxyController throw new BadRequestHttpException('You must provide a dateFrom parameter'); } - if (false === $dateFrom = DateTimeImmutable::createFromFormat( - DateTimeImmutable::ATOM, + if (false === $dateFrom = \DateTimeImmutable::createFromFormat( + \DateTimeImmutable::ATOM, $request->query->get('dateFrom') )) { throw new BadRequestHttpException('dateFrom not parsable'); @@ -58,8 +56,8 @@ class RemoteCalendarProxyController throw new BadRequestHttpException('You must provide a dateTo parameter'); } - if (false === $dateTo = DateTimeImmutable::createFromFormat( - DateTimeImmutable::ATOM, + if (false === $dateTo = \DateTimeImmutable::createFromFormat( + \DateTimeImmutable::ATOM, $request->query->get('dateTo') )) { throw new BadRequestHttpException('dateTo not parsable'); @@ -87,8 +85,8 @@ class RemoteCalendarProxyController // in some case, we cannot paginate: we have to fetch all the items at once. We must avoid // further requests by forcing the number of items returned. - if (count($events) > $paginator->getItemsPerPage()) { - $paginator->setItemsPerPage(count($events)); + if (\count($events) > $paginator->getItemsPerPage()) { + $paginator->setItemsPerPage(\count($events)); } $collection = new Collection($events, $paginator); diff --git a/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCalendarACL.php b/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCalendarACL.php index 6915f2e89..2ef7365ca 100644 --- a/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCalendarACL.php +++ b/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCalendarACL.php @@ -28,7 +28,7 @@ class LoadCalendarACL extends Fixture implements OrderedFixtureInterface foreach ([ CalendarVoter::CREATE, CalendarVoter::DELETE, - CalendarVoter::DELETE + CalendarVoter::DELETE, ] as $role) { $roleScopes[] = $r = (new RoleScope()) ->setRole($role); @@ -51,5 +51,4 @@ class LoadCalendarACL extends Fixture implements OrderedFixtureInterface { return 16000; } - } diff --git a/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCalendarRange.php b/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCalendarRange.php index bddf70866..f222823bf 100644 --- a/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCalendarRange.php +++ b/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCalendarRange.php @@ -18,7 +18,6 @@ use Chill\MainBundle\Entity\Location; use Chill\MainBundle\Entity\LocationType; use Chill\MainBundle\Entity\PostalCode; use Chill\MainBundle\Repository\UserRepository; -use DateTimeImmutable; use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Bundle\FixturesBundle\FixtureGroupInterface; use Doctrine\Common\DataFixtures\OrderedFixtureInterface; @@ -63,7 +62,7 @@ class LoadCalendarRange extends Fixture implements FixtureGroupInterface, Ordere $manager->persist($type); $manager->persist($location); - $now = new DateTimeImmutable(); + $now = new \DateTimeImmutable(); $days = [ '2021-08-23', @@ -74,8 +73,8 @@ class LoadCalendarRange extends Fixture implements FixtureGroupInterface, Ordere '2021-08-31', '2021-09-01', '2021-09-02', - (new DateTimeImmutable('tomorrow'))->format('Y-m-d'), - (new DateTimeImmutable('today'))->format('Y-m-d'), + (new \DateTimeImmutable('tomorrow'))->format('Y-m-d'), + (new \DateTimeImmutable('today'))->format('Y-m-d'), $now->add(new \DateInterval('P7D'))->format('Y-m-d'), $now->add(new \DateInterval('P8D'))->format('Y-m-d'), $now->add(new \DateInterval('P9D'))->format('Y-m-d'), @@ -92,9 +91,9 @@ class LoadCalendarRange extends Fixture implements FixtureGroupInterface, Ordere foreach ($users as $u) { foreach ($days as $d) { foreach ($hours as $h) { - $event = $d . ' ' . $h; - $startEvent = new DateTimeImmutable($event); - $endEvent = new DateTimeImmutable($event . ' + 1 hours'); + $event = $d.' '.$h; + $startEvent = new \DateTimeImmutable($event); + $endEvent = new \DateTimeImmutable($event.' + 1 hours'); $calendarRange = (new CalendarRange()) ->setUser($u) ->setStartDate($startEvent) diff --git a/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCancelReason.php b/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCancelReason.php index bc5de7f70..d7e552d5d 100644 --- a/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCancelReason.php +++ b/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCancelReason.php @@ -39,12 +39,12 @@ class LoadCancelReason extends Fixture implements FixtureGroupInterface ]; foreach ($arr as $a) { - echo 'Creating calendar cancel reason : ' . $a['name'] . "\n"; + echo 'Creating calendar cancel reason : '.$a['name']."\n"; $cancelReason = (new CancelReason()) ->setCanceledBy($a['name']) ->setActive(true); $manager->persist($cancelReason); - $reference = 'CancelReason_' . $a['name']; + $reference = 'CancelReason_'.$a['name']; $this->addReference($reference, $cancelReason); static::$references[] = $reference; } diff --git a/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadInvite.php b/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadInvite.php index ba325e296..f677a4283 100644 --- a/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadInvite.php +++ b/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadInvite.php @@ -46,12 +46,12 @@ class LoadInvite extends Fixture implements FixtureGroupInterface ]; foreach ($arr as $a) { - echo 'Creating calendar invite : ' . $a['name']['fr'] . "\n"; + echo 'Creating calendar invite : '.$a['name']['fr']."\n"; $invite = (new Invite()) ->setStatus($a['status']) ->setUser($this->getRandomUser()); $manager->persist($invite); - $reference = 'Invite_' . $a['name']['fr']; + $reference = 'Invite_'.$a['name']['fr']; $this->addReference($reference, $invite); static::$references[] = $reference; } diff --git a/src/Bundle/ChillCalendarBundle/DependencyInjection/ChillCalendarExtension.php b/src/Bundle/ChillCalendarBundle/DependencyInjection/ChillCalendarExtension.php index c848366bb..5aa8d8507 100644 --- a/src/Bundle/ChillCalendarBundle/DependencyInjection/ChillCalendarExtension.php +++ b/src/Bundle/ChillCalendarBundle/DependencyInjection/ChillCalendarExtension.php @@ -31,7 +31,7 @@ class ChillCalendarExtension extends Extension implements PrependExtensionInterf $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); - $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); + $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.yml'); $loader->load('services/exports.yaml'); $loader->load('services/controller.yml'); diff --git a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php index dd61dd39a..32308a50c 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php +++ b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php @@ -24,29 +24,26 @@ use Chill\MainBundle\Entity\User; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; use Chill\ThirdPartyBundle\Entity\ThirdParty; -use DateInterval; -use DateTimeImmutable; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\ReadableCollection; use Doctrine\Common\Collections\Selectable; use Doctrine\ORM\Mapping as ORM; -use LogicException; use Symfony\Component\Serializer\Annotation as Serializer; use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints\NotBlank; - use Symfony\Component\Validator\Constraints\Range; use Symfony\Component\Validator\Mapping\ClassMetadata; -use function in_array; /** * @ORM\Table( * name="chill_calendar.calendar", * uniqueConstraints={@ORM\UniqueConstraint(name="idx_calendar_remote", columns={"remoteId"}, options={"where": "remoteId <> ''"})} * ) + * * @ORM\Entity + * * @Serializer\DiscriminatorMap(typeProperty="type", mapping={ * "chill_calendar_calendar": Calendar::class * }) @@ -94,6 +91,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente /** * @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod", inversedBy="calendars") + * * @Serializer\Groups({"calendar:read", "read"}) */ private ?AccompanyingPeriod $accompanyingPeriod = null; @@ -105,6 +103,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente /** * @ORM\OneToOne(targetEntity="CalendarRange", inversedBy="calendar") + * * @Serializer\Groups({"calendar:read", "read"}) */ private ?CalendarRange $calendarRange = null; @@ -116,6 +115,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente /** * @ORM\Embedded(class=CommentEmbeddable::class, columnPrefix="comment_") + * * @Serializer\Groups({"calendar:read", "read", "docgen:read"}) */ private CommentEmbeddable $comment; @@ -127,21 +127,27 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente /** * @var Collection + * * @ORM\OneToMany(targetEntity=CalendarDoc::class, mappedBy="calendar", orphanRemoval=true) */ private Collection $documents; /** * @ORM\Column(type="datetime_immutable", nullable=false) + * * @Serializer\Groups({"calendar:read", "read", "calendar:light", "docgen:read"}) + * * @Assert\NotNull(message="calendar.An end date is required") */ - private ?DateTimeImmutable $endDate = null; + private ?\DateTimeImmutable $endDate = null; /** * @ORM\Id + * * @ORM\GeneratedValue + * * @ORM\Column(type="integer") + * * @Serializer\Groups({"calendar:read", "read", "calendar:light", "docgen:read"}) */ private ?int $id = null; @@ -153,60 +159,80 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente * orphanRemoval=true, * cascade={"persist", "remove", "merge", "detach"} * ) + * * @ORM\JoinTable(name="chill_calendar.calendar_to_invites") + * * @Serializer\Groups({"read", "docgen:read"}) + * * @var Collection&Selectable */ private Collection&Selectable $invites; /** * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Location") + * * @Serializer\Groups({"read", "docgen:read"}) + * * @Assert\NotNull(message="calendar.A location is required") */ private ?Location $location = null; /** * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User") + * * @Serializer\Groups({"calendar:read", "read", "calendar:light", "docgen:read"}) + * * @Serializer\Context(normalizationContext={"read"}, groups={"calendar:light"}) + * * @Assert\NotNull(message="calendar.A main user is mandatory") */ private ?User $mainUser = null; /** * @ORM\ManyToOne(targetEntity=Person::class) + * * @ORM\JoinColumn(nullable=true) */ private ?Person $person = null; /** * @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\Person", inversedBy="calendars") + * * @ORM\JoinTable(name="chill_calendar.calendar_to_persons") + * * @Serializer\Groups({"calendar:read", "read", "calendar:light", "docgen:read"}) + * * @Serializer\Context(normalizationContext={"read"}, groups={"calendar:light"}) + * * @Assert\Count(min=1, minMessage="calendar.At least {{ limit }} person is required.") + * * @var Collection */ private Collection $persons; /** * @ORM\Embedded(class=PrivateCommentEmbeddable::class, columnPrefix="privateComment_") + * * @Serializer\Groups({"calendar:read"}) */ private PrivateCommentEmbeddable $privateComment; /** * @var Collection + * * @ORM\ManyToMany(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty") + * * @ORM\JoinTable(name="chill_calendar.calendar_to_thirdparties") + * * @Serializer\Groups({"calendar:read", "read", "calendar:light", "docgen:read"}) + * * @Serializer\Context(normalizationContext={"read"}, groups={"calendar:light"}) */ private Collection $professionals; /** * @ORM\Column(type="boolean", nullable=true) + * * @Serializer\Groups({"docgen:read"}) */ private ?bool $sendSMS = false; @@ -218,21 +244,27 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente /** * @ORM\Column(type="datetime_immutable", nullable=false) + * * @Serializer\Groups({"calendar:read", "read", "calendar:light", "docgen:read"}) + * * @Serializer\Context(normalizationContext={"read"}, groups={"calendar:light"}) + * * @Assert\NotNull(message="calendar.A start date is required") */ - private ?DateTimeImmutable $startDate = null; + private ?\DateTimeImmutable $startDate = null; /** * @ORM\Column(type="string", length=255, nullable=false, options={"default": "valid"}) + * * @Serializer\Groups({"calendar:read", "read", "calendar:light"}) + * * @Serializer\Context(normalizationContext={"read"}, groups={"calendar:light"}) */ private string $status = self::STATUS_VALID; /** * @ORM\Column(type="boolean", nullable=true) + * * @Serializer\Groups({"docgen:read"}) */ private ?bool $urgent = false; @@ -265,7 +297,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente public function addInvite(Invite $invite): self { if ($invite->getCalendar() instanceof Calendar && $invite->getCalendar() !== $this) { - throw new LogicException('Not allowed to move an invitation to another Calendar'); + throw new \LogicException('Not allowed to move an invitation to another Calendar'); } $this->invites[] = $invite; @@ -324,7 +356,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente return match ($this->getContext()) { 'person' => [$this->getPerson()->getCenter()], 'accompanying_period' => $this->getAccompanyingPeriod()->getCenters(), - default => throw new LogicException('context not supported: ' . $this->getContext()), + default => throw new \LogicException('context not supported: '.$this->getContext()), }; } @@ -338,11 +370,11 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente */ public function getContext(): ?string { - if ($this->getAccompanyingPeriod() !== null) { + if (null !== $this->getAccompanyingPeriod()) { return 'accompanying_period'; } - if ($this->getPerson() !== null) { + if (null !== $this->getPerson()) { return 'person'; } @@ -365,16 +397,16 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente /** * @Serializer\Groups({"docgen:read"}) */ - public function getDuration(): ?DateInterval + public function getDuration(): ?\DateInterval { - if ($this->getStartDate() === null || $this->getEndDate() === null) { + if (null === $this->getStartDate() || null === $this->getEndDate()) { return null; } return $this->getStartDate()->diff($this->getEndDate()); } - public function getEndDate(): ?DateTimeImmutable + public function getEndDate(): ?\DateTimeImmutable { return $this->endDate; } @@ -453,7 +485,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente $personsNotAssociated = []; foreach ($this->persons as $person) { - if (!in_array($person, $this->getPersonsAssociated(), true)) { + if (!\in_array($person, $this->getPersonsAssociated(), true)) { $personsNotAssociated[] = $person; } } @@ -487,7 +519,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente return $this->smsStatus; } - public function getStartDate(): ?DateTimeImmutable + public function getStartDate(): ?\DateTimeImmutable { return $this->startDate; } @@ -509,6 +541,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente /** * @return ReadableCollection<(int|string), User> + * * @Serializer\Groups({"calendar:read", "read"}) */ public function getUsers(): ReadableCollection @@ -558,7 +591,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente public function removeDocument(CalendarDoc $calendarDoc): self { if ($calendarDoc->getCalendar() !== $this) { - throw new LogicException('cannot remove document of another calendar'); + throw new \LogicException('cannot remove document of another calendar'); } return $this; @@ -652,7 +685,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente return $this; } - public function setEndDate(DateTimeImmutable $endDate): self + public function setEndDate(\DateTimeImmutable $endDate): self { if (null === $this->endDate || $this->endDate->getTimestamp() !== $endDate->getTimestamp()) { $this->increaseaDatetimeVersion(); @@ -710,7 +743,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente return $this; } - public function setStartDate(DateTimeImmutable $startDate): self + public function setStartDate(\DateTimeImmutable $startDate): self { if (null === $this->startDate || $this->startDate->getTimestamp() !== $startDate->getTimestamp()) { $this->increaseaDatetimeVersion(); @@ -725,7 +758,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente { $this->status = $status; - if (self::STATUS_CANCELED === $status && $this->getSmsStatus() === self::SMS_SENT) { + if (self::STATUS_CANCELED === $status && self::SMS_SENT === $this->getSmsStatus()) { $this->setSmsStatus(self::SMS_CANCEL_PENDING); } diff --git a/src/Bundle/ChillCalendarBundle/Entity/CalendarDoc.php b/src/Bundle/ChillCalendarBundle/Entity/CalendarDoc.php index 763488560..5ea958fab 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/CalendarDoc.php +++ b/src/Bundle/ChillCalendarBundle/Entity/CalendarDoc.php @@ -22,6 +22,7 @@ use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity + * * @ORM\Table( * name="chill_calendar.calendar_doc", * ) @@ -34,6 +35,7 @@ class CalendarDoc implements TrackCreationInterface, TrackUpdateInterface /** * @ORM\ManyToOne(targetEntity=Calendar::class, inversedBy="documents") + * * @ORM\JoinColumn(nullable=false) */ private Calendar $calendar; @@ -45,7 +47,9 @@ class CalendarDoc implements TrackCreationInterface, TrackUpdateInterface /** * @ORM\Id + * * @ORM\GeneratedValue + * * @ORM\Column(type="integer") */ private ?int $id = null; @@ -57,9 +61,10 @@ class CalendarDoc implements TrackCreationInterface, TrackUpdateInterface public function __construct(Calendar $calendar, /** * @ORM\ManyToOne(targetEntity=StoredObject::class, cascade={"persist"}) + * * @ORM\JoinColumn(nullable=false) */ - private ?\Chill\DocStoreBundle\Entity\StoredObject $storedObject) + private ?StoredObject $storedObject) { $this->setCalendar($calendar); $this->datetimeVersion = $calendar->getDateTimeVersion(); @@ -108,8 +113,6 @@ class CalendarDoc implements TrackCreationInterface, TrackUpdateInterface /** * @internal use @see{Calendar::removeDocument} instead - * - * @param Calendar $calendar */ public function setCalendar(?Calendar $calendar): CalendarDoc { diff --git a/src/Bundle/ChillCalendarBundle/Entity/CalendarDoc/CalendarDocCreateDTO.php b/src/Bundle/ChillCalendarBundle/Entity/CalendarDoc/CalendarDocCreateDTO.php index b7209e46f..ff4e10402 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/CalendarDoc/CalendarDocCreateDTO.php +++ b/src/Bundle/ChillCalendarBundle/Entity/CalendarDoc/CalendarDocCreateDTO.php @@ -18,12 +18,14 @@ class CalendarDocCreateDTO { /** * @Assert\NotNull + * * @Assert\Valid */ public ?StoredObject $doc = null; /** * @Assert\NotBlank + * * @Assert\NotNull */ public ?string $title = ''; diff --git a/src/Bundle/ChillCalendarBundle/Entity/CalendarDoc/CalendarDocEditDTO.php b/src/Bundle/ChillCalendarBundle/Entity/CalendarDoc/CalendarDocEditDTO.php index ff57d9876..2e8970db6 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/CalendarDoc/CalendarDocEditDTO.php +++ b/src/Bundle/ChillCalendarBundle/Entity/CalendarDoc/CalendarDocEditDTO.php @@ -24,6 +24,7 @@ class CalendarDocEditDTO /** * @Assert\NotBlank + * * @Assert\NotNull */ public ?string $title = ''; diff --git a/src/Bundle/ChillCalendarBundle/Entity/CalendarRange.php b/src/Bundle/ChillCalendarBundle/Entity/CalendarRange.php index 6bd44aeca..0c46db57c 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/CalendarRange.php +++ b/src/Bundle/ChillCalendarBundle/Entity/CalendarRange.php @@ -17,7 +17,6 @@ use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface; use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait; use Chill\MainBundle\Entity\Location; use Chill\MainBundle\Entity\User; -use DateTimeImmutable; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Validator\Constraints as Assert; @@ -27,6 +26,7 @@ use Symfony\Component\Validator\Constraints as Assert; * name="chill_calendar.calendar_range", * uniqueConstraints={@ORM\UniqueConstraint(name="idx_calendar_range_remote", columns={"remoteId"}, options={"where": "remoteId <> ''"})} * ) + * * @ORM\Entity */ class CalendarRange implements TrackCreationInterface, TrackUpdateInterface @@ -44,37 +44,49 @@ class CalendarRange implements TrackCreationInterface, TrackUpdateInterface /** * @ORM\Column(type="datetime_immutable", nullable=false) + * * @Groups({"read", "write", "calendar:read"}) + * * @Assert\NotNull */ - private ?DateTimeImmutable $endDate = null; + private ?\DateTimeImmutable $endDate = null; /** * @ORM\Id + * * @ORM\GeneratedValue + * * @ORM\Column(type="integer") + * * @Groups({"read"}) */ private ?int $id = null; /** * @ORM\ManyToOne(targetEntity=Location::class) + * * @ORM\JoinColumn(nullable=false) + * * @Groups({"read", "write", "calendar:read"}) + * * @Assert\NotNull */ private ?Location $location = null; /** * @ORM\Column(type="datetime_immutable", nullable=false) + * * @groups({"read", "write", "calendar:read"}) + * * @Assert\NotNull */ - private ?DateTimeImmutable $startDate = null; + private ?\DateTimeImmutable $startDate = null; /** * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User") + * * @Groups({"read", "write", "calendar:read"}) + * * @Assert\NotNull */ private ?User $user = null; @@ -84,7 +96,7 @@ class CalendarRange implements TrackCreationInterface, TrackUpdateInterface return $this->calendar; } - public function getEndDate(): ?DateTimeImmutable + public function getEndDate(): ?\DateTimeImmutable { return $this->endDate; } @@ -99,7 +111,7 @@ class CalendarRange implements TrackCreationInterface, TrackUpdateInterface return $this->location; } - public function getStartDate(): ?DateTimeImmutable + public function getStartDate(): ?\DateTimeImmutable { return $this->startDate; } @@ -117,7 +129,7 @@ class CalendarRange implements TrackCreationInterface, TrackUpdateInterface $this->calendar = $calendar; } - public function setEndDate(DateTimeImmutable $endDate): self + public function setEndDate(\DateTimeImmutable $endDate): self { $this->endDate = $endDate; @@ -131,7 +143,7 @@ class CalendarRange implements TrackCreationInterface, TrackUpdateInterface return $this; } - public function setStartDate(DateTimeImmutable $startDate): self + public function setStartDate(\DateTimeImmutable $startDate): self { $this->startDate = $startDate; diff --git a/src/Bundle/ChillCalendarBundle/Entity/CancelReason.php b/src/Bundle/ChillCalendarBundle/Entity/CancelReason.php index 6ed74e8d9..cff54e70b 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/CancelReason.php +++ b/src/Bundle/ChillCalendarBundle/Entity/CancelReason.php @@ -16,6 +16,7 @@ use Doctrine\ORM\Mapping as ORM; /** * @ORM\Table(name="chill_calendar.cancel_reason") + * * @ORM\Entity(repositoryClass=CancelReasonRepository::class) */ class CancelReason @@ -38,7 +39,9 @@ class CancelReason /** * @ORM\Id + * * @ORM\GeneratedValue + * * @ORM\Column(type="integer") */ private ?int $id = null; diff --git a/src/Bundle/ChillCalendarBundle/Entity/Invite.php b/src/Bundle/ChillCalendarBundle/Entity/Invite.php index da1b9bb9e..48fe865b0 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/Invite.php +++ b/src/Bundle/ChillCalendarBundle/Entity/Invite.php @@ -17,7 +17,6 @@ use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface; use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait; use Chill\MainBundle\Entity\User; use Doctrine\ORM\Mapping as ORM; -use LogicException; use Symfony\Component\Serializer\Annotation as Serializer; /** @@ -30,6 +29,7 @@ use Symfony\Component\Serializer\Annotation as Serializer; * name="chill_calendar.invite", * uniqueConstraints={@ORM\UniqueConstraint(name="idx_calendar_invite_remote", columns={"remoteId"}, options={"where": "remoteId <> ''"})} * ) + * * @ORM\Entity */ class Invite implements TrackUpdateInterface, TrackCreationInterface @@ -65,21 +65,27 @@ class Invite implements TrackUpdateInterface, TrackCreationInterface /** * @ORM\Id + * * @ORM\GeneratedValue + * * @ORM\Column(type="integer") + * * @Serializer\Groups(groups={"calendar:read", "read"}) */ private ?int $id = null; /** * @ORM\Column(type="text", nullable=false, options={"default": "pending"}) + * * @Serializer\Groups(groups={"calendar:read", "read", "docgen:read"}) */ private string $status = self::PENDING; /** * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User") + * * @ORM\JoinColumn(nullable=false) + * * @Serializer\Groups(groups={"calendar:read", "read", "docgen:read"}) */ private ?User $user = null; @@ -122,7 +128,7 @@ class Invite implements TrackUpdateInterface, TrackCreationInterface public function setUser(?User $user): self { if ($user instanceof User && $this->user instanceof User && $user !== $this->user) { - throw new LogicException('Not allowed to associate an invite to a different user'); + throw new \LogicException('Not allowed to associate an invite to a different user'); } $this->user = $user; diff --git a/src/Bundle/ChillCalendarBundle/Event/ListenToActivityCreate.php b/src/Bundle/ChillCalendarBundle/Event/ListenToActivityCreate.php index fab77afc4..82c76eea4 100644 --- a/src/Bundle/ChillCalendarBundle/Event/ListenToActivityCreate.php +++ b/src/Bundle/ChillCalendarBundle/Event/ListenToActivityCreate.php @@ -15,8 +15,6 @@ use Chill\ActivityBundle\Entity\Activity; use Doctrine\Persistence\Event\LifecycleEventArgs; use Symfony\Component\HttpFoundation\RequestStack; -use function array_key_exists; - class ListenToActivityCreate { public function __construct(private readonly RequestStack $requestStack) {} @@ -33,7 +31,7 @@ class ListenToActivityCreate if ($request->query->has('activityData')) { $activityData = $request->query->get('activityData'); - if (array_key_exists('calendarId', $activityData)) { + if (\array_key_exists('calendarId', $activityData)) { $calendarId = $activityData['calendarId']; // Attach the activity to the calendar diff --git a/src/Bundle/ChillCalendarBundle/Exception/UserAbsenceSyncException.php b/src/Bundle/ChillCalendarBundle/Exception/UserAbsenceSyncException.php index a5e5a679a..dd2c0b9c2 100644 --- a/src/Bundle/ChillCalendarBundle/Exception/UserAbsenceSyncException.php +++ b/src/Bundle/ChillCalendarBundle/Exception/UserAbsenceSyncException.php @@ -13,7 +13,7 @@ namespace Chill\CalendarBundle\Exception; class UserAbsenceSyncException extends \LogicException { - public function __construct(string $message = "", int $code = 20_230_706, ?\Throwable $previous = null) + public function __construct(string $message = '', int $code = 20_230_706, \Throwable $previous = null) { parent::__construct($message, $code, $previous); } diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php index be389b5f0..5e2091fac 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php @@ -15,10 +15,8 @@ use Chill\CalendarBundle\Export\Declarations; use Chill\MainBundle\Export\AggregatorInterface; use Chill\MainBundle\Repository\UserRepository; use Chill\MainBundle\Templating\Entity\UserRender; -use Closure; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; -use function in_array; final readonly class AgentAggregator implements AggregatorInterface { @@ -31,7 +29,7 @@ final readonly class AgentAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('caluser', $qb->getAllAliases(), true)) { + if (!\in_array('caluser', $qb->getAllAliases(), true)) { $qb->join('cal.mainUser', 'caluser'); } @@ -48,12 +46,13 @@ final readonly class AgentAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array { return []; } - public function getLabels($key, array $values, $data): Closure + public function getLabels($key, array $values, $data): \Closure { return function ($value): string { if ('_header' === $value) { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php index 66e94b8e7..7c84653d2 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php @@ -15,10 +15,8 @@ use Chill\CalendarBundle\Export\Declarations; use Chill\CalendarBundle\Repository\CancelReasonRepository; use Chill\MainBundle\Export\AggregatorInterface; use Chill\MainBundle\Templating\TranslatableStringHelper; -use Closure; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; -use function in_array; class CancelReasonAggregator implements AggregatorInterface { @@ -32,7 +30,7 @@ class CancelReasonAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { // TODO: still needs to take into account calendars without a cancel reason somehow - if (!in_array('calcancel', $qb->getAllAliases(), true)) { + if (!\in_array('calcancel', $qb->getAllAliases(), true)) { $qb->join('cal.cancelReason', 'calcancel'); } @@ -49,12 +47,13 @@ class CancelReasonAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array { return []; } - public function getLabels($key, array $values, $data): Closure + public function getLabels($key, array $values, $data): \Closure { return function ($value): string { if ('_header' === $value) { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php index 189d70130..76cbe5cd8 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php @@ -16,7 +16,6 @@ use Chill\MainBundle\Entity\User\UserJobHistory; use Chill\MainBundle\Export\AggregatorInterface; use Chill\MainBundle\Repository\UserJobRepository; use Chill\MainBundle\Templating\TranslatableStringHelper; -use Closure; use Doctrine\ORM\Query\Expr\Join; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; @@ -50,10 +49,10 @@ final readonly class JobAggregator implements AggregatorInterface // job_at based on cal.startDate ->andWhere( $qb->expr()->andX( - $qb->expr()->lte("{$p}_history.startDate", "cal.startDate"), + $qb->expr()->lte("{$p}_history.startDate", 'cal.startDate'), $qb->expr()->orX( $qb->expr()->isNull("{$p}_history.endDate"), - $qb->expr()->gt("{$p}_history.endDate", "cal.startDate") + $qb->expr()->gt("{$p}_history.endDate", 'cal.startDate') ) ) ) @@ -73,7 +72,7 @@ final readonly class JobAggregator implements AggregatorInterface return []; } - public function getLabels($key, array $values, $data): Closure + public function getLabels($key, array $values, $data): \Closure { return function ($value): string { if ('_header' === $value) { @@ -96,7 +95,7 @@ final readonly class JobAggregator implements AggregatorInterface public function getQueryKeys($data): array { - return [self::PREFIX . '_select']; + return [self::PREFIX.'_select']; } public function getTitle(): string diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php index b45177bb5..6481f95b4 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php @@ -14,10 +14,8 @@ namespace Chill\CalendarBundle\Export\Aggregator; use Chill\CalendarBundle\Export\Declarations; use Chill\MainBundle\Export\AggregatorInterface; use Chill\MainBundle\Repository\LocationRepository; -use Closure; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; -use function in_array; final readonly class LocationAggregator implements AggregatorInterface { @@ -30,7 +28,7 @@ final readonly class LocationAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('calloc', $qb->getAllAliases(), true)) { + if (!\in_array('calloc', $qb->getAllAliases(), true)) { $qb->join('cal.location', 'calloc'); } $qb->addSelect('IDENTITY(cal.location) as location_aggregator'); @@ -46,12 +44,13 @@ final readonly class LocationAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array { return []; } - public function getLabels($key, array $values, $data): Closure + public function getLabels($key, array $values, $data): \Closure { return function ($value): string { if ('_header' === $value) { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php index 90301e92f..be9406cfa 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php @@ -15,10 +15,8 @@ use Chill\CalendarBundle\Export\Declarations; use Chill\MainBundle\Export\AggregatorInterface; use Chill\MainBundle\Repository\LocationTypeRepository; use Chill\MainBundle\Templating\TranslatableStringHelper; -use Closure; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; -use function in_array; final readonly class LocationTypeAggregator implements AggregatorInterface { @@ -31,7 +29,7 @@ final readonly class LocationTypeAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('calloc', $qb->getAllAliases(), true)) { + if (!\in_array('calloc', $qb->getAllAliases(), true)) { $qb->join('cal.location', 'calloc'); } @@ -48,12 +46,13 @@ final readonly class LocationTypeAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array { return []; } - public function getLabels($key, array $values, $data): Closure + public function getLabels($key, array $values, $data): \Closure { return function ($value): string { if ('_header' === $value) { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/MonthYearAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/MonthYearAggregator.php index b3c2aaf19..6bf65b8ef 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/MonthYearAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/MonthYearAggregator.php @@ -13,7 +13,6 @@ namespace Chill\CalendarBundle\Export\Aggregator; use Chill\CalendarBundle\Export\Declarations; use Chill\MainBundle\Export\AggregatorInterface; -use Closure; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; @@ -40,12 +39,13 @@ class MonthYearAggregator implements AggregatorInterface { // No form needed } + public function getFormDefaultData(): array { return []; } - public function getLabels($key, array $values, $data): Closure + public function getLabels($key, array $values, $data): \Closure { return static function ($value): string { if ('_header' === $value) { diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php index 5412a15d1..4998f6d1f 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php @@ -16,14 +16,13 @@ use Chill\MainBundle\Entity\User\UserScopeHistory; use Chill\MainBundle\Export\AggregatorInterface; use Chill\MainBundle\Repository\ScopeRepository; use Chill\MainBundle\Templating\TranslatableStringHelper; -use Closure; use Doctrine\ORM\Query\Expr\Join; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; final readonly class ScopeAggregator implements AggregatorInterface { - private const PREFIX = "cal_agg_scope"; + private const PREFIX = 'cal_agg_scope'; public function __construct( private ScopeRepository $scopeRepository, @@ -40,7 +39,7 @@ final readonly class ScopeAggregator implements AggregatorInterface $p = self::PREFIX; $qb - ->leftJoin("cal.mainUser", "{$p}_user") + ->leftJoin('cal.mainUser', "{$p}_user") ->leftJoin( UserScopeHistory::class, "{$p}_history", @@ -50,10 +49,10 @@ final readonly class ScopeAggregator implements AggregatorInterface // scope_at based on cal.startDate ->andWhere( $qb->expr()->andX( - $qb->expr()->lte("{$p}_history.startDate", "cal.startDate"), + $qb->expr()->lte("{$p}_history.startDate", 'cal.startDate'), $qb->expr()->orX( $qb->expr()->isNull("{$p}_history.endDate"), - $qb->expr()->gt("{$p}_history.endDate", "cal.startDate") + $qb->expr()->gt("{$p}_history.endDate", 'cal.startDate') ) ) ) @@ -73,7 +72,7 @@ final readonly class ScopeAggregator implements AggregatorInterface return []; } - public function getLabels($key, array $values, $data): Closure + public function getLabels($key, array $values, $data): \Closure { return function ($value): string { if ('_header' === $value) { @@ -96,7 +95,7 @@ final readonly class ScopeAggregator implements AggregatorInterface public function getQueryKeys($data): array { - return [self::PREFIX . '_select']; + return [self::PREFIX.'_select']; } public function getTitle(): string diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/UrgencyAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/UrgencyAggregator.php index f37bdec0f..e9213d3cb 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/UrgencyAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/UrgencyAggregator.php @@ -20,9 +20,7 @@ namespace Chill\CalendarBundle\Export\Aggregator; use Chill\CalendarBundle\Export\Declarations; use Chill\MainBundle\Export\AggregatorInterface; -use Closure; use Doctrine\ORM\QueryBuilder; -use LogicException; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Contracts\Translation\TranslatorInterface; @@ -50,12 +48,13 @@ class UrgencyAggregator implements AggregatorInterface { // no form } + public function getFormDefaultData(): array { return []; } - public function getLabels($key, array $values, $data): Closure + public function getLabels($key, array $values, $data): \Closure { return function ($value): string { if ('_header' === $value) { @@ -65,7 +64,7 @@ class UrgencyAggregator implements AggregatorInterface return match ($value) { true => $this->translator->trans('is urgent'), false => $this->translator->trans('is not urgent'), - default => throw new LogicException(sprintf('The value %s is not valid', $value)), + default => throw new \LogicException(sprintf('The value %s is not valid', $value)), }; }; } diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php b/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php index 771e66504..2e156d7a0 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php @@ -18,7 +18,6 @@ use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; use Chill\PersonBundle\Security\Authorization\PersonVoter; -use Closure; use Doctrine\ORM\AbstractQuery; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; @@ -32,6 +31,7 @@ class CountCalendars implements ExportInterface, GroupedExportInterface { // No form necessary } + public function getFormDefaultData(): array { return []; diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php index 3c73888d5..b69185a17 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php @@ -20,7 +20,6 @@ use Chill\MainBundle\Export\GroupedExportInterface; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; use Doctrine\ORM\Query; use Doctrine\ORM\QueryBuilder; -use LogicException; use Symfony\Component\Form\FormBuilderInterface; class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface @@ -31,6 +30,7 @@ class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface { // no form needed } + public function getFormDefaultData(): array { return []; @@ -54,7 +54,7 @@ class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface public function getLabels($key, array $values, $data) { if ('export_result' !== $key) { - throw new LogicException("the key {$key} is not used by this export"); + throw new \LogicException("the key {$key} is not used by this export"); } $labels = array_combine($values, $values); diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php index 155cf7b69..8ea23014c 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php @@ -20,7 +20,6 @@ use Chill\MainBundle\Export\GroupedExportInterface; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; use Doctrine\ORM\Query; use Doctrine\ORM\QueryBuilder; -use LogicException; use Symfony\Component\Form\FormBuilderInterface; class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface @@ -31,6 +30,7 @@ class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface { // no form needed } + public function getFormDefaultData(): array { return []; @@ -54,7 +54,7 @@ class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface public function getLabels($key, array $values, $data) { if ('export_result' !== $key) { - throw new LogicException("the key {$key} is not used by this export"); + throw new \LogicException("the key {$key} is not used by this export"); } $labels = array_combine($values, $values); diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php index 453e14fae..c16c148fc 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php @@ -58,6 +58,7 @@ class AgentFilter implements FilterInterface 'expanded' => true, ]); } + public function getFormDefaultData(): array { return []; diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php index 4db5d2e80..90a004388 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php @@ -58,6 +58,7 @@ class BetweenDatesFilter implements FilterInterface ->add('date_from', PickRollingDateType::class, []) ->add('date_to', PickRollingDateType::class, []); } + public function getFormDefaultData(): array { return ['date_from' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), 'date_to' => new RollingDate(RollingDate::T_TODAY)]; diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/CalendarRangeFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/CalendarRangeFilter.php index c53e9ba1f..63149509f 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/CalendarRangeFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/CalendarRangeFilter.php @@ -20,7 +20,6 @@ namespace Chill\CalendarBundle\Export\Filter; use Chill\CalendarBundle\Export\Declarations; use Chill\MainBundle\Export\FilterInterface; -use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\FormBuilderInterface; @@ -66,6 +65,7 @@ class CalendarRangeFilter implements FilterInterface 'empty_data' => self::DEFAULT_CHOICE, ]); } + public function getFormDefaultData(): array { return ['hasCalendarRange' => self::DEFAULT_CHOICE]; diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php index 93def5631..c122a298d 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php @@ -20,7 +20,6 @@ use Doctrine\ORM\Query\Expr\Join; use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Contracts\Translation\TranslatorInterface; final readonly class JobFilter implements FilterInterface { @@ -40,7 +39,7 @@ final readonly class JobFilter implements FilterInterface $p = self::PREFIX; $qb - ->leftJoin("cal.mainUser", "{$p}_user") + ->leftJoin('cal.mainUser', "{$p}_user") ->leftJoin( UserJobHistory::class, "{$p}_history", @@ -50,19 +49,18 @@ final readonly class JobFilter implements FilterInterface // job_at based on cal.startDate ->andWhere( $qb->expr()->andX( - $qb->expr()->lte("{$p}_history.startDate", "cal.startDate"), + $qb->expr()->lte("{$p}_history.startDate", 'cal.startDate'), $qb->expr()->orX( $qb->expr()->isNull("{$p}_history.endDate"), - $qb->expr()->gt("{$p}_history.endDate", "cal.startDate") + $qb->expr()->gt("{$p}_history.endDate", 'cal.startDate') ) ) ) ->andWhere($qb->expr()->in("{$p}_history.job", ":{$p}_job")) ->setParameter( "{$p}_job", - $data["job"] + $data['job'] ); - } public function applyOn(): string diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php index e04bd922b..93edc1b3a 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php @@ -41,7 +41,7 @@ class ScopeFilter implements FilterInterface $p = self::PREFIX; $qb - ->leftJoin("cal.mainUser", "{$p}_user") + ->leftJoin('cal.mainUser', "{$p}_user") ->leftJoin( UserScopeHistory::class, "{$p}_history", @@ -51,17 +51,17 @@ class ScopeFilter implements FilterInterface // scope_at based on cal.startDate ->andWhere( $qb->expr()->andX( - $qb->expr()->lte("{$p}_history.startDate", "cal.startDate"), + $qb->expr()->lte("{$p}_history.startDate", 'cal.startDate'), $qb->expr()->orX( $qb->expr()->isNull("{$p}_history.endDate"), - $qb->expr()->gt("{$p}_history.endDate", "cal.startDate") + $qb->expr()->gt("{$p}_history.endDate", 'cal.startDate') ) ) ) ->andWhere($qb->expr()->in("{$p}_history.scope", ":{$p}_scope")) ->setParameter( "{$p}_scope", - $data["scope"] + $data['scope'] ); } diff --git a/src/Bundle/ChillCalendarBundle/Form/CalendarDocEditType.php b/src/Bundle/ChillCalendarBundle/Form/CalendarDocEditType.php index 34a501028..224a74f01 100644 --- a/src/Bundle/ChillCalendarBundle/Form/CalendarDocEditType.php +++ b/src/Bundle/ChillCalendarBundle/Form/CalendarDocEditType.php @@ -12,7 +12,6 @@ declare(strict_types=1); namespace Chill\CalendarBundle\Form; use Chill\CalendarBundle\Entity\CalendarDoc\CalendarDocEditDTO; -use Chill\DocStoreBundle\Form\StoredObjectType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/Bundle/ChillCalendarBundle/Form/CalendarType.php b/src/Bundle/ChillCalendarBundle/Form/CalendarType.php index 702e27695..eec0b3f9f 100644 --- a/src/Bundle/ChillCalendarBundle/Form/CalendarType.php +++ b/src/Bundle/ChillCalendarBundle/Form/CalendarType.php @@ -21,7 +21,6 @@ use Chill\MainBundle\Form\Type\CommentType; use Chill\MainBundle\Form\Type\PrivateCommentType; use Chill\PersonBundle\Form\DataTransformer\PersonsToIdDataTransformer; use Chill\ThirdPartyBundle\Form\DataTransformer\ThirdPartiesToIdDataTransformer; -use DateTimeImmutable; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\CallbackTransformer; @@ -72,42 +71,42 @@ class CalendarType extends AbstractType $builder->add('startDate', HiddenType::class); $builder->get('startDate') ->addModelTransformer(new CallbackTransformer( - static function (?DateTimeImmutable $dateTimeImmutable): string { + static function (?\DateTimeImmutable $dateTimeImmutable): string { if (null !== $dateTimeImmutable) { - $res = date_format($dateTimeImmutable, DateTimeImmutable::ATOM); + $res = date_format($dateTimeImmutable, \DateTimeImmutable::ATOM); } else { $res = ''; } return $res; }, - static function (?string $dateAsString): ?DateTimeImmutable { + static function (?string $dateAsString): ?\DateTimeImmutable { if ('' === $dateAsString || null === $dateAsString) { return null; } - return DateTimeImmutable::createFromFormat(DateTimeImmutable::ATOM, $dateAsString); + return \DateTimeImmutable::createFromFormat(\DateTimeImmutable::ATOM, $dateAsString); } )); $builder->add('endDate', HiddenType::class); $builder->get('endDate') ->addModelTransformer(new CallbackTransformer( - static function (?DateTimeImmutable $dateTimeImmutable): string { + static function (?\DateTimeImmutable $dateTimeImmutable): string { if (null !== $dateTimeImmutable) { - $res = date_format($dateTimeImmutable, DateTimeImmutable::ATOM); + $res = date_format($dateTimeImmutable, \DateTimeImmutable::ATOM); } else { $res = ''; } return $res; }, - static function (?string $dateAsString): ?DateTimeImmutable { + static function (?string $dateAsString): ?\DateTimeImmutable { if ('' === $dateAsString || null === $dateAsString) { return null; } - return DateTimeImmutable::createFromFormat(DateTimeImmutable::ATOM, $dateAsString); + return \DateTimeImmutable::createFromFormat(\DateTimeImmutable::ATOM, $dateAsString); } )); diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Doctrine/CalendarEntityListener.php b/src/Bundle/ChillCalendarBundle/Messenger/Doctrine/CalendarEntityListener.php index 007e781cb..8f62fdcdb 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Doctrine/CalendarEntityListener.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Doctrine/CalendarEntityListener.php @@ -21,7 +21,6 @@ namespace Chill\CalendarBundle\Messenger\Doctrine; 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; diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Doctrine/CalendarRangeEntityListener.php b/src/Bundle/ChillCalendarBundle/Messenger/Doctrine/CalendarRangeEntityListener.php index beb46f870..8b875bdcb 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Doctrine/CalendarRangeEntityListener.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Doctrine/CalendarRangeEntityListener.php @@ -21,7 +21,6 @@ namespace Chill\CalendarBundle\Messenger\Doctrine; 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; diff --git a/src/Bundle/ChillCalendarBundle/Messenger/Handler/MSGraphChangeNotificationHandler.php b/src/Bundle/ChillCalendarBundle/Messenger/Handler/MSGraphChangeNotificationHandler.php index f96d3d14c..7a67bee61 100644 --- a/src/Bundle/ChillCalendarBundle/Messenger/Handler/MSGraphChangeNotificationHandler.php +++ b/src/Bundle/ChillCalendarBundle/Messenger/Handler/MSGraphChangeNotificationHandler.php @@ -43,7 +43,7 @@ class MSGraphChangeNotificationHandler implements MessageHandlerInterface $user = $this->userRepository->find($changeNotificationMessage->getUserId()); if (null === $user) { - $this->logger->warning(self::class . ' notification concern non-existent user, skipping'); + $this->logger->warning(self::class.' notification concern non-existent user, skipping'); return; } @@ -52,7 +52,7 @@ class MSGraphChangeNotificationHandler implements MessageHandlerInterface $secret = $this->mapCalendarToUser->getSubscriptionSecret($user); if ($secret !== ($notification['clientState'] ?? -1)) { - $this->logger->warning(self::class . ' could not validate secret, skipping'); + $this->logger->warning(self::class.' could not validate secret, skipping'); continue; } @@ -67,7 +67,7 @@ class MSGraphChangeNotificationHandler implements MessageHandlerInterface $this->calendarSyncer->handleCalendarSync($calendar, $notification, $user); $this->em->flush(); } else { - $this->logger->info(self::class . ' id not found in any calendar nor calendar range'); + $this->logger->info(self::class.' id not found in any calendar nor calendar range'); } } diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/EventsOnUserSubscriptionCreator.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/EventsOnUserSubscriptionCreator.php index d86b61c6d..080140d86 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/EventsOnUserSubscriptionCreator.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/EventsOnUserSubscriptionCreator.php @@ -19,8 +19,6 @@ declare(strict_types=1); namespace Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph; use Chill\MainBundle\Entity\User; -use DateTimeImmutable; -use LogicException; use Psr\Log\LoggerInterface; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface; @@ -33,18 +31,18 @@ class EventsOnUserSubscriptionCreator public function __construct(private readonly LoggerInterface $logger, private readonly MachineHttpClient $machineHttpClient, private readonly MapCalendarToUser $mapCalendarToUser, private readonly UrlGeneratorInterface $urlGenerator) {} /** + * @return array{secret: string, id: string, expiration: int} + * * @throws ClientExceptionInterface * @throws \Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface * @throws \Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface * @throws \Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface - * - * @return array */ - public function createSubscriptionForUser(User $user, DateTimeImmutable $expiration): array + public function createSubscriptionForUser(User $user, \DateTimeImmutable $expiration): array { if (null === $userId = $this->mapCalendarToUser->getUserId($user)) { - throw new LogicException('no user id'); + throw new \LogicException('no user id'); } $subscription = [ @@ -56,7 +54,7 @@ class EventsOnUserSubscriptionCreator ), 'resource' => "/users/{$userId}/calendar/events", 'clientState' => $secret = base64_encode(openssl_random_pseudo_bytes(92, $cstrong)), - 'expirationDateTime' => $expiration->format(DateTimeImmutable::ATOM), + 'expirationDateTime' => $expiration->format(\DateTimeImmutable::ATOM), ]; try { @@ -79,26 +77,26 @@ class EventsOnUserSubscriptionCreator } /** + * @return array{secret: string, id: string, expiration: int} + * * @throws ClientExceptionInterface * @throws \Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface * @throws \Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface * @throws \Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface - * - * @return array */ - public function renewSubscriptionForUser(User $user, DateTimeImmutable $expiration): array + public function renewSubscriptionForUser(User $user, \DateTimeImmutable $expiration): array { if (null === $userId = $this->mapCalendarToUser->getUserId($user)) { - throw new LogicException('no user id'); + throw new \LogicException('no user id'); } if (null === $subscriptionId = $this->mapCalendarToUser->getActiveSubscriptionId($user)) { - throw new LogicException('no user id'); + throw new \LogicException('no user id'); } $subscription = [ - 'expirationDateTime' => $expiration->format(DateTimeImmutable::ATOM), + 'expirationDateTime' => $expiration->format(\DateTimeImmutable::ATOM), ]; try { diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSUserAbsenceReader.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSUserAbsenceReader.php index 740666cd6..37e3e1996 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSUserAbsenceReader.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSUserAbsenceReader.php @@ -13,7 +13,6 @@ namespace Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph; use Chill\CalendarBundle\Exception\UserAbsenceSyncException; use Chill\MainBundle\Entity\User; -use Psr\Log\LoggerInterface; use Symfony\Component\Clock\ClockInterface; use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface; use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface; @@ -43,25 +42,24 @@ final readonly class MSUserAbsenceReader implements MSUserAbsenceReaderInterface try { $automaticRepliesSettings = $this->machineHttpClient - ->request('GET', 'users/' . $id . '/mailboxSettings/automaticRepliesSetting') + ->request('GET', 'users/'.$id.'/mailboxSettings/automaticRepliesSetting') ->toArray(true); } catch (ClientExceptionInterface|DecodingExceptionInterface|RedirectionExceptionInterface|TransportExceptionInterface $e) { - throw new UserAbsenceSyncException("Error receiving response for mailboxSettings", 0, $e); + throw new UserAbsenceSyncException('Error receiving response for mailboxSettings', 0, $e); } catch (ServerExceptionInterface $e) { - throw new UserAbsenceSyncException("Server error receiving response for mailboxSettings", 0, $e); + throw new UserAbsenceSyncException('Server error receiving response for mailboxSettings', 0, $e); } - if (!array_key_exists("status", $automaticRepliesSettings)) { - throw new \LogicException("no key \"status\" on automatic replies settings: " . json_encode($automaticRepliesSettings, JSON_THROW_ON_ERROR)); + if (!array_key_exists('status', $automaticRepliesSettings)) { + throw new \LogicException('no key "status" on automatic replies settings: '.json_encode($automaticRepliesSettings, JSON_THROW_ON_ERROR)); } return match ($automaticRepliesSettings['status']) { 'disabled' => false, 'alwaysEnabled' => true, - 'scheduled' => - RemoteEventConverter::convertStringDateWithoutTimezone($automaticRepliesSettings['scheduledStartDateTime']['dateTime']) < $this->clock->now() + 'scheduled' => RemoteEventConverter::convertStringDateWithoutTimezone($automaticRepliesSettings['scheduledStartDateTime']['dateTime']) < $this->clock->now() && RemoteEventConverter::convertStringDateWithoutTimezone($automaticRepliesSettings['scheduledEndDateTime']['dateTime']) > $this->clock->now(), - default => throw new UserAbsenceSyncException("this status is not documented by Microsoft") + default => throw new UserAbsenceSyncException('this status is not documented by Microsoft') }; } } diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSUserAbsenceSync.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSUserAbsenceSync.php index a54fa217f..318580ffc 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSUserAbsenceSync.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSUserAbsenceSync.php @@ -36,13 +36,13 @@ readonly class MSUserAbsenceSync return; } - $this->logger->info("will change user absence", ['userId' => $user->getId()]); + $this->logger->info('will change user absence', ['userId' => $user->getId()]); if ($absence) { - $this->logger->debug("make user absent", ['userId' => $user->getId()]); + $this->logger->debug('make user absent', ['userId' => $user->getId()]); $user->setAbsenceStart($this->clock->now()); } else { - $this->logger->debug("make user present", ['userId' => $user->getId()]); + $this->logger->debug('make user present', ['userId' => $user->getId()]); $user->setAbsenceStart(null); } } diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MachineHttpClient.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MachineHttpClient.php index b7b9b4e73..ce490ce3f 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MachineHttpClient.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MachineHttpClient.php @@ -19,7 +19,6 @@ declare(strict_types=1); namespace Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph; use League\OAuth2\Client\Tool\BearerAuthorizationTrait; -use LogicException; use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\HttpClient\ResponseInterface; use Symfony\Contracts\HttpClient\ResponseStreamInterface; @@ -30,17 +29,14 @@ class MachineHttpClient implements HttpClientInterface private readonly HttpClientInterface $decoratedClient; - /** - * @param HttpClientInterface $decoratedClient - */ - public function __construct(private readonly MachineTokenStorage $machineTokenStorage, ?HttpClientInterface $decoratedClient = null) + public function __construct(private readonly MachineTokenStorage $machineTokenStorage, HttpClientInterface $decoratedClient = null) { $this->decoratedClient = $decoratedClient ?? \Symfony\Component\HttpClient\HttpClient::create(); } /** * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface - * @throws LogicException if method is not supported + * @throws \LogicException if method is not supported */ public function request(string $method, string $url, array $options = []): ResponseInterface { @@ -66,13 +62,13 @@ class MachineHttpClient implements HttpClientInterface break; default: - throw new LogicException("Method not supported: {$method}"); + throw new \LogicException("Method not supported: {$method}"); } return $this->decoratedClient->request($method, $url, $options); } - public function stream($responses, ?float $timeout = null): ResponseStreamInterface + public function stream($responses, float $timeout = null): ResponseStreamInterface { return $this->decoratedClient->stream($responses, $timeout); } diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MapCalendarToUser.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MapCalendarToUser.php index ff6d63c10..4b214e6d0 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MapCalendarToUser.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MapCalendarToUser.php @@ -19,12 +19,9 @@ declare(strict_types=1); namespace Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph; use Chill\MainBundle\Entity\User; -use DateTimeImmutable; -use LogicException; use Psr\Log\LoggerInterface; use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; -use function array_key_exists; /** * Write metadata to user, which allow to find his default calendar. @@ -43,12 +40,12 @@ class MapCalendarToUser public function getActiveSubscriptionId(User $user): string { - if (!array_key_exists(self::METADATA_KEY, $user->getAttributes())) { - throw new LogicException('do not contains msgraph metadata'); + if (!\array_key_exists(self::METADATA_KEY, $user->getAttributes())) { + throw new \LogicException('do not contains msgraph metadata'); } - if (!array_key_exists(self::ID_SUBSCRIPTION_EVENT, $user->getAttributes()[self::METADATA_KEY])) { - throw new LogicException('do not contains metadata for subscription id'); + if (!\array_key_exists(self::ID_SUBSCRIPTION_EVENT, $user->getAttributes()[self::METADATA_KEY])) { + throw new \LogicException('do not contains metadata for subscription id'); } return $user->getAttributes()[self::METADATA_KEY][self::ID_SUBSCRIPTION_EVENT]; @@ -83,12 +80,12 @@ class MapCalendarToUser public function getSubscriptionSecret(User $user): string { - if (!array_key_exists(self::METADATA_KEY, $user->getAttributes())) { - throw new LogicException('do not contains msgraph metadata'); + if (!\array_key_exists(self::METADATA_KEY, $user->getAttributes())) { + throw new \LogicException('do not contains msgraph metadata'); } - if (!array_key_exists(self::SECRET_SUBSCRIPTION_EVENT, $user->getAttributes()[self::METADATA_KEY])) { - throw new LogicException('do not contains secret in msgraph'); + if (!\array_key_exists(self::SECRET_SUBSCRIPTION_EVENT, $user->getAttributes()[self::METADATA_KEY])) { + throw new \LogicException('do not contains secret in msgraph'); } return $user->getAttributes()[self::METADATA_KEY][self::SECRET_SUBSCRIPTION_EVENT]; @@ -114,25 +111,25 @@ class MapCalendarToUser public function hasActiveSubscription(User $user): bool { - if (!array_key_exists(self::METADATA_KEY, $user->getAttributes())) { + if (!\array_key_exists(self::METADATA_KEY, $user->getAttributes())) { return false; } - if (!array_key_exists(self::EXPIRATION_SUBSCRIPTION_EVENT, $user->getAttributes()[self::METADATA_KEY])) { + if (!\array_key_exists(self::EXPIRATION_SUBSCRIPTION_EVENT, $user->getAttributes()[self::METADATA_KEY])) { return false; } return $user->getAttributes()[self::METADATA_KEY][self::EXPIRATION_SUBSCRIPTION_EVENT] - >= (new DateTimeImmutable('now'))->getTimestamp(); + >= (new \DateTimeImmutable('now'))->getTimestamp(); } public function hasSubscriptionSecret(User $user): bool { - if (!array_key_exists(self::METADATA_KEY, $user->getAttributes())) { + if (!\array_key_exists(self::METADATA_KEY, $user->getAttributes())) { return false; } - return array_key_exists(self::SECRET_SUBSCRIPTION_EVENT, $user->getAttributes()[self::METADATA_KEY]); + return \array_key_exists(self::SECRET_SUBSCRIPTION_EVENT, $user->getAttributes()[self::METADATA_KEY]); } public function hasUserId(User $user): bool @@ -141,11 +138,11 @@ class MapCalendarToUser return false; } - if (!array_key_exists(self::METADATA_KEY, $user->getAttributes())) { + if (!\array_key_exists(self::METADATA_KEY, $user->getAttributes())) { return false; } - return array_key_exists('id', $user->getAttributes()[self::METADATA_KEY]); + return \array_key_exists('id', $user->getAttributes()[self::METADATA_KEY]); } public function writeMetadata(User $user): User @@ -179,8 +176,8 @@ class MapCalendarToUser public function writeSubscriptionMetadata( User $user, int $expiration, - ?string $id = null, - ?string $secret = null + string $id = null, + string $secret = null ): void { $user->setAttributeByDomain(self::METADATA_KEY, self::EXPIRATION_SUBSCRIPTION_EVENT, $expiration); diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/OnBehalfOfUserHttpClient.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/OnBehalfOfUserHttpClient.php index 32f0e5dec..d969a56b6 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/OnBehalfOfUserHttpClient.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/OnBehalfOfUserHttpClient.php @@ -19,7 +19,6 @@ declare(strict_types=1); namespace Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph; use League\OAuth2\Client\Tool\BearerAuthorizationTrait; -use LogicException; use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\HttpClient\ResponseInterface; use Symfony\Contracts\HttpClient\ResponseStreamInterface; @@ -30,10 +29,7 @@ class OnBehalfOfUserHttpClient private readonly HttpClientInterface $decoratedClient; - /** - * @param HttpClientInterface $decoratedClient - */ - public function __construct(private readonly OnBehalfOfUserTokenStorage $tokenStorage, ?HttpClientInterface $decoratedClient = null) + public function __construct(private readonly OnBehalfOfUserTokenStorage $tokenStorage, HttpClientInterface $decoratedClient = null) { $this->decoratedClient = $decoratedClient ?? \Symfony\Component\HttpClient\HttpClient::create(); } @@ -61,13 +57,13 @@ class OnBehalfOfUserHttpClient break; default: - throw new LogicException("Method not supported: {$method}"); + throw new \LogicException("Method not supported: {$method}"); } return $this->decoratedClient->request($method, $url, $options); } - public function stream($responses, ?float $timeout = null): ResponseStreamInterface + public function stream($responses, float $timeout = null): ResponseStreamInterface { return $this->decoratedClient->stream($responses, $timeout); } diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/OnBehalfOfUserTokenStorage.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/OnBehalfOfUserTokenStorage.php index a3a8971bc..d8fff109b 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/OnBehalfOfUserTokenStorage.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/OnBehalfOfUserTokenStorage.php @@ -18,7 +18,6 @@ declare(strict_types=1); namespace Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph; -use LogicException; use Symfony\Component\HttpFoundation\Session\SessionInterface; use TheNetworg\OAuth2\Client\Provider\Azure; use TheNetworg\OAuth2\Client\Token\AccessToken; @@ -38,7 +37,7 @@ class OnBehalfOfUserTokenStorage $token = $this->session->get(self::MS_GRAPH_ACCESS_TOKEN, null); if (null === $token) { - throw new LogicException('unexisting token'); + throw new \LogicException('unexisting token'); } if ($token->hasExpired()) { diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteEventConverter.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteEventConverter.php index 5b52a6ecd..94b488ddd 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteEventConverter.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteEventConverter.php @@ -24,11 +24,7 @@ use Chill\CalendarBundle\Entity\Invite; use Chill\CalendarBundle\RemoteCalendar\Model\RemoteEvent; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Templating\Entity\PersonRenderInterface; -use DateTimeImmutable; -use DateTimeZone; use Psr\Log\LoggerInterface; -use RuntimeException; -use Symfony\Component\Templating\EngineInterface; use Symfony\Contracts\Translation\TranslatorInterface; /** @@ -52,9 +48,9 @@ class RemoteEventConverter private const REMOTE_DATETIME_WITHOUT_TZ_FORMAT = 'Y-m-d\TH:i:s.u?'; - private readonly DateTimeZone $defaultDateTimeZone; + private readonly \DateTimeZone $defaultDateTimeZone; - private readonly DateTimeZone $remoteDateTimeZone; + private readonly \DateTimeZone $remoteDateTimeZone; public function __construct( private readonly \Twig\Environment $engine, @@ -63,7 +59,7 @@ class RemoteEventConverter private readonly PersonRenderInterface $personRender, private readonly TranslatorInterface $translator ) { - $this->defaultDateTimeZone = (new DateTimeImmutable())->getTimezone(); + $this->defaultDateTimeZone = (new \DateTimeImmutable())->getTimezone(); $this->remoteDateTimeZone = self::getRemoteTimeZone(); } @@ -103,7 +99,7 @@ class RemoteEventConverter { $result = array_merge( [ - 'subject' => '[Chill] ' . + 'subject' => '[Chill] '. implode( ', ', $calendar->getPersons()->map(fn (Person $p) => $this->personRender->renderString($p, []))->toArray() @@ -119,7 +115,7 @@ class RemoteEventConverter 'timeZone' => 'UTC', ], 'allowNewTimeProposals' => false, - 'transactionId' => 'calendar_' . $calendar->getId(), + 'transactionId' => 'calendar_'.$calendar->getId(), 'body' => [ 'contentType' => 'text', 'content' => $this->engine->render( @@ -152,45 +148,45 @@ class RemoteEventConverter public function convertAvailabilityToRemoteEvent(array $event): RemoteEvent { $startDate = - DateTimeImmutable::createFromFormat(self::REMOTE_DATE_FORMAT, $event['start']['dateTime'], $this->remoteDateTimeZone) + \DateTimeImmutable::createFromFormat(self::REMOTE_DATE_FORMAT, $event['start']['dateTime'], $this->remoteDateTimeZone) ->setTimezone($this->defaultDateTimeZone); $endDate = - DateTimeImmutable::createFromFormat(self::REMOTE_DATE_FORMAT, $event['end']['dateTime'], $this->remoteDateTimeZone) + \DateTimeImmutable::createFromFormat(self::REMOTE_DATE_FORMAT, $event['end']['dateTime'], $this->remoteDateTimeZone) ->setTimezone($this->defaultDateTimeZone); return new RemoteEvent( uniqid('generated_'), - $this->translator->trans('remote_ms_graph.freebusy_statuses.' . $event['status']), + $this->translator->trans('remote_ms_graph.freebusy_statuses.'.$event['status']), '', $startDate, $endDate ); } - public static function convertStringDateWithoutTimezone(string $date): DateTimeImmutable + public static function convertStringDateWithoutTimezone(string $date): \DateTimeImmutable { - $d = DateTimeImmutable::createFromFormat( + $d = \DateTimeImmutable::createFromFormat( self::REMOTE_DATETIME_WITHOUT_TZ_FORMAT, $date, self::getRemoteTimeZone() ); if (false === $d) { - throw new RuntimeException("could not convert string date to datetime: {$date}"); + throw new \RuntimeException("could not convert string date to datetime: {$date}"); } - return $d->setTimezone((new DateTimeImmutable())->getTimezone()); + return $d->setTimezone((new \DateTimeImmutable())->getTimezone()); } - public static function convertStringDateWithTimezone(string $date): DateTimeImmutable + public static function convertStringDateWithTimezone(string $date): \DateTimeImmutable { - $d = DateTimeImmutable::createFromFormat(self::REMOTE_DATETIMEZONE_FORMAT, $date); + $d = \DateTimeImmutable::createFromFormat(self::REMOTE_DATETIMEZONE_FORMAT, $date); if (false === $d) { - throw new RuntimeException("could not convert string date to datetime: {$date}"); + throw new \RuntimeException("could not convert string date to datetime: {$date}"); } - $d->setTimezone((new DateTimeImmutable())->getTimezone()); + $d->setTimezone((new \DateTimeImmutable())->getTimezone()); return $d; } @@ -198,10 +194,10 @@ class RemoteEventConverter public function convertToRemote(array $event): RemoteEvent { $startDate = - DateTimeImmutable::createFromFormat(self::REMOTE_DATE_FORMAT, $event['start']['dateTime'], $this->remoteDateTimeZone) + \DateTimeImmutable::createFromFormat(self::REMOTE_DATE_FORMAT, $event['start']['dateTime'], $this->remoteDateTimeZone) ->setTimezone($this->defaultDateTimeZone); $endDate = - DateTimeImmutable::createFromFormat(self::REMOTE_DATE_FORMAT, $event['end']['dateTime'], $this->remoteDateTimeZone) + \DateTimeImmutable::createFromFormat(self::REMOTE_DATE_FORMAT, $event['end']['dateTime'], $this->remoteDateTimeZone) ->setTimezone($this->defaultDateTimeZone); return new RemoteEvent( @@ -214,26 +210,22 @@ class RemoteEventConverter ); } - public function getLastModifiedDate(array $event): DateTimeImmutable + public function getLastModifiedDate(array $event): \DateTimeImmutable { - $date = DateTimeImmutable::createFromFormat(self::REMOTE_DATETIMEZONE_FORMAT, $event['lastModifiedDateTime']); + $date = \DateTimeImmutable::createFromFormat(self::REMOTE_DATETIMEZONE_FORMAT, $event['lastModifiedDateTime']); if (false === $date) { - $date = DateTimeImmutable::createFromFormat(self::REMOTE_DATETIMEZONE_FORMAT_ALT, $event['lastModifiedDateTime']); + $date = \DateTimeImmutable::createFromFormat(self::REMOTE_DATETIMEZONE_FORMAT_ALT, $event['lastModifiedDateTime']); } if (false === $date) { - $this->logger->error(self::class . ' Could not convert lastModifiedDate', [ + $this->logger->error(self::class.' Could not convert lastModifiedDate', [ 'actual' => $event['lastModifiedDateTime'], 'format' => self::REMOTE_DATETIMEZONE_FORMAT, 'format_alt' => self::REMOTE_DATETIMEZONE_FORMAT_ALT, ]); - throw new RuntimeException(sprintf( - 'could not convert lastModifiedDate: %s, expected format: %s', - $event['lastModifiedDateTime'], - self::REMOTE_DATETIMEZONE_FORMAT . ' and ' . self::REMOTE_DATETIMEZONE_FORMAT_ALT - )); + throw new \RuntimeException(sprintf('could not convert lastModifiedDate: %s, expected format: %s', $event['lastModifiedDateTime'], self::REMOTE_DATETIMEZONE_FORMAT.' and '.self::REMOTE_DATETIMEZONE_FORMAT_ALT)); } return $date; @@ -247,9 +239,9 @@ class RemoteEventConverter return 'Y-m-d\TH:i:s'; } - public static function getRemoteTimeZone(): DateTimeZone + public static function getRemoteTimeZone(): \DateTimeZone { - return new DateTimeZone('UTC'); + return new \DateTimeZone('UTC'); } private function buildInviteToAttendee(Invite $invite): array diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarRangeSyncer.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarRangeSyncer.php index 847052a26..1dffe198c 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarRangeSyncer.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarRangeSyncer.php @@ -24,7 +24,6 @@ use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\RemoteEventConverter; use Chill\MainBundle\Entity\User; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; -use RuntimeException; use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -45,7 +44,7 @@ class CalendarRangeSyncer } $calendarRange->preventEnqueueChanges = true; - $this->logger->info(self::class . ' remove a calendar range because deleted on remote calendar'); + $this->logger->info(self::class.' remove a calendar range because deleted on remote calendar'); $this->em->remove($calendarRange); break; @@ -57,7 +56,7 @@ class CalendarRangeSyncer $notification['resource'] )->toArray(); } catch (ClientExceptionInterface $clientException) { - $this->logger->warning(self::class . ' could not retrieve event from ms graph. Already deleted ?', [ + $this->logger->warning(self::class.' could not retrieve event from ms graph. Already deleted ?', [ 'calendarRangeId' => $calendarRange->getId(), 'remoteEventId' => $notification['resource'], ]); @@ -68,7 +67,7 @@ class CalendarRangeSyncer $lastModified = RemoteEventConverter::convertStringDateWithTimezone($new['lastModifiedDateTime']); if ($calendarRange->getRemoteAttributes()['lastModifiedDateTime'] === $lastModified->getTimestamp()) { - $this->logger->info(self::class . ' change key is equals. Source is probably a local update', [ + $this->logger->info(self::class.' change key is equals. Source is probably a local update', [ 'calendarRangeId' => $calendarRange->getId(), 'remoteEventId' => $notification['resource'], ]); @@ -90,7 +89,7 @@ class CalendarRangeSyncer break; default: - throw new RuntimeException('This changeType is not suppored: ' . $notification['changeType']); + throw new \RuntimeException('This changeType is not suppored: '.$notification['changeType']); } } } diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarSyncer.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarSyncer.php index a1362a2ce..9b4daf626 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarSyncer.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarSyncer.php @@ -23,12 +23,9 @@ use Chill\CalendarBundle\Entity\Invite; use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\RemoteEventConverter; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Repository\UserRepositoryInterface; -use LogicException; use Psr\Log\LoggerInterface; -use RuntimeException; use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; -use function in_array; class CalendarSyncer { @@ -39,7 +36,7 @@ class CalendarSyncer match ($notification['changeType']) { 'deleted' => $this->handleDeleteCalendar($calendar, $notification, $user), 'updated' => $this->handleUpdateCalendar($calendar, $notification, $user), - default => throw new RuntimeException('this change type is not supported: ' . $notification['changeType']), + default => throw new \RuntimeException('this change type is not supported: '.$notification['changeType']), }; } @@ -59,7 +56,7 @@ class CalendarSyncer $notification['resource'] )->toArray(); } catch (ClientExceptionInterface $clientException) { - $this->logger->warning(self::class . ' could not retrieve event from ms graph. Already deleted ?', [ + $this->logger->warning(self::class.' could not retrieve event from ms graph. Already deleted ?', [ 'calendarId' => $calendar->getId(), 'remoteEventId' => $notification['resource'], ]); @@ -76,7 +73,7 @@ class CalendarSyncer ); if ($calendar->getRemoteAttributes()['lastModifiedDateTime'] === $lastModified->getTimestamp()) { - $this->logger->info(self::class . ' change key is equals. Source is probably a local update', [ + $this->logger->info(self::class.' change key is equals. Source is probably a local update', [ 'calendarRangeId' => $calendar->getId(), 'remoteEventId' => $notification['resource'], ]); @@ -135,12 +132,12 @@ class CalendarSyncer 'tentativelyAccepted' => $invite->setStatus(Invite::TENTATIVELY_ACCEPTED), 'accepted' => $invite->setStatus(Invite::ACCEPTED), 'declined' => $invite->setStatus(Invite::DECLINED), - default => throw new LogicException('should not happens, not implemented: ' . $status), + default => throw new \LogicException('should not happens, not implemented: '.$status), }; } foreach ($calendar->getUsers() as $user) { - if (!in_array(strtolower($user->getEmailCanonical()), $emails, true)) { + if (!\in_array(strtolower($user->getEmailCanonical()), $emails, true)) { $calendar->removeUser($user); } } diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraphRemoteCalendarConnector.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraphRemoteCalendarConnector.php index fe8fae8e6..768ad2a44 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraphRemoteCalendarConnector.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraphRemoteCalendarConnector.php @@ -28,8 +28,6 @@ use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\RemoteEventConverter; use Chill\CalendarBundle\Repository\CalendarRangeRepository; use Chill\CalendarBundle\Repository\CalendarRepository; use Chill\MainBundle\Entity\User; -use DateTimeImmutable; -use Exception; use Psr\Log\LoggerInterface; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Response; @@ -38,8 +36,6 @@ use Symfony\Component\Security\Core\Security; use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\Translation\TranslatorInterface; -use function array_key_exists; -use function count; class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface { @@ -47,7 +43,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface public function __construct(private readonly CalendarRepository $calendarRepository, private readonly CalendarRangeRepository $calendarRangeRepository, private readonly HttpClientInterface $machineHttpClient, private readonly MapCalendarToUser $mapCalendarToUser, private readonly LoggerInterface $logger, private readonly OnBehalfOfUserTokenStorage $tokenStorage, private readonly OnBehalfOfUserHttpClient $userHttpClient, private readonly RemoteEventConverter $remoteEventConverter, private readonly TranslatorInterface $translator, private readonly UrlGeneratorInterface $urlGenerator, private readonly Security $security) {} - public function countEventsForUser(User $user, DateTimeImmutable $startDate, DateTimeImmutable $endDate): int + public function countEventsForUser(User $user, \DateTimeImmutable $startDate, \DateTimeImmutable $endDate): int { $userId = $this->mapCalendarToUser->getUserId($user); @@ -58,7 +54,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface try { $data = $this->userHttpClient->request( 'GET', - 'users/' . $userId . '/calendarView', + 'users/'.$userId.'/calendarView', [ 'query' => [ 'startDateTime' => $startDate->setTimezone(RemoteEventConverter::getRemoteTimeZone())->format(RemoteEventConverter::getRemoteDateTimeSimpleFormat()), @@ -70,7 +66,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface )->toArray(); } catch (ClientExceptionInterface $e) { if (403 === $e->getResponse()->getStatusCode()) { - return count($this->getScheduleTimesForUser($user, $startDate, $endDate)); + return \count($this->getScheduleTimesForUser($user, $startDate, $endDate)); } $this->logger->error('Could not get list of event on MSGraph', [ @@ -107,6 +103,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface $this->logger->debug('mark user ready for msgraph calendar as he does not have any mapping', [ 'userId' => $user->getId(), ]); + return true; } @@ -114,14 +111,14 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface } /** + * @return array|\Chill\CalendarBundle\RemoteCalendar\Model\RemoteEvent[] + * * @throws \Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface * @throws \Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface * @throws \Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface - * - * @return array|\Chill\CalendarBundle\RemoteCalendar\Model\RemoteEvent[] */ - public function listEventsForUser(User $user, DateTimeImmutable $startDate, DateTimeImmutable $endDate, ?int $offset = 0, ?int $limit = 50): array + public function listEventsForUser(User $user, \DateTimeImmutable $startDate, \DateTimeImmutable $endDate, ?int $offset = 0, ?int $limit = 50): array { $userId = $this->mapCalendarToUser->getUserId($user); @@ -132,7 +129,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface try { $bareEvents = $this->userHttpClient->request( 'GET', - 'users/' . $userId . '/calendarView', + 'users/'.$userId.'/calendarView', [ 'query' => [ 'startDateTime' => $startDate->setTimezone(RemoteEventConverter::getRemoteTimeZone())->format(RemoteEventConverter::getRemoteDateTimeSimpleFormat()), @@ -172,7 +169,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface } } - public function removeCalendar(string $remoteId, array $remoteAttributes, User $user, ?CalendarRange $associatedCalendarRange = null): void + public function removeCalendar(string $remoteId, array $remoteAttributes, User $user, CalendarRange $associatedCalendarRange = null): void { if ('' === $remoteId) { return; @@ -222,7 +219,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface $calendar->getRemoteId(), $this->translator->trans('remote_ms_graph.cancel_event_because_main_user_is_%label%', ['%label%' => $calendar->getMainUser()]), $previousMainUser, - 'calendar_' . $calendar->getRemoteId() + 'calendar_'.$calendar->getRemoteId() ); $this->createCalendarOnRemote($calendar); } else { @@ -300,7 +297,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface break; default: - throw new Exception('not supported'); + throw new \Exception('not supported'); } try { @@ -313,7 +310,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface $this->logger->warning('could not update calendar range to remote', [ 'exception' => $e->getTraceAsString(), 'content' => $e->getResponse()->getContent(), - 'calendarRangeId' => 'invite_' . $invite->getId(), + 'calendarRangeId' => 'invite_'.$invite->getId(), ]); throw $e; @@ -355,7 +352,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface 'id' => $id, 'lastModifiedDateTime' => $lastModified, 'changeKey' => $changeKey - ] = $this->createOnRemote($eventData, $calendar->getMainUser(), 'calendar_' . $calendar->getId()); + ] = $this->createOnRemote($eventData, $calendar->getMainUser(), 'calendar_'.$calendar->getId()); if (null === $id) { return; @@ -390,7 +387,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface try { $event = $this->machineHttpClient->request( 'POST', - 'users/' . $userId . '/calendar/events', + 'users/'.$userId.'/calendar/events', [ 'json' => $eventData, ] @@ -434,7 +431,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface ] = $this->createOnRemote( $eventData, $calendarRange->getUser(), - 'calendar_range_' . $calendarRange->getId() + 'calendar_range_'.$calendarRange->getId() ); $calendarRange->setRemoteId($id) @@ -457,7 +454,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface $userId = $this->mapCalendarToUser->getUserId($user); if ('' === $iCalUid = ($event['iCalUId'] ?? '')) { - throw new Exception('no iCalUid for this event'); + throw new \Exception('no iCalUid for this event'); } try { @@ -475,8 +472,8 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface throw $clientException; } - if (1 !== count($events['value'])) { - throw new Exception('multiple events found with same iCalUid'); + if (1 !== \count($events['value'])) { + throw new \Exception('multiple events found with same iCalUid'); } return $events['value'][0]['id']; @@ -487,19 +484,13 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface $userId = $this->mapCalendarToUser->getUserId($user); if (null === $userId) { - throw new Exception( - sprintf( - 'no remote calendar for this user: %s, remoteid: %s', - $user->getId(), - $remoteId - ) - ); + throw new \Exception(sprintf('no remote calendar for this user: %s, remoteid: %s', $user->getId(), $remoteId)); } try { return $this->machineHttpClient->request( 'GET', - 'users/' . $userId . '/calendar/events/' . $remoteId + 'users/'.$userId.'/calendar/events/'.$remoteId )->toArray(); } catch (ClientExceptionInterface $e) { $this->logger->warning('Could not get event from calendar', [ @@ -510,11 +501,11 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface } } - private function getScheduleTimesForUser(User $user, DateTimeImmutable $startDate, DateTimeImmutable $endDate): array + private function getScheduleTimesForUser(User $user, \DateTimeImmutable $startDate, \DateTimeImmutable $endDate): array { $userId = $this->mapCalendarToUser->getUserId($user); - if (array_key_exists($userId, $this->cacheScheduleTimeForUser)) { + if (\array_key_exists($userId, $this->cacheScheduleTimeForUser)) { return $this->cacheScheduleTimeForUser[$userId]; } @@ -529,17 +520,17 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface $body = [ 'schedules' => [$user->getEmailCanonical()], 'startTime' => [ - 'dateTime' => ($startDate->setTimezone(RemoteEventConverter::getRemoteTimeZone())->format(RemoteEventConverter::getRemoteDateTimeSimpleFormat())), + 'dateTime' => $startDate->setTimezone(RemoteEventConverter::getRemoteTimeZone())->format(RemoteEventConverter::getRemoteDateTimeSimpleFormat()), 'timeZone' => 'UTC', ], 'endTime' => [ - 'dateTime' => ($endDate->setTimezone(RemoteEventConverter::getRemoteTimeZone())->format(RemoteEventConverter::getRemoteDateTimeSimpleFormat())), + 'dateTime' => $endDate->setTimezone(RemoteEventConverter::getRemoteTimeZone())->format(RemoteEventConverter::getRemoteDateTimeSimpleFormat()), 'timeZone' => 'UTC', ], ]; try { - $response = $this->userHttpClient->request('POST', 'users/' . $userId . '/calendar/getSchedule', [ + $response = $this->userHttpClient->request('POST', 'users/'.$userId.'/calendar/getSchedule', [ 'json' => $body, ])->toArray(); } catch (ClientExceptionInterface $e) { @@ -564,7 +555,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface $eventDatas = []; $eventDatas[] = $this->remoteEventConverter->calendarToEvent($calendar); - if (0 < count($newInvites)) { + if (0 < \count($newInvites)) { // it seems that invitaiton are always send, even if attendee changes are mixed with other datas // $eventDatas[] = $this->remoteEventConverter->calendarToEventAttendeesOnly($calendar); } @@ -578,7 +569,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface $calendar->getRemoteId(), $eventData, $calendar->getMainUser(), - 'calendar_' . $calendar->getId() + 'calendar_'.$calendar->getId() ); $calendar->addRemoteAttributes([ @@ -609,7 +600,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface try { $event = $this->machineHttpClient->request( 'PATCH', - 'users/' . $userId . '/calendar/events/' . $remoteId, + 'users/'.$userId.'/calendar/events/'.$remoteId, [ 'json' => $eventData, ] @@ -637,7 +628,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface try { $this->machineHttpClient->request( 'DELETE', - 'users/' . $userId . '/calendar/events/' . $remoteId + 'users/'.$userId.'/calendar/events/'.$remoteId ); } catch (ClientExceptionInterface) { $this->logger->warning('could not remove event from calendar', [ @@ -664,7 +655,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface try { $event = $this->machineHttpClient->request( 'GET', - 'users/' . $userId . '/calendar/events/' . $calendarRange->getRemoteId() + 'users/'.$userId.'/calendar/events/'.$calendarRange->getRemoteId() )->toArray(); } catch (ClientExceptionInterface $e) { $this->logger->warning('Could not get event from calendar', [ @@ -691,7 +682,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface try { $event = $this->machineHttpClient->request( 'PATCH', - 'users/' . $userId . '/calendar/events/' . $calendarRange->getRemoteId(), + 'users/'.$userId.'/calendar/events/'.$calendarRange->getRemoteId(), [ 'json' => $eventData, ] diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/NullRemoteCalendarConnector.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/NullRemoteCalendarConnector.php index c8fb569e8..b4e2a5d3a 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/NullRemoteCalendarConnector.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/NullRemoteCalendarConnector.php @@ -22,20 +22,18 @@ use Chill\CalendarBundle\Entity\Calendar; use Chill\CalendarBundle\Entity\CalendarRange; use Chill\CalendarBundle\Entity\Invite; use Chill\MainBundle\Entity\User; -use DateTimeImmutable; -use LogicException; use Symfony\Component\HttpFoundation\Response; class NullRemoteCalendarConnector implements RemoteCalendarConnectorInterface { - public function countEventsForUser(User $user, DateTimeImmutable $startDate, DateTimeImmutable $endDate): int + public function countEventsForUser(User $user, \DateTimeImmutable $startDate, \DateTimeImmutable $endDate): int { return 0; } public function getMakeReadyResponse(string $returnPath): Response { - throw new LogicException('As this connector is always ready, this method should not be called'); + throw new \LogicException('As this connector is always ready, this method should not be called'); } public function isReady(): bool @@ -43,12 +41,12 @@ class NullRemoteCalendarConnector implements RemoteCalendarConnectorInterface return true; } - public function listEventsForUser(User $user, DateTimeImmutable $startDate, DateTimeImmutable $endDate, ?int $offset = 0, ?int $limit = 50): array + public function listEventsForUser(User $user, \DateTimeImmutable $startDate, \DateTimeImmutable $endDate, ?int $offset = 0, ?int $limit = 50): array { return []; } - public function removeCalendar(string $remoteId, array $remoteAttributes, User $user, ?CalendarRange $associatedCalendarRange = null): void {} + public function removeCalendar(string $remoteId, array $remoteAttributes, User $user, CalendarRange $associatedCalendarRange = null): void {} public function removeCalendarRange(string $remoteId, array $remoteAttributes, User $user): void {} diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/RemoteCalendarConnectorInterface.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/RemoteCalendarConnectorInterface.php index e3ef89ca4..53d2c8602 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/RemoteCalendarConnectorInterface.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/RemoteCalendarConnectorInterface.php @@ -23,12 +23,11 @@ use Chill\CalendarBundle\Entity\CalendarRange; use Chill\CalendarBundle\Entity\Invite; use Chill\CalendarBundle\RemoteCalendar\Model\RemoteEvent; use Chill\MainBundle\Entity\User; -use DateTimeImmutable; use Symfony\Component\HttpFoundation\Response; interface RemoteCalendarConnectorInterface { - public function countEventsForUser(User $user, DateTimeImmutable $startDate, DateTimeImmutable $endDate): int; + public function countEventsForUser(User $user, \DateTimeImmutable $startDate, \DateTimeImmutable $endDate): int; /** * Return a response, more probably a RedirectResponse, where the user @@ -46,9 +45,9 @@ interface RemoteCalendarConnectorInterface /** * @return array|RemoteEvent[] */ - public function listEventsForUser(User $user, DateTimeImmutable $startDate, DateTimeImmutable $endDate, ?int $offset = 0, ?int $limit = 50): array; + public function listEventsForUser(User $user, \DateTimeImmutable $startDate, \DateTimeImmutable $endDate, ?int $offset = 0, ?int $limit = 50): array; - public function removeCalendar(string $remoteId, array $remoteAttributes, User $user, ?CalendarRange $associatedCalendarRange = null): void; + public function removeCalendar(string $remoteId, array $remoteAttributes, User $user, CalendarRange $associatedCalendarRange = null): void; public function removeCalendarRange(string $remoteId, array $remoteAttributes, User $user): void; diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/DependencyInjection/RemoteCalendarCompilerPass.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/DependencyInjection/RemoteCalendarCompilerPass.php index 6a986c9db..c52fc2866 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/DependencyInjection/RemoteCalendarCompilerPass.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/DependencyInjection/RemoteCalendarCompilerPass.php @@ -28,7 +28,6 @@ use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\MSUserAbsenceSync; use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraphRemoteCalendarConnector; use Chill\CalendarBundle\RemoteCalendar\Connector\NullRemoteCalendarConnector; use Chill\CalendarBundle\RemoteCalendar\Connector\RemoteCalendarConnectorInterface; -use RuntimeException; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -43,7 +42,7 @@ class RemoteCalendarCompilerPass implements CompilerPassInterface if (true === $config['remote_calendars_sync']['microsoft_graph']['enabled']) { $connector = MSGraphRemoteCalendarConnector::class; - $container->setAlias(HttpClientInterface::class . ' $machineHttpClient', MachineHttpClient::class); + $container->setAlias(HttpClientInterface::class.' $machineHttpClient', MachineHttpClient::class); } else { $connector = NullRemoteCalendarConnector::class; // remove services which cannot be loaded diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Model/RemoteEvent.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Model/RemoteEvent.php index d0a4bb566..40d1d1435 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Model/RemoteEvent.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Model/RemoteEvent.php @@ -18,7 +18,6 @@ declare(strict_types=1); namespace Chill\CalendarBundle\RemoteCalendar\Model; -use DateTimeImmutable; use Symfony\Component\Serializer\Annotation as Serializer; class RemoteEvent @@ -36,11 +35,11 @@ class RemoteEvent /** * @Serializer\Groups({"read"}) */ - public DateTimeImmutable $startDate, + public \DateTimeImmutable $startDate, /** * @Serializer\Groups({"read"}) */ - public DateTimeImmutable $endDate, + public \DateTimeImmutable $endDate, /** * @Serializer\Groups({"read"}) */ diff --git a/src/Bundle/ChillCalendarBundle/Repository/CalendarACLAwareRepository.php b/src/Bundle/ChillCalendarBundle/Repository/CalendarACLAwareRepository.php index b120fb4d0..8f490f376 100644 --- a/src/Bundle/ChillCalendarBundle/Repository/CalendarACLAwareRepository.php +++ b/src/Bundle/ChillCalendarBundle/Repository/CalendarACLAwareRepository.php @@ -23,7 +23,6 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Repository\AccompanyingPeriodACLAwareRepositoryInterface; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; -use DateTimeImmutable; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\QueryBuilder; @@ -31,7 +30,7 @@ class CalendarACLAwareRepository implements CalendarACLAwareRepositoryInterface { public function __construct(private readonly AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository, private readonly EntityManagerInterface $em) {} - public function buildQueryByAccompanyingPeriod(AccompanyingPeriod $period, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate): QueryBuilder + public function buildQueryByAccompanyingPeriod(AccompanyingPeriod $period, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate): QueryBuilder { $qb = $this->em->createQueryBuilder(); $qb->from(Calendar::class, 'c'); @@ -54,7 +53,7 @@ class CalendarACLAwareRepository implements CalendarACLAwareRepositoryInterface return $qb; } - public function buildQueryByAccompanyingPeriodIgnoredByDates(AccompanyingPeriod $period, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate): QueryBuilder + public function buildQueryByAccompanyingPeriodIgnoredByDates(AccompanyingPeriod $period, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate): QueryBuilder { $qb = $this->em->createQueryBuilder(); $qb->from(Calendar::class, 'c'); @@ -80,7 +79,7 @@ class CalendarACLAwareRepository implements CalendarACLAwareRepositoryInterface /** * Base implementation. The list of allowed accompanying period is retrieved "manually" from @see{AccompanyingPeriodACLAwareRepository}. */ - public function buildQueryByPerson(Person $person, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate): QueryBuilder + public function buildQueryByPerson(Person $person, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate): QueryBuilder { $qb = $this->em->createQueryBuilder() ->from(Calendar::class, 'c'); @@ -104,7 +103,7 @@ class CalendarACLAwareRepository implements CalendarACLAwareRepositoryInterface /** * Base implementation. The list of allowed accompanying period is retrieved "manually" from @see{AccompanyingPeriodACLAwareRepository}. */ - public function buildQueryByPersonIgnoredByDates(Person $person, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate): QueryBuilder + public function buildQueryByPersonIgnoredByDates(Person $person, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate): QueryBuilder { $qb = $this->em->createQueryBuilder() ->from(Calendar::class, 'c'); @@ -125,14 +124,14 @@ class CalendarACLAwareRepository implements CalendarACLAwareRepositoryInterface return $qb; } - public function countByAccompanyingPeriod(AccompanyingPeriod $period, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate): int + public function countByAccompanyingPeriod(AccompanyingPeriod $period, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate): int { $qb = $this->buildQueryByAccompanyingPeriod($period, $startDate, $endDate)->select('count(c)'); return $qb->getQuery()->getSingleScalarResult(); } - public function countByPerson(Person $person, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate): int + public function countByPerson(Person $person, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate): int { return $this->buildQueryByPerson($person, $startDate, $endDate) ->select('COUNT(c)') @@ -140,14 +139,14 @@ class CalendarACLAwareRepository implements CalendarACLAwareRepositoryInterface ->getSingleScalarResult(); } - public function countIgnoredByAccompanyingPeriod(AccompanyingPeriod $period, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate): int + public function countIgnoredByAccompanyingPeriod(AccompanyingPeriod $period, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate): int { $qb = $this->buildQueryByAccompanyingPeriodIgnoredByDates($period, $startDate, $endDate)->select('count(c)'); return $qb->getQuery()->getSingleScalarResult(); } - public function countIgnoredByPerson(Person $person, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate): int + public function countIgnoredByPerson(Person $person, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate): int { return $this->buildQueryByPersonIgnoredByDates($person, $startDate, $endDate) ->select('COUNT(c)') @@ -158,12 +157,12 @@ class CalendarACLAwareRepository implements CalendarACLAwareRepositoryInterface /** * @return array|Calendar[] */ - public function findByAccompanyingPeriod(AccompanyingPeriod $period, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate, ?array $orderBy = [], ?int $offset = null, ?int $limit = null): array + public function findByAccompanyingPeriod(AccompanyingPeriod $period, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate, ?array $orderBy = [], int $offset = null, int $limit = null): array { $qb = $this->buildQueryByAccompanyingPeriod($period, $startDate, $endDate)->select('c'); foreach ($orderBy as $sort => $order) { - $qb->addOrderBy('c.' . $sort, $order); + $qb->addOrderBy('c.'.$sort, $order); } if (null !== $offset) { @@ -177,13 +176,13 @@ class CalendarACLAwareRepository implements CalendarACLAwareRepositoryInterface return $qb->getQuery()->getResult(); } - public function findByPerson(Person $person, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate, ?array $orderBy = [], ?int $offset = null, ?int $limit = null): array + public function findByPerson(Person $person, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate, ?array $orderBy = [], int $offset = null, int $limit = null): array { $qb = $this->buildQueryByPerson($person, $startDate, $endDate) ->select('c'); foreach ($orderBy as $sort => $order) { - $qb->addOrderBy('c.' . $sort, $order); + $qb->addOrderBy('c.'.$sort, $order); } if (null !== $offset) { diff --git a/src/Bundle/ChillCalendarBundle/Repository/CalendarACLAwareRepositoryInterface.php b/src/Bundle/ChillCalendarBundle/Repository/CalendarACLAwareRepositoryInterface.php index 70fb02590..f6d1b5c17 100644 --- a/src/Bundle/ChillCalendarBundle/Repository/CalendarACLAwareRepositoryInterface.php +++ b/src/Bundle/ChillCalendarBundle/Repository/CalendarACLAwareRepositoryInterface.php @@ -21,33 +21,32 @@ namespace Chill\CalendarBundle\Repository; use Chill\CalendarBundle\Entity\Calendar; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; -use DateTimeImmutable; interface CalendarACLAwareRepositoryInterface { - public function countByAccompanyingPeriod(AccompanyingPeriod $period, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate): int; + public function countByAccompanyingPeriod(AccompanyingPeriod $period, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate): int; /** * Return the number or calendars associated with a person. See condition on @see{self::findByPerson}. */ - public function countByPerson(Person $person, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate): int; + public function countByPerson(Person $person, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate): int; /** * Return the number or calendars associated with an accompanyign period which **does not** match the date conditions. */ - public function countIgnoredByAccompanyingPeriod(AccompanyingPeriod $period, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate): int; + public function countIgnoredByAccompanyingPeriod(AccompanyingPeriod $period, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate): int; /** * Return the number or calendars associated with a person which **does not** match the date conditions. * * See condition on @see{self::findByPerson}. */ - public function countIgnoredByPerson(Person $person, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate): int; + public function countIgnoredByPerson(Person $person, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate): int; /** * @return array|Calendar[] */ - public function findByAccompanyingPeriod(AccompanyingPeriod $period, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate, ?array $orderBy = [], ?int $offset = null, ?int $limit = null): array; + public function findByAccompanyingPeriod(AccompanyingPeriod $period, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate, ?array $orderBy = [], int $offset = null, int $limit = null): array; /** * Return all the calendars which are associated with a person, either on @see{Calendar::person} or within. @@ -59,5 +58,5 @@ interface CalendarACLAwareRepositoryInterface * * @return array|Calendar[] */ - public function findByPerson(Person $person, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate, ?array $orderBy = [], ?int $offset = null, ?int $limit = null): array; + public function findByPerson(Person $person, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate, ?array $orderBy = [], int $offset = null, int $limit = null): array; } diff --git a/src/Bundle/ChillCalendarBundle/Repository/CalendarDocRepository.php b/src/Bundle/ChillCalendarBundle/Repository/CalendarDocRepository.php index dd593bf3c..fb71717d0 100644 --- a/src/Bundle/ChillCalendarBundle/Repository/CalendarDocRepository.php +++ b/src/Bundle/ChillCalendarBundle/Repository/CalendarDocRepository.php @@ -35,7 +35,7 @@ class CalendarDocRepository implements ObjectRepository, CalendarDocRepositoryIn return $this->repository->findAll(); } - public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null) + public function findBy(array $criteria, array $orderBy = null, int $limit = null, int $offset = null) { return $this->repository->findBy($criteria, $orderBy, $limit, $offset); } diff --git a/src/Bundle/ChillCalendarBundle/Repository/CalendarDocRepositoryInterface.php b/src/Bundle/ChillCalendarBundle/Repository/CalendarDocRepositoryInterface.php index d2b1951df..6d86fd943 100644 --- a/src/Bundle/ChillCalendarBundle/Repository/CalendarDocRepositoryInterface.php +++ b/src/Bundle/ChillCalendarBundle/Repository/CalendarDocRepositoryInterface.php @@ -25,7 +25,7 @@ interface CalendarDocRepositoryInterface /** * @return array|CalendarDoc[] */ - public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null); + public function findBy(array $criteria, array $orderBy = null, int $limit = null, int $offset = null); public function findOneBy(array $criteria): ?CalendarDoc; diff --git a/src/Bundle/ChillCalendarBundle/Repository/CalendarRangeRepository.php b/src/Bundle/ChillCalendarBundle/Repository/CalendarRangeRepository.php index b74110c96..a707ccde9 100644 --- a/src/Bundle/ChillCalendarBundle/Repository/CalendarRangeRepository.php +++ b/src/Bundle/ChillCalendarBundle/Repository/CalendarRangeRepository.php @@ -13,14 +13,12 @@ namespace Chill\CalendarBundle\Repository; use Chill\CalendarBundle\Entity\CalendarRange; use Chill\MainBundle\Entity\User; -use DateTimeImmutable; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\ORM\QueryBuilder; use Doctrine\Persistence\ObjectRepository; -use function count; class CalendarRangeRepository implements ObjectRepository { @@ -31,7 +29,7 @@ class CalendarRangeRepository implements ObjectRepository $this->repository = $em->getRepository(CalendarRange::class); } - public function countByAvailableRangesForUser(User $user, DateTimeImmutable $from, DateTimeImmutable $to): int + public function countByAvailableRangesForUser(User $user, \DateTimeImmutable $from, \DateTimeImmutable $to): int { return $this->buildQueryAvailableRangesForUser($user, $from, $to) ->select('COUNT(cr)') @@ -54,7 +52,7 @@ class CalendarRangeRepository implements ObjectRepository /** * @return array|CalendarRange[] */ - public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null) + public function findBy(array $criteria, array $orderBy = null, int $limit = null, int $offset = null) { return $this->repository->findBy($criteria, $orderBy, $limit, $offset); } @@ -64,10 +62,10 @@ class CalendarRangeRepository implements ObjectRepository */ public function findByAvailableRangesForUser( User $user, - DateTimeImmutable $from, - DateTimeImmutable $to, - ?int $limit = null, - ?int $offset = null + \DateTimeImmutable $from, + \DateTimeImmutable $to, + int $limit = null, + int $offset = null ): array { $qb = $this->buildQueryAvailableRangesForUser($user, $from, $to); @@ -98,7 +96,7 @@ class CalendarRangeRepository implements ObjectRepository */ public function findRemoteIdsPresent(array $remoteIds): array { - if (0 === count($remoteIds)) { + if (0 === \count($remoteIds)) { return []; } @@ -113,7 +111,7 @@ class CalendarRangeRepository implements ObjectRepository $remoteIdsStr = implode( ', ', - array_fill(0, count($remoteIds), '((?))') + array_fill(0, \count($remoteIds), '((?))') ); $rsm = new ResultSetMapping(); @@ -143,7 +141,7 @@ class CalendarRangeRepository implements ObjectRepository return CalendarRange::class; } - private function buildQueryAvailableRangesForUser(User $user, DateTimeImmutable $from, DateTimeImmutable $to): QueryBuilder + private function buildQueryAvailableRangesForUser(User $user, \DateTimeImmutable $from, \DateTimeImmutable $to): QueryBuilder { $qb = $this->repository->createQueryBuilder('cr'); diff --git a/src/Bundle/ChillCalendarBundle/Repository/CalendarRepository.php b/src/Bundle/ChillCalendarBundle/Repository/CalendarRepository.php index 91a64c5ec..486493b21 100644 --- a/src/Bundle/ChillCalendarBundle/Repository/CalendarRepository.php +++ b/src/Bundle/ChillCalendarBundle/Repository/CalendarRepository.php @@ -14,14 +14,12 @@ namespace Chill\CalendarBundle\Repository; use Chill\CalendarBundle\Entity\Calendar; use Chill\MainBundle\Entity\User; use Chill\PersonBundle\Entity\AccompanyingPeriod; -use DateTimeImmutable; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\ORM\QueryBuilder; use Doctrine\Persistence\ObjectRepository; -use function count; class CalendarRepository implements ObjectRepository { @@ -40,7 +38,7 @@ class CalendarRepository implements ObjectRepository return $this->repository->count(['accompanyingPeriod' => $period]); } - public function countByUser(User $user, DateTimeImmutable $from, DateTimeImmutable $to): int + public function countByUser(User $user, \DateTimeImmutable $from, \DateTimeImmutable $to): int { return $this->buildQueryByUser($user, $from, $to) ->select('COUNT(c)') @@ -48,7 +46,7 @@ class CalendarRepository implements ObjectRepository ->getSingleScalarResult(); } - public function createQueryBuilder(string $alias, ?string $indexBy = null): QueryBuilder + public function createQueryBuilder(string $alias, string $indexBy = null): QueryBuilder { return $this->repository->createQueryBuilder($alias, $indexBy); } @@ -69,7 +67,7 @@ class CalendarRepository implements ObjectRepository /** * @return array|Calendar[] */ - public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array + public function findBy(array $criteria, array $orderBy = null, int $limit = null, int $offset = null): array { return $this->repository->findBy($criteria, $orderBy, $limit, $offset); } @@ -77,7 +75,7 @@ class CalendarRepository implements ObjectRepository /** * @return array|Calendar[] */ - public function findByAccompanyingPeriod(AccompanyingPeriod $period, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array + public function findByAccompanyingPeriod(AccompanyingPeriod $period, array $orderBy = null, int $limit = null, int $offset = null): array { return $this->findBy( [ @@ -89,7 +87,7 @@ class CalendarRepository implements ObjectRepository ); } - public function findByNotificationAvailable(DateTimeImmutable $startDate, DateTimeImmutable $endDate, ?int $limit = null, ?int $offset = null): array + public function findByNotificationAvailable(\DateTimeImmutable $startDate, \DateTimeImmutable $endDate, int $limit = null, int $offset = null): array { $qb = $this->queryByNotificationAvailable($startDate, $endDate)->select('c'); @@ -107,7 +105,7 @@ class CalendarRepository implements ObjectRepository /** * @return array|Calendar[] */ - public function findByUser(User $user, DateTimeImmutable $from, DateTimeImmutable $to, ?int $limit = null, ?int $offset = null): array + public function findByUser(User $user, \DateTimeImmutable $from, \DateTimeImmutable $to, int $limit = null, int $offset = null): array { $qb = $this->buildQueryByUser($user, $from, $to)->select('c'); @@ -138,13 +136,13 @@ class CalendarRepository implements ObjectRepository */ public function findRemoteIdsPresent(array $remoteIds): array { - if (0 === count($remoteIds)) { + if (0 === \count($remoteIds)) { return []; } $remoteIdsStr = implode( ', ', - array_fill(0, count($remoteIds), '((?))') + array_fill(0, \count($remoteIds), '((?))') ); $sql = "SELECT @@ -183,7 +181,7 @@ class CalendarRepository implements ObjectRepository return Calendar::class; } - private function buildQueryByUser(User $user, DateTimeImmutable $from, DateTimeImmutable $to): QueryBuilder + private function buildQueryByUser(User $user, \DateTimeImmutable $from, \DateTimeImmutable $to): QueryBuilder { $qb = $this->repository->createQueryBuilder('c'); @@ -202,7 +200,7 @@ class CalendarRepository implements ObjectRepository ]); } - private function queryByNotificationAvailable(DateTimeImmutable $startDate, DateTimeImmutable $endDate): QueryBuilder + private function queryByNotificationAvailable(\DateTimeImmutable $startDate, \DateTimeImmutable $endDate): QueryBuilder { $qb = $this->repository->createQueryBuilder('c'); diff --git a/src/Bundle/ChillCalendarBundle/Repository/InviteRepository.php b/src/Bundle/ChillCalendarBundle/Repository/InviteRepository.php index 8778330f8..c6f163aa3 100644 --- a/src/Bundle/ChillCalendarBundle/Repository/InviteRepository.php +++ b/src/Bundle/ChillCalendarBundle/Repository/InviteRepository.php @@ -41,7 +41,7 @@ class InviteRepository implements ObjectRepository /** * @return array|Invite[] */ - public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null) + public function findBy(array $criteria, array $orderBy = null, int $limit = null, int $offset = null) { return $this->entityRepository->findBy($criteria, $orderBy, $limit, $offset); } diff --git a/src/Bundle/ChillCalendarBundle/Security/Voter/CalendarDocVoter.php b/src/Bundle/ChillCalendarBundle/Security/Voter/CalendarDocVoter.php index 75f774119..a0e653cb1 100644 --- a/src/Bundle/ChillCalendarBundle/Security/Voter/CalendarDocVoter.php +++ b/src/Bundle/ChillCalendarBundle/Security/Voter/CalendarDocVoter.php @@ -15,8 +15,6 @@ use Chill\CalendarBundle\Entity\CalendarDoc; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authorization\Voter\Voter; use Symfony\Component\Security\Core\Security; -use UnexpectedValueException; -use function in_array; class CalendarDocVoter extends Voter { @@ -33,19 +31,18 @@ class CalendarDocVoter extends Voter protected function supports($attribute, $subject): bool { - return in_array($attribute, self::ALL, true) && $subject instanceof CalendarDoc; + return \in_array($attribute, self::ALL, true) && $subject instanceof CalendarDoc; } /** * @param CalendarDoc $subject - * @param mixed $attribute */ protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool { return match ($attribute) { self::EDIT => $this->security->isGranted(CalendarVoter::EDIT, $subject->getCalendar()), self::SEE => $this->security->isGranted(CalendarVoter::SEE, $subject->getCalendar()), - default => throw new UnexpectedValueException('Attribute not supported: ' . $attribute), + default => throw new \UnexpectedValueException('Attribute not supported: '.$attribute), }; } } diff --git a/src/Bundle/ChillCalendarBundle/Security/Voter/CalendarVoter.php b/src/Bundle/ChillCalendarBundle/Security/Voter/CalendarVoter.php index c433f2ee6..8f4c3a065 100644 --- a/src/Bundle/ChillCalendarBundle/Security/Voter/CalendarVoter.php +++ b/src/Bundle/ChillCalendarBundle/Security/Voter/CalendarVoter.php @@ -20,15 +20,12 @@ namespace Chill\CalendarBundle\Security\Voter; use Chill\CalendarBundle\Entity\Calendar; use Chill\MainBundle\Security\Authorization\AbstractChillVoter; -use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface; use Chill\MainBundle\Security\Authorization\VoterHelperFactoryInterface; use Chill\MainBundle\Security\Authorization\VoterHelperInterface; use Chill\MainBundle\Security\ProvideRoleHierarchyInterface; -use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; -use LogicException; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Security; @@ -92,7 +89,7 @@ class CalendarVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn switch ($attribute) { case self::SEE: case self::CREATE: - if ($subject->getStep() === AccompanyingPeriod::STEP_DRAFT) { + if (AccompanyingPeriod::STEP_DRAFT === $subject->getStep()) { return false; } @@ -122,6 +119,6 @@ class CalendarVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn } } - throw new LogicException('attribute or not implemented'); + throw new \LogicException('attribute or not implemented'); } } diff --git a/src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContext.php b/src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContext.php index 80c77d119..087f5ea86 100644 --- a/src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContext.php +++ b/src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContext.php @@ -29,7 +29,6 @@ use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; -use function count; final readonly class CalendarContext implements CalendarContextInterface { @@ -122,8 +121,6 @@ final readonly class CalendarContext implements CalendarContextInterface } } - /** - */ public function getData(DocGeneratorTemplate $template, mixed $entity, array $contextGenerationData = []): array { $options = $this->getOptions($template); @@ -173,7 +170,7 @@ final readonly class CalendarContext implements CalendarContextInterface if ($options['askMainPerson']) { $data['mainPerson'] = null; - if (1 === count($entity->getPersons())) { + if (1 === \count($entity->getPersons())) { $data['mainPerson'] = $entity->getPersons()->first(); } } @@ -181,7 +178,7 @@ final readonly class CalendarContext implements CalendarContextInterface if ($options['askThirdParty']) { $data['thirdParty'] = null; - if (1 === count($entity->getProfessionals())) { + if (1 === \count($entity->getProfessionals())) { $data['thirdParty'] = $entity->getProfessionals()->first(); } } diff --git a/src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContextInterface.php b/src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContextInterface.php index 74393a422..09a333f3f 100644 --- a/src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContextInterface.php +++ b/src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContextInterface.php @@ -12,12 +12,8 @@ declare(strict_types=1); namespace Chill\CalendarBundle\Service\DocGenerator; use Chill\CalendarBundle\Entity\Calendar; -use Chill\DocGeneratorBundle\Context\DocGeneratorContextInterface; use Chill\DocGeneratorBundle\Context\DocGeneratorContextWithAdminFormInterface; use Chill\DocGeneratorBundle\Context\DocGeneratorContextWithPublicFormInterface; -use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate; -use Chill\DocStoreBundle\Entity\StoredObject; -use Symfony\Component\Form\FormBuilderInterface; /** * @extends DocGeneratorContextWithPublicFormInterface diff --git a/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/AccompanyingPeriodCalendarGenericDocProvider.php b/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/AccompanyingPeriodCalendarGenericDocProvider.php index 530843723..5e4e7de83 100644 --- a/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/AccompanyingPeriodCalendarGenericDocProvider.php +++ b/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/AccompanyingPeriodCalendarGenericDocProvider.php @@ -22,7 +22,6 @@ use Chill\DocStoreBundle\GenericDoc\GenericDocForPersonProviderInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; -use DateTimeImmutable; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\MappingException; @@ -44,7 +43,7 @@ final readonly class AccompanyingPeriodCalendarGenericDocProvider implements Gen /** * @throws MappingException */ - public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface + public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null, string $origin = null): FetchQueryInterface { $classMetadata = $this->em->getClassMetadata(CalendarDoc::class); $storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class); @@ -91,7 +90,7 @@ final readonly class AccompanyingPeriodCalendarGenericDocProvider implements Gen return $this->security->isGranted(CalendarVoter::SEE, $accompanyingPeriod); } - public function buildFetchQueryForPerson(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface + public function buildFetchQueryForPerson(Person $person, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null, string $origin = null): FetchQueryInterface { $classMetadata = $this->em->getClassMetadata(CalendarDoc::class); $storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class); @@ -136,8 +135,8 @@ final readonly class AccompanyingPeriodCalendarGenericDocProvider implements Gen $storedObjectMetadata->getColumnName('createdAt') ); $orParams = [...$orParams, $participation->getAccompanyingPeriod()->getId(), - DateTimeImmutable::createFromInterface($participation->getStartDate()), - null === $participation->getEndDate() ? null : DateTimeImmutable::createFromInterface($participation->getEndDate())]; + \DateTimeImmutable::createFromInterface($participation->getStartDate()), + null === $participation->getEndDate() ? null : \DateTimeImmutable::createFromInterface($participation->getEndDate())]; $orTypes = [...$orTypes, Types::INTEGER, Types::DATE_IMMUTABLE, Types::DATE_IMMUTABLE]; } @@ -147,7 +146,7 @@ final readonly class AccompanyingPeriodCalendarGenericDocProvider implements Gen return $query; } - $query->addWhereClause(implode(" OR ", $or), $orParams, $orTypes); + $query->addWhereClause(implode(' OR ', $or), $orParams, $orTypes); return $this->addWhereClausesToQuery($query, $startDate, $endDate, $content); } @@ -159,7 +158,7 @@ final readonly class AccompanyingPeriodCalendarGenericDocProvider implements Gen return $this->security->isGranted(AccompanyingPeriodVoter::SEE, $person); } - private function addWhereClausesToQuery(FetchQuery $query, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate, ?string $content): FetchQuery + private function addWhereClausesToQuery(FetchQuery $query, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate, ?string $content): FetchQuery { $storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class); @@ -182,7 +181,7 @@ final readonly class AccompanyingPeriodCalendarGenericDocProvider implements Gen if (null !== $content) { $query->addWhereClause( sprintf('doc_store.%s ilike ?', $storedObjectMetadata->getColumnName('title')), - ['%' . $content . '%'], + ['%'.$content.'%'], [Types::STRING] ); } diff --git a/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/PersonCalendarGenericDocProvider.php b/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/PersonCalendarGenericDocProvider.php index 8bc2d4c4c..49e890ca0 100644 --- a/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/PersonCalendarGenericDocProvider.php +++ b/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Providers/PersonCalendarGenericDocProvider.php @@ -19,8 +19,6 @@ use Chill\DocStoreBundle\GenericDoc\FetchQuery; use Chill\DocStoreBundle\GenericDoc\FetchQueryInterface; use Chill\DocStoreBundle\GenericDoc\GenericDocForPersonProviderInterface; use Chill\PersonBundle\Entity\Person; -use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodWorkVoter; -use DateTimeImmutable; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\MappingException; @@ -28,7 +26,7 @@ use Service\GenericDoc\Providers\PersonCalendarGenericDocProviderTest; use Symfony\Component\Security\Core\Security; /** - * Provide calendar documents for calendar associated to persons + * Provide calendar documents for calendar associated to persons. * * @see PersonCalendarGenericDocProviderTest */ @@ -41,7 +39,7 @@ final readonly class PersonCalendarGenericDocProvider implements GenericDocForPe private EntityManagerInterface $em ) {} - private function addWhereClausesToQuery(FetchQuery $query, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null): FetchQuery + private function addWhereClausesToQuery(FetchQuery $query, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null): FetchQuery { $storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class); @@ -64,7 +62,7 @@ final readonly class PersonCalendarGenericDocProvider implements GenericDocForPe if (null !== $content) { $query->addWhereClause( sprintf('doc_store.%s ilike ?', $storedObjectMetadata->getColumnName('title')), - ['%' . $content . '%'], + ['%'.$content.'%'], [Types::STRING] ); } @@ -75,7 +73,7 @@ final readonly class PersonCalendarGenericDocProvider implements GenericDocForPe /** * @throws MappingException */ - public function buildFetchQueryForPerson(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface + public function buildFetchQueryForPerson(Person $person, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null, string $origin = null): FetchQueryInterface { $classMetadata = $this->em->getClassMetadata(CalendarDoc::class); $storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class); @@ -114,10 +112,6 @@ final readonly class PersonCalendarGenericDocProvider implements GenericDocForPe return $this->addWhereClausesToQuery($query, $startDate, $endDate, $content); } - /** - * @param Person $person - * @return bool - */ public function isAllowedForPerson(Person $person): bool { return $this->security->isGranted(CalendarVoter::SEE, $person); diff --git a/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Renderers/AccompanyingPeriodCalendarGenericDocRenderer.php b/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Renderers/AccompanyingPeriodCalendarGenericDocRenderer.php index b252b698d..123afc164 100644 --- a/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Renderers/AccompanyingPeriodCalendarGenericDocRenderer.php +++ b/src/Bundle/ChillCalendarBundle/Service/GenericDoc/Renderers/AccompanyingPeriodCalendarGenericDocRenderer.php @@ -23,7 +23,7 @@ final readonly class AccompanyingPeriodCalendarGenericDocRenderer implements Gen public function supports(GenericDocDTO $genericDocDTO, $options = []): bool { - return $genericDocDTO->key === AccompanyingPeriodCalendarGenericDocProvider::KEY || $genericDocDTO->key === PersonCalendarGenericDocProvider::KEY; + return AccompanyingPeriodCalendarGenericDocProvider::KEY === $genericDocDTO->key || PersonCalendarGenericDocProvider::KEY === $genericDocDTO->key; } public function getTemplate(GenericDocDTO $genericDocDTO, $options = []): string diff --git a/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/BulkCalendarShortMessageSender.php b/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/BulkCalendarShortMessageSender.php index c29328988..9a4a92a94 100644 --- a/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/BulkCalendarShortMessageSender.php +++ b/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/BulkCalendarShortMessageSender.php @@ -19,7 +19,6 @@ declare(strict_types=1); namespace Chill\CalendarBundle\Service\ShortMessageNotification; use Chill\CalendarBundle\Entity\Calendar; -use DateTimeImmutable; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Component\Messenger\MessageBusInterface; @@ -33,7 +32,7 @@ class BulkCalendarShortMessageSender $countCalendars = 0; $countSms = 0; - foreach ($this->provider->getCalendars(new DateTimeImmutable('now')) as $calendar) { + foreach ($this->provider->getCalendars(new \DateTimeImmutable('now')) as $calendar) { $smses = $this->messageForCalendarBuilder->buildMessageForCalendar($calendar); foreach ($smses as $sms) { @@ -42,13 +41,13 @@ class BulkCalendarShortMessageSender } $this->em - ->createQuery('UPDATE ' . Calendar::class . ' c SET c.smsStatus = :smsStatus WHERE c.id = :id') + ->createQuery('UPDATE '.Calendar::class.' c SET c.smsStatus = :smsStatus WHERE c.id = :id') ->setParameters(['smsStatus' => Calendar::SMS_SENT, 'id' => $calendar->getId()]) ->execute(); ++$countCalendars; $this->em->refresh($calendar); } - $this->logger->info(self::class . 'a bulk of messages was sent', ['count_calendars' => $countCalendars, 'count_sms' => $countSms]); + $this->logger->info(self::class.'a bulk of messages was sent', ['count_calendars' => $countCalendars, 'count_sms' => $countSms]); } } diff --git a/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/CalendarForShortMessageProvider.php b/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/CalendarForShortMessageProvider.php index 8f15be6f2..31b870ed4 100644 --- a/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/CalendarForShortMessageProvider.php +++ b/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/CalendarForShortMessageProvider.php @@ -20,9 +20,7 @@ namespace Chill\CalendarBundle\Service\ShortMessageNotification; use Chill\CalendarBundle\Entity\Calendar; use Chill\CalendarBundle\Repository\CalendarRepository; -use DateTimeImmutable; use Doctrine\ORM\EntityManagerInterface; -use function count; class CalendarForShortMessageProvider { @@ -35,7 +33,7 @@ class CalendarForShortMessageProvider * * @return iterable|Calendar[] */ - public function getCalendars(DateTimeImmutable $at): iterable + public function getCalendars(\DateTimeImmutable $at): iterable { $range = $this->rangeGenerator->generateRange($at); @@ -62,6 +60,6 @@ class CalendarForShortMessageProvider $calendars = $this->calendarRepository ->findByNotificationAvailable($startDate, $endDate, $batchSize, $offset); - } while (count($calendars) === $batchSize); + } while (\count($calendars) === $batchSize); } } diff --git a/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/DefaultRangeGenerator.php b/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/DefaultRangeGenerator.php index 7d6da3ef0..b79118cf0 100644 --- a/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/DefaultRangeGenerator.php +++ b/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/DefaultRangeGenerator.php @@ -18,9 +18,7 @@ declare(strict_types=1); namespace Chill\CalendarBundle\Service\ShortMessageNotification; -use DateInterval; use Monolog\DateTimeImmutable; -use UnexpectedValueException; /** * * Lundi => Envoi des rdv du mardi et mercredi. @@ -33,7 +31,7 @@ class DefaultRangeGenerator implements RangeGeneratorInterface { public function generateRange(\DateTimeImmutable $date): ?array { - $onMidnight = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $date->format('Y-m-d') . ' 00:00:00'); + $onMidnight = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $date->format('Y-m-d').' 00:00:00'); switch ($dow = (int) $onMidnight->format('w')) { case 6: // Saturday @@ -42,32 +40,32 @@ class DefaultRangeGenerator implements RangeGeneratorInterface case 1: // Monday // send for Tuesday and Wednesday - $startDate = $onMidnight->add(new DateInterval('P1D')); - $endDate = $startDate->add(new DateInterval('P2D')); + $startDate = $onMidnight->add(new \DateInterval('P1D')); + $endDate = $startDate->add(new \DateInterval('P2D')); break; case 2: // tuesday case 3: // wednesday - $startDate = $onMidnight->add(new DateInterval('P2D')); - $endDate = $startDate->add(new DateInterval('P1D')); + $startDate = $onMidnight->add(new \DateInterval('P2D')); + $endDate = $startDate->add(new \DateInterval('P1D')); break; case 4: // thursday - $startDate = $onMidnight->add(new DateInterval('P2D')); - $endDate = $startDate->add(new DateInterval('P2D')); + $startDate = $onMidnight->add(new \DateInterval('P2D')); + $endDate = $startDate->add(new \DateInterval('P2D')); break; case 5: // friday - $startDate = $onMidnight->add(new DateInterval('P3D')); - $endDate = $startDate->add(new DateInterval('P1D')); + $startDate = $onMidnight->add(new \DateInterval('P3D')); + $endDate = $startDate->add(new \DateInterval('P1D')); break; default: - throw new UnexpectedValueException('a day of a week should not have the value: ' . $dow); + throw new \UnexpectedValueException('a day of a week should not have the value: '.$dow); } return ['startDate' => $startDate, 'endDate' => $endDate]; diff --git a/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/DefaultShortMessageForCalendarBuilder.php b/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/DefaultShortMessageForCalendarBuilder.php index 0d6c4002e..880c9950f 100644 --- a/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/DefaultShortMessageForCalendarBuilder.php +++ b/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/DefaultShortMessageForCalendarBuilder.php @@ -20,7 +20,6 @@ namespace Chill\CalendarBundle\Service\ShortMessageNotification; use Chill\CalendarBundle\Entity\Calendar; use Chill\MainBundle\Service\ShortMessage\ShortMessage; -use Symfony\Component\Templating\EngineInterface; class DefaultShortMessageForCalendarBuilder implements ShortMessageForCalendarBuilderInterface { diff --git a/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/RangeGeneratorInterface.php b/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/RangeGeneratorInterface.php index 357e264d9..a96664907 100644 --- a/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/RangeGeneratorInterface.php +++ b/src/Bundle/ChillCalendarBundle/Service/ShortMessageNotification/RangeGeneratorInterface.php @@ -18,12 +18,10 @@ declare(strict_types=1); namespace Chill\CalendarBundle\Service\ShortMessageNotification; -use DateTimeImmutable; - interface RangeGeneratorInterface { /** - * @return ?array{startDate: DateTimeImmutable, endDate: DateTimeImmutable} when return is null, then no ShortMessage must be send + * @return ?array{startDate: \DateTimeImmutable, endDate: \DateTimeImmutable} when return is null, then no ShortMessage must be send */ - public function generateRange(DateTimeImmutable $date): ?array; + public function generateRange(\DateTimeImmutable $date): ?array; } diff --git a/src/Bundle/ChillCalendarBundle/Tests/Controller/CalendarControllerTest.php b/src/Bundle/ChillCalendarBundle/Tests/Controller/CalendarControllerTest.php index ba9fecb65..80d01ada5 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Controller/CalendarControllerTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Controller/CalendarControllerTest.php @@ -13,15 +13,14 @@ namespace Chill\CalendarBundle\Tests\Controller; use Chill\MainBundle\Test\PrepareClientTrait; use Chill\PersonBundle\Entity\AccompanyingPeriod; -use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\HttpFoundation\Request; -use function random_int; /** * @internal + * * @coversNothing */ final class CalendarControllerTest extends WebTestCase @@ -75,7 +74,7 @@ final class CalendarControllerTest extends WebTestCase ->join('ac.scopes', 's') ->andWhere('JSON_EXTRACT(s.name,\'fr\') LIKE :s') ->setParameter('s', 'social') - ->setFirstResult(random_int(0, $nb - 1)) + ->setFirstResult(\random_int(0, $nb - 1)) ->setMaxResults(1) ->getQuery() ->getSingleScalarResult(), diff --git a/src/Bundle/ChillCalendarBundle/Tests/Controller/RemoteCalendarMSGraphSyncControllerTest.php b/src/Bundle/ChillCalendarBundle/Tests/Controller/RemoteCalendarMSGraphSyncControllerTest.php index 1d4fb46b1..0c53f2b8d 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Controller/RemoteCalendarMSGraphSyncControllerTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Controller/RemoteCalendarMSGraphSyncControllerTest.php @@ -23,6 +23,7 @@ use Symfony\Component\Messenger\Transport\InMemoryTransport; /** * @internal + * * @coversNothing */ final class RemoteCalendarMSGraphSyncControllerTest extends WebTestCase diff --git a/src/Bundle/ChillCalendarBundle/Tests/Entity/CalendarDocTest.php b/src/Bundle/ChillCalendarBundle/Tests/Entity/CalendarDocTest.php index fa6132b03..98306b10c 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Entity/CalendarDocTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Entity/CalendarDocTest.php @@ -18,6 +18,7 @@ use PHPUnit\Framework\TestCase; /** * @internal + * * @coversNothing */ final class CalendarDocTest extends TestCase diff --git a/src/Bundle/ChillCalendarBundle/Tests/Entity/CalendarTest.php b/src/Bundle/ChillCalendarBundle/Tests/Entity/CalendarTest.php index e37436ad3..1cedea31c 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Entity/CalendarTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Entity/CalendarTest.php @@ -24,6 +24,7 @@ use PHPUnit\Framework\TestCase; /** * @internal + * * @coversNothing */ final class CalendarTest extends TestCase diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/AgentAggregatorTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/AgentAggregatorTest.php index c1a71218e..ae1aa6663 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/AgentAggregatorTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/AgentAggregatorTest.php @@ -25,6 +25,7 @@ use Doctrine\ORM\EntityManagerInterface; /** * @internal + * * @coversNothing */ final class AgentAggregatorTest extends AbstractAggregatorTest @@ -59,7 +60,7 @@ final class AgentAggregatorTest extends AbstractAggregatorTest return [ $em->createQueryBuilder() ->select('count(cal.id)') - ->from(Calendar::class, 'cal') + ->from(Calendar::class, 'cal'), ]; } } diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/CancelReasonAggregatorTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/CancelReasonAggregatorTest.php index ec769f3b1..0cc1ba58a 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/CancelReasonAggregatorTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/CancelReasonAggregatorTest.php @@ -25,6 +25,7 @@ use Doctrine\ORM\EntityManagerInterface; /** * @internal + * * @coversNothing */ final class CancelReasonAggregatorTest extends AbstractAggregatorTest @@ -59,7 +60,7 @@ final class CancelReasonAggregatorTest extends AbstractAggregatorTest return [ $em->createQueryBuilder() ->select('count(cal.id)') - ->from(Calendar::class, 'cal') + ->from(Calendar::class, 'cal'), ]; } } diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/JobAggregatorTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/JobAggregatorTest.php index 094567fa7..50949c3e3 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/JobAggregatorTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/JobAggregatorTest.php @@ -25,6 +25,7 @@ use Doctrine\ORM\EntityManagerInterface; /** * @internal + * * @coversNothing */ final class JobAggregatorTest extends AbstractAggregatorTest @@ -46,7 +47,7 @@ final class JobAggregatorTest extends AbstractAggregatorTest public function getFormData(): array { return [ - [] + [], ]; } @@ -59,7 +60,7 @@ final class JobAggregatorTest extends AbstractAggregatorTest return [ $em->createQueryBuilder() ->select('count(cal.id)') - ->from(Calendar::class, 'cal') + ->from(Calendar::class, 'cal'), ]; } } diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/LocationAggregatorTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/LocationAggregatorTest.php index 7756c2d69..c46f9d6da 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/LocationAggregatorTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/LocationAggregatorTest.php @@ -25,6 +25,7 @@ use Doctrine\ORM\EntityManagerInterface; /** * @internal + * * @coversNothing */ final class LocationAggregatorTest extends AbstractAggregatorTest @@ -59,7 +60,7 @@ final class LocationAggregatorTest extends AbstractAggregatorTest return [ $em->createQueryBuilder() ->select('count(cal.id)') - ->from(Calendar::class, 'cal') + ->from(Calendar::class, 'cal'), ]; } } diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/LocationTypeAggregatorTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/LocationTypeAggregatorTest.php index a69c9d9b1..fcf4e2709 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/LocationTypeAggregatorTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/LocationTypeAggregatorTest.php @@ -25,6 +25,7 @@ use Doctrine\ORM\EntityManagerInterface; /** * @internal + * * @coversNothing */ final class LocationTypeAggregatorTest extends AbstractAggregatorTest @@ -59,7 +60,7 @@ final class LocationTypeAggregatorTest extends AbstractAggregatorTest return [ $em->createQueryBuilder() ->select('count(cal.id)') - ->from(Calendar::class, 'cal') + ->from(Calendar::class, 'cal'), ]; } } diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/MonthYearAggregatorTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/MonthYearAggregatorTest.php index f2840aa98..7c50a0b52 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/MonthYearAggregatorTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/MonthYearAggregatorTest.php @@ -25,6 +25,7 @@ use Doctrine\ORM\EntityManagerInterface; /** * @internal + * * @coversNothing */ final class MonthYearAggregatorTest extends AbstractAggregatorTest diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/ScopeAggregatorTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/ScopeAggregatorTest.php index c9a2b9e5c..77ffc0bf1 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/ScopeAggregatorTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Aggregator/ScopeAggregatorTest.php @@ -25,6 +25,7 @@ use Doctrine\ORM\EntityManagerInterface; /** * @internal + * * @coversNothing */ final class ScopeAggregatorTest extends AbstractAggregatorTest @@ -59,7 +60,7 @@ final class ScopeAggregatorTest extends AbstractAggregatorTest return [ $em->createQueryBuilder() ->select('count(cal.id)') - ->from(Calendar::class, 'cal') + ->from(Calendar::class, 'cal'), ]; } } diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/AgentFilterTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/AgentFilterTest.php index 443d2b0bd..3d4efdd83 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/AgentFilterTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/AgentFilterTest.php @@ -26,6 +26,7 @@ use Doctrine\ORM\EntityManagerInterface; /** * @internal + * * @coversNothing */ final class AgentFilterTest extends AbstractFilterTest @@ -78,10 +79,9 @@ final class AgentFilterTest extends AbstractFilterTest $em = self::$container->get(EntityManagerInterface::class); - yield - $em->createQueryBuilder() - ->select('cal.id') - ->from(Calendar::class, 'cal') + yield $em->createQueryBuilder() + ->select('cal.id') + ->from(Calendar::class, 'cal') ; self::ensureKernelShutdown(); diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/BetweenDatesFilterTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/BetweenDatesFilterTest.php index a8c8b1749..4a7751433 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/BetweenDatesFilterTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/BetweenDatesFilterTest.php @@ -22,11 +22,11 @@ use Chill\CalendarBundle\Entity\Calendar; use Chill\CalendarBundle\Export\Filter\BetweenDatesFilter; use Chill\MainBundle\Service\RollingDate\RollingDate; use Chill\MainBundle\Test\Export\AbstractFilterTest; -use DateTime; use Doctrine\ORM\EntityManagerInterface; /** * @internal + * * @coversNothing */ final class BetweenDatesFilterTest extends AbstractFilterTest diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/JobFilterTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/JobFilterTest.php index d571508c8..e4bf1ac3b 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/JobFilterTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/JobFilterTest.php @@ -27,6 +27,7 @@ use Doctrine\ORM\EntityManagerInterface; /** * @internal + * * @coversNothing */ final class JobFilterTest extends AbstractFilterTest @@ -65,8 +66,8 @@ final class JobFilterTest extends AbstractFilterTest return [ [ - 'job' => new ArrayCollection($array) - ] + 'job' => new ArrayCollection($array), + ], ]; } @@ -79,7 +80,7 @@ final class JobFilterTest extends AbstractFilterTest return [ $em->createQueryBuilder() ->select('cal.id') - ->from(Calendar::class, 'cal') + ->from(Calendar::class, 'cal'), ]; } } diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/ScopeFilterTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/ScopeFilterTest.php index 06d36846b..194a6cca7 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/ScopeFilterTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Filter/ScopeFilterTest.php @@ -27,6 +27,7 @@ use Doctrine\ORM\EntityManagerInterface; /** * @internal + * * @coversNothing */ final class ScopeFilterTest extends AbstractFilterTest @@ -65,8 +66,8 @@ final class ScopeFilterTest extends AbstractFilterTest return [ [ - 'scope' => new ArrayCollection($array) - ] + 'scope' => new ArrayCollection($array), + ], ]; } @@ -79,7 +80,7 @@ final class ScopeFilterTest extends AbstractFilterTest return [ $em->createQueryBuilder() ->select('cal.id') - ->from(Calendar::class, 'cal') + ->from(Calendar::class, 'cal'), ]; } } diff --git a/src/Bundle/ChillCalendarBundle/Tests/Form/CalendarTypeTest.php b/src/Bundle/ChillCalendarBundle/Tests/Form/CalendarTypeTest.php index 85a2d72f9..0d1202b67 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Form/CalendarTypeTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Form/CalendarTypeTest.php @@ -35,11 +35,9 @@ use Chill\PersonBundle\Form\DataTransformer\PersonsToIdDataTransformer; use Chill\ThirdPartyBundle\Entity\ThirdParty; use Chill\ThirdPartyBundle\Form\DataTransformer\ThirdPartiesToIdDataTransformer; use Chill\ThirdPartyBundle\Repository\ThirdPartyRepository; -use DateTimeImmutable; use Doctrine\Common\Collections\Collection; use Prophecy\Argument; use Prophecy\PhpUnit\ProphecyTrait; -use ReflectionProperty; use Symfony\Component\Form\PreloadedExtension; use Symfony\Component\Form\Test\TypeTestCase; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; @@ -48,6 +46,7 @@ use Symfony\Component\Security\Core\Security; /** * @internal + * * @coversNothing */ final class CalendarTypeTest extends TypeTestCase @@ -112,8 +111,8 @@ final class CalendarTypeTest extends TypeTestCase $form->submit($formData); $this->assertTrue($form->isSynchronized()); - $this->assertEquals(DateTimeImmutable::createFromFormat('Y-m-d H:i:s', '2022-05-05 14:00:00'), $calendar->getStartDate()); - $this->assertEquals(DateTimeImmutable::createFromFormat('Y-m-d H:i:s', '2022-05-05 14:30:00'), $calendar->getEndDate()); + $this->assertEquals(\DateTimeImmutable::createFromFormat('Y-m-d H:i:s', '2022-05-05 14:00:00'), $calendar->getStartDate()); + $this->assertEquals(\DateTimeImmutable::createFromFormat('Y-m-d H:i:s', '2022-05-05 14:30:00'), $calendar->getEndDate()); $this->assertEquals(7, $calendar->getPersons()->first()->getId()); $this->assertEquals(8, $calendar->getCalendarRange()->getId()); $this->assertEquals(9, $calendar->getLocation()->getId()); @@ -181,7 +180,7 @@ final class CalendarTypeTest extends TypeTestCase return array_map( static function ($id) use ($objClass) { $obj = new $objClass(); - $reflectionProperty = new ReflectionProperty($objClass, 'id'); + $reflectionProperty = new \ReflectionProperty($objClass, 'id'); $reflectionProperty->setAccessible(true); $reflectionProperty->setValue($obj, (int) $id); @@ -209,7 +208,7 @@ final class CalendarTypeTest extends TypeTestCase return null; } $obj = new $class(); - $reflectionProperty = new ReflectionProperty($class, 'id'); + $reflectionProperty = new \ReflectionProperty($class, 'id'); $reflectionProperty->setAccessible(true); $reflectionProperty->setValue($obj, (int) $args[0]); diff --git a/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/AddressConverterTest.php b/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/AddressConverterTest.php index 7623cba64..eca929875 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/AddressConverterTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/AddressConverterTest.php @@ -27,10 +27,10 @@ use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use PHPUnit\Framework\TestCase; use Prophecy\Argument; use Prophecy\PhpUnit\ProphecyTrait; -use Symfony\Component\Templating\EngineInterface; /** * @internal + * * @coversNothing */ final class AddressConverterTest extends TestCase diff --git a/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/CalendarRangeSyncerTest.php b/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/CalendarRangeSyncerTest.php index 92280f6c1..9f7df0c2c 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/CalendarRangeSyncerTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/CalendarRangeSyncerTest.php @@ -22,7 +22,6 @@ use Chill\CalendarBundle\Entity\Calendar; use Chill\CalendarBundle\Entity\CalendarRange; use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\RemoteToLocalSync\CalendarRangeSyncer; use Chill\MainBundle\Entity\User; -use DateTimeImmutable; use Doctrine\ORM\EntityManagerInterface; use PHPUnit\Framework\TestCase; use Prophecy\Argument; @@ -33,6 +32,7 @@ use Symfony\Component\HttpClient\Response\MockResponse; /** * @internal + * * @coversNothing */ final class CalendarRangeSyncerTest extends TestCase @@ -228,8 +228,8 @@ final class CalendarRangeSyncerTest extends TestCase $calendarRange = new CalendarRange(); $calendarRange ->setUser($user = new User()) - ->setStartDate(new DateTimeImmutable('2020-01-01 15:00:00')) - ->setEndDate(new DateTimeImmutable('2020-01-01 15:30:00')) + ->setStartDate(new \DateTimeImmutable('2020-01-01 15:00:00')) + ->setEndDate(new \DateTimeImmutable('2020-01-01 15:30:00')) ->addRemoteAttributes([ 'lastModifiedDateTime' => 0, 'changeKey' => 'abc', @@ -244,11 +244,11 @@ final class CalendarRangeSyncerTest extends TestCase $this->assertStringContainsString( '2022-06-10T15:30:00', - $calendarRange->getStartDate()->format(DateTimeImmutable::ATOM) + $calendarRange->getStartDate()->format(\DateTimeImmutable::ATOM) ); $this->assertStringContainsString( '2022-06-10T17:30:00', - $calendarRange->getEndDate()->format(DateTimeImmutable::ATOM) + $calendarRange->getEndDate()->format(\DateTimeImmutable::ATOM) ); $this->assertTrue($calendarRange->preventEnqueueChanges); } diff --git a/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/CalendarSyncerTest.php b/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/CalendarSyncerTest.php index 82f088c3f..8f6cb9335 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/CalendarSyncerTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/CalendarSyncerTest.php @@ -24,8 +24,6 @@ use Chill\CalendarBundle\Entity\Invite; use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\RemoteToLocalSync\CalendarSyncer; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Repository\UserRepositoryInterface; -use DateTimeImmutable; -use DateTimeZone; use PHPUnit\Framework\TestCase; use Prophecy\Argument; use Prophecy\PhpUnit\ProphecyTrait; @@ -35,6 +33,7 @@ use Symfony\Component\HttpClient\Response\MockResponse; /** * @internal + * * @coversNothing */ final class CalendarSyncerTest extends TestCase @@ -362,9 +361,9 @@ final class CalendarSyncerTest extends TestCase parent::setUp(); // all tests should run when timezone = +02:00 - $brussels = new DateTimeZone('Europe/Brussels'); + $brussels = new \DateTimeZone('Europe/Brussels'); - if (7200 === $brussels->getOffset(new DateTimeImmutable())) { + if (7200 === $brussels->getOffset(new \DateTimeImmutable())) { date_default_timezone_set('Europe/Brussels'); } else { date_default_timezone_set('Europe/Moscow'); @@ -403,8 +402,8 @@ final class CalendarSyncerTest extends TestCase $calendar = new Calendar(); $calendar ->setMainUser($user = new User()) - ->setStartDate(new DateTimeImmutable('2022-06-11 14:30:00')) - ->setEndDate(new DateTimeImmutable('2022-06-11 15:30:00')) + ->setStartDate(new \DateTimeImmutable('2022-06-11 14:30:00')) + ->setEndDate(new \DateTimeImmutable('2022-06-11 15:30:00')) ->addUser($userA) ->addUser($userB) ->setCalendarRange(new CalendarRange()) @@ -480,8 +479,8 @@ final class CalendarSyncerTest extends TestCase $calendar = new Calendar(); $calendar ->setMainUser($user = new User()) - ->setStartDate(new DateTimeImmutable('2020-01-01 10:00:00')) - ->setEndDate(new DateTimeImmutable('2020-01-01 12:00:00')) + ->setStartDate(new \DateTimeImmutable('2020-01-01 10:00:00')) + ->setEndDate(new \DateTimeImmutable('2020-01-01 12:00:00')) ->setCalendarRange(new CalendarRange()) ->addRemoteAttributes([ 'lastModifiedDateTime' => 0, @@ -498,11 +497,11 @@ final class CalendarSyncerTest extends TestCase $this->assertStringContainsString( '2022-06-10T15:30:00', - $calendar->getStartDate()->format(DateTimeImmutable::ATOM) + $calendar->getStartDate()->format(\DateTimeImmutable::ATOM) ); $this->assertStringContainsString( '2022-06-10T17:30:00', - $calendar->getEndDate()->format(DateTimeImmutable::ATOM) + $calendar->getEndDate()->format(\DateTimeImmutable::ATOM) ); $this->assertTrue($calendar->preventEnqueueChanges); $this->assertGreaterThan($previousVersion, $calendar->getDateTimeVersion()); @@ -524,8 +523,8 @@ final class CalendarSyncerTest extends TestCase $calendar = new Calendar(); $calendar ->setMainUser($user = new User()) - ->setStartDate(new DateTimeImmutable('2022-06-10 15:30:00')) - ->setEndDate(new DateTimeImmutable('2022-06-10 17:30:00')) + ->setStartDate(new \DateTimeImmutable('2022-06-10 15:30:00')) + ->setEndDate(new \DateTimeImmutable('2022-06-10 17:30:00')) ->setCalendarRange(new CalendarRange()) ->addRemoteAttributes([ 'lastModifiedDateTime' => 0, @@ -541,11 +540,11 @@ final class CalendarSyncerTest extends TestCase $this->assertStringContainsString( '2022-06-10T15:30:00', - $calendar->getStartDate()->format(DateTimeImmutable::ATOM) + $calendar->getStartDate()->format(\DateTimeImmutable::ATOM) ); $this->assertStringContainsString( '2022-06-10T17:30:00', - $calendar->getEndDate()->format(DateTimeImmutable::ATOM) + $calendar->getEndDate()->format(\DateTimeImmutable::ATOM) ); $this->assertTrue($calendar->preventEnqueueChanges); $this->assertEquals(Calendar::STATUS_VALID, $calendar->getStatus()); @@ -568,8 +567,8 @@ final class CalendarSyncerTest extends TestCase $calendar = new Calendar(); $calendar ->setMainUser($user = new User()) - ->setStartDate(new DateTimeImmutable('2020-01-01 10:00:00')) - ->setEndDate(new DateTimeImmutable('2020-01-01 12:00:00')) + ->setStartDate(new \DateTimeImmutable('2020-01-01 10:00:00')) + ->setEndDate(new \DateTimeImmutable('2020-01-01 12:00:00')) ->setCalendarRange(new CalendarRange()) ->addRemoteAttributes([ 'lastModifiedDateTime' => 0, @@ -585,11 +584,11 @@ final class CalendarSyncerTest extends TestCase $this->assertStringContainsString( '2020-01-01T10:00:00', - $calendar->getStartDate()->format(DateTimeImmutable::ATOM) + $calendar->getStartDate()->format(\DateTimeImmutable::ATOM) ); $this->assertStringContainsString( '2020-01-01T12:00:00', - $calendar->getEndDate()->format(DateTimeImmutable::ATOM) + $calendar->getEndDate()->format(\DateTimeImmutable::ATOM) ); $this->assertEquals(Calendar::STATUS_VALID, $calendar->getStatus()); diff --git a/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/LocationConverterTest.php b/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/LocationConverterTest.php index 604b707c0..55dfe427c 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/LocationConverterTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/LocationConverterTest.php @@ -30,6 +30,7 @@ use Prophecy\PhpUnit\ProphecyTrait; /** * @internal + * * @coversNothing */ final class LocationConverterTest extends TestCase diff --git a/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/MSUserAbsenceReaderTest.php b/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/MSUserAbsenceReaderTest.php index 2ceab8b1f..4307f32a3 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/MSUserAbsenceReaderTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/MSUserAbsenceReaderTest.php @@ -22,6 +22,7 @@ use Symfony\Component\HttpClient\Response\MockResponse; /** * @internal + * * @coversNothing */ class MSUserAbsenceReaderTest extends TestCase @@ -55,7 +56,7 @@ class MSUserAbsenceReaderTest extends TestCase $absenceReader = new MSUserAbsenceReader($client, $mapUser->reveal(), $clock); - self::assertNull($absenceReader->isUserAbsent($user), "when no user found, absence should be null"); + self::assertNull($absenceReader->isUserAbsent($user), 'when no user found, absence should be null'); } public function provideDataTestUserAbsence(): iterable @@ -81,7 +82,7 @@ class MSUserAbsenceReaderTest extends TestCase } JSON, false, - "User is present" + 'User is present', ]; yield [ @@ -103,7 +104,7 @@ class MSUserAbsenceReaderTest extends TestCase } JSON, true, - 'User is absent with absence scheduled, we are within this period' + 'User is absent with absence scheduled, we are within this period', ]; yield [ @@ -125,7 +126,7 @@ class MSUserAbsenceReaderTest extends TestCase } JSON, false, - 'User is present: absence is scheduled for later' + 'User is present: absence is scheduled for later', ]; yield [ @@ -147,7 +148,7 @@ class MSUserAbsenceReaderTest extends TestCase } JSON, false, - 'User is present: absence is past' + 'User is present: absence is past', ]; yield [ @@ -169,7 +170,7 @@ class MSUserAbsenceReaderTest extends TestCase } JSON, true, - "User is absent: absence is always enabled" + 'User is absent: absence is always enabled', ]; } } diff --git a/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/MSUserAbsenceSyncTest.php b/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/MSUserAbsenceSyncTest.php index 1b0f1e416..244c7e468 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/MSUserAbsenceSyncTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/MSUserAbsenceSyncTest.php @@ -11,7 +11,6 @@ declare(strict_types=1); namespace Chill\CalendarBundle\Tests\RemoteCalendar\Connector\MSGraph; -use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\MSUserAbsenceReader; use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\MSUserAbsenceReaderInterface; use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\MSUserAbsenceSync; use Chill\MainBundle\Entity\User; @@ -22,6 +21,7 @@ use Symfony\Component\Clock\MockClock; /** * @internal + * * @coversNothing */ class MSUserAbsenceSyncTest extends TestCase @@ -48,21 +48,21 @@ class MSUserAbsenceSyncTest extends TestCase public function provideDataTestSyncUserAbsence(): iterable { - yield [new User(), false, false, null, "user present remains present"]; - yield [new User(), true, true, new \DateTimeImmutable('2023-07-01T12:00:00'), "user present becomes absent"]; + yield [new User(), false, false, null, 'user present remains present']; + yield [new User(), true, true, new \DateTimeImmutable('2023-07-01T12:00:00'), 'user present becomes absent']; $user = new User(); - $user->setAbsenceStart($abs = new \DateTimeImmutable("2023-07-01T12:00:00")); - yield [$user, true, true, $abs, "user absent remains absent"]; + $user->setAbsenceStart($abs = new \DateTimeImmutable('2023-07-01T12:00:00')); + yield [$user, true, true, $abs, 'user absent remains absent']; $user = new User(); - $user->setAbsenceStart($abs = new \DateTimeImmutable("2023-07-01T12:00:00")); - yield [$user, false, false, null, "user absent becomes present"]; + $user->setAbsenceStart($abs = new \DateTimeImmutable('2023-07-01T12:00:00')); + yield [$user, false, false, null, 'user absent becomes present']; - yield [new User(), null, false, null, "user not syncable: presence do not change"]; + yield [new User(), null, false, null, 'user not syncable: presence do not change']; $user = new User(); - $user->setAbsenceStart($abs = new \DateTimeImmutable("2023-07-01T12:00:00")); - yield [$user, null, true, $abs, "user not syncable: absence do not change"]; + $user->setAbsenceStart($abs = new \DateTimeImmutable('2023-07-01T12:00:00')); + yield [$user, null, true, $abs, 'user not syncable: absence do not change']; } } diff --git a/src/Bundle/ChillCalendarBundle/Tests/Repository/CalendarACLAwareRepositoryTest.php b/src/Bundle/ChillCalendarBundle/Tests/Repository/CalendarACLAwareRepositoryTest.php index 0fb4a662b..8d3101c5b 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Repository/CalendarACLAwareRepositoryTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Repository/CalendarACLAwareRepositoryTest.php @@ -15,13 +15,13 @@ use Chill\CalendarBundle\Repository\CalendarACLAwareRepository; use Chill\PersonBundle\DataFixtures\Helper\PersonRandomHelper; use Chill\PersonBundle\Repository\AccompanyingPeriodACLAwareRepositoryInterface; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; -use DateTimeImmutable; use Doctrine\ORM\EntityManagerInterface; use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; /** * @internal + * * @coversNothing */ final class CalendarACLAwareRepositoryTest extends KernelTestCase @@ -51,7 +51,7 @@ final class CalendarACLAwareRepositoryTest extends KernelTestCase $this->entityManager ); - $count = $calendarRepository->countByPerson($person, new DateTimeImmutable('yesterday'), new DateTimeImmutable('tomorrow')); + $count = $calendarRepository->countByPerson($person, new \DateTimeImmutable('yesterday'), new \DateTimeImmutable('tomorrow')); $this->assertIsInt($count); } diff --git a/src/Bundle/ChillCalendarBundle/Tests/Serializer/Normalizer/CalendarNormalizerTest.php b/src/Bundle/ChillCalendarBundle/Tests/Serializer/Normalizer/CalendarNormalizerTest.php index 2a0975206..03ba7f164 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Serializer/Normalizer/CalendarNormalizerTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Serializer/Normalizer/CalendarNormalizerTest.php @@ -16,12 +16,12 @@ use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable; use Chill\MainBundle\Entity\User; use Chill\PersonBundle\Entity\Person; use Chill\ThirdPartyBundle\Entity\ThirdParty; -use DateTimeImmutable; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; /** * @internal + * * @coversNothing */ final class CalendarNormalizerTest extends KernelTestCase @@ -41,8 +41,8 @@ final class CalendarNormalizerTest extends KernelTestCase ->setComment( $comment = new CommentEmbeddable() ) - ->setStartDate(DateTimeImmutable::createFromFormat(DateTimeImmutable::ATOM, '2020-10-15T15:00:00+0000')) - ->setEndDate(DateTimeImmutable::createFromFormat(DateTimeImmutable::ATOM, '2020-15-15T15:30:00+0000')) + ->setStartDate(\DateTimeImmutable::createFromFormat(\DateTimeImmutable::ATOM, '2020-10-15T15:00:00+0000')) + ->setEndDate(\DateTimeImmutable::createFromFormat(\DateTimeImmutable::ATOM, '2020-15-15T15:30:00+0000')) ->addPerson(new Person()) ->addPerson(new Person()) ->addUser(new User()) diff --git a/src/Bundle/ChillCalendarBundle/Tests/Service/DocGenerator/CalendarContextTest.php b/src/Bundle/ChillCalendarBundle/Tests/Service/DocGenerator/CalendarContextTest.php index 7bbaf4ded..506baa98b 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Service/DocGenerator/CalendarContextTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Service/DocGenerator/CalendarContextTest.php @@ -33,11 +33,10 @@ use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; -use function array_key_exists; -use function count; /** * @internal + * * @coversNothing */ final class CalendarContextTest extends TestCase @@ -85,13 +84,13 @@ final class CalendarContextTest extends TestCase // so, we expect the call to be twice for each method $formBuilder->add('thirdParty', EntityType::class, Argument::type('array')) ->should(static function ($calls, $object, $method) use ($tp1, $tp2) { - if (2 !== count($calls)) { - throw new FailedPredictionException(sprintf('the $builder->add should be called exactly 2, %d receivved', count($calls))); + if (2 !== \count($calls)) { + throw new FailedPredictionException(sprintf('the $builder->add should be called exactly 2, %d receivved', \count($calls))); } $opts = $calls[0]->getArguments()[2]; - if (!array_key_exists('label', $opts)) { + if (!\array_key_exists('label', $opts)) { throw new FailedPredictionException('the $builder->add should have a label key'); } @@ -105,13 +104,13 @@ final class CalendarContextTest extends TestCase }); $formBuilder->add('mainPerson', EntityType::class, Argument::type('array')) ->should(static function ($calls, $object, $method) use ($p1) { - if (2 !== count($calls)) { - throw new FailedPredictionException(sprintf('the $builder->add should be called exactly 2, %d receivved', count($calls))); + if (2 !== \count($calls)) { + throw new FailedPredictionException(sprintf('the $builder->add should be called exactly 2, %d receivved', \count($calls))); } $opts = $calls[0]->getArguments()[2]; - if (!array_key_exists('label', $opts)) { + if (!\array_key_exists('label', $opts)) { throw new FailedPredictionException('the $builder->add should have a label key'); } @@ -178,7 +177,7 @@ final class CalendarContextTest extends TestCase $em = $this->prophesize(EntityManagerInterface::class); $em->persist(Argument::type(CalendarDoc::class))->should( static function ($calls, $object, $method) use ($storedObject) { - if (1 !== count($calls)) { + if (1 !== \count($calls)) { throw new FailedPredictionException('the persist method should be called once'); } @@ -189,7 +188,7 @@ final class CalendarContextTest extends TestCase throw new FailedPredictionException('the stored object is not correct'); } - if ($calendarDoc->getStoredObject()->getTitle() !== 'blabla') { + if ('blabla' !== $calendarDoc->getStoredObject()->getTitle()) { throw new FailedPredictionException('the doc title should be the one provided'); } @@ -203,8 +202,8 @@ final class CalendarContextTest extends TestCase } private function buildCalendarContext( - ?EntityManagerInterface $entityManager = null, - ?NormalizerInterface $normalizer = null + EntityManagerInterface $entityManager = null, + NormalizerInterface $normalizer = null ): CalendarContext { $baseContext = $this->prophesize(BaseContextData::class); $baseContext->getData(null)->willReturn(['base_context' => 'data']); diff --git a/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/BulkCalendarShortMessageSenderTest.php b/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/BulkCalendarShortMessageSenderTest.php index 0c190f51d..308c17237 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/BulkCalendarShortMessageSenderTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/BulkCalendarShortMessageSenderTest.php @@ -18,7 +18,6 @@ declare(strict_types=1); namespace Chill\CalendarBundle\Tests\Service\ShortMessageNotification; -use ArrayIterator; use Chill\CalendarBundle\Entity\Calendar; use Chill\CalendarBundle\Service\ShortMessageNotification\BulkCalendarShortMessageSender; use Chill\CalendarBundle\Service\ShortMessageNotification\CalendarForShortMessageProvider; @@ -27,20 +26,18 @@ use Chill\MainBundle\Entity\User; use Chill\MainBundle\Service\ShortMessage\ShortMessage; use Chill\MainBundle\Test\PrepareUserTrait; use Chill\PersonBundle\DataFixtures\Helper\PersonRandomHelper; -use DateInterval; -use DateTimeImmutable; use Doctrine\ORM\EntityManagerInterface; use libphonenumber\PhoneNumberUtil; use Prophecy\Argument; use Prophecy\PhpUnit\ProphecyTrait; use Psr\Log\NullLogger; -use stdClass; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Component\Messenger\Envelope; use Symfony\Component\Messenger\MessageBusInterface; /** * @internal + * * @coversNothing */ final class BulkCalendarShortMessageSenderTest extends KernelTestCase @@ -79,26 +76,26 @@ final class BulkCalendarShortMessageSenderTest extends KernelTestCase $calendar ->addPerson($this->getRandomPerson($em)) ->setMainUser($user = $this->prepareUser([])) - ->setStartDate(new DateTimeImmutable('now')) - ->setEndDate($calendar->getStartDate()->add(new DateInterval('PT30M'))) + ->setStartDate(new \DateTimeImmutable('now')) + ->setEndDate($calendar->getStartDate()->add(new \DateInterval('PT30M'))) ->setSendSMS(true); $user->setUsername(uniqid()); - $user->setEmail(uniqid() . '@gmail.com'); + $user->setEmail(uniqid().'@gmail.com'); $calendar->getPersons()->first()->setAcceptSMS(true); // hack to prevent side effect with messages $calendar->preventEnqueueChanges = true; $em->persist($user); - //$this->toDelete[] = [User::class, $user->getId()]; + // $this->toDelete[] = [User::class, $user->getId()]; $em->persist($calendar); - //$this->toDelete[] = [Calendar::class, $calendar->getId()]; + // $this->toDelete[] = [Calendar::class, $calendar->getId()]; $em->flush(); $provider = $this->prophesize(CalendarForShortMessageProvider::class); - $provider->getCalendars(Argument::type(DateTimeImmutable::class)) - ->willReturn(new ArrayIterator([$calendar])); + $provider->getCalendars(Argument::type(\DateTimeImmutable::class)) + ->willReturn(new \ArrayIterator([$calendar])); $messageBuilder = $this->prophesize(ShortMessageForCalendarBuilderInterface::class); $messageBuilder->buildMessageForCalendar(Argument::type(Calendar::class)) @@ -114,7 +111,7 @@ final class BulkCalendarShortMessageSenderTest extends KernelTestCase $bus = $this->prophesize(MessageBusInterface::class); $bus->dispatch(Argument::type(ShortMessage::class)) - ->willReturn(new Envelope(new stdClass())) + ->willReturn(new Envelope(new \stdClass())) ->shouldBeCalledTimes(1); $bulk = new BulkCalendarShortMessageSender( diff --git a/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/CalendarForShortMessageProviderTest.php b/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/CalendarForShortMessageProviderTest.php index 34867d8bd..47af7d68e 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/CalendarForShortMessageProviderTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/CalendarForShortMessageProviderTest.php @@ -23,15 +23,14 @@ use Chill\CalendarBundle\Repository\CalendarRepository; use Chill\CalendarBundle\Service\ShortMessageNotification\CalendarForShortMessageProvider; use Chill\CalendarBundle\Service\ShortMessageNotification\DefaultRangeGenerator; use Chill\CalendarBundle\Service\ShortMessageNotification\RangeGeneratorInterface; -use DateTimeImmutable; use Doctrine\ORM\EntityManagerInterface; use PHPUnit\Framework\TestCase; use Prophecy\Argument; use Prophecy\PhpUnit\ProphecyTrait; -use function count; /** * @internal + * * @coversNothing */ final class CalendarForShortMessageProviderTest extends TestCase @@ -42,13 +41,13 @@ final class CalendarForShortMessageProviderTest extends TestCase { $calendarRepository = $this->prophesize(CalendarRepository::class); $calendarRepository->findByNotificationAvailable( - Argument::type(DateTimeImmutable::class), - Argument::type(DateTimeImmutable::class), + Argument::type(\DateTimeImmutable::class), + Argument::type(\DateTimeImmutable::class), Argument::type('int'), Argument::exact(0) )->shouldBeCalledTimes(0); $rangeGenerator = $this->prophesize(RangeGeneratorInterface::class); - $rangeGenerator->generateRange(Argument::type(DateTimeImmutable::class))->willReturn(null); + $rangeGenerator->generateRange(Argument::type(\DateTimeImmutable::class))->willReturn(null); $em = $this->prophesize(EntityManagerInterface::class); $em->clear()->shouldNotBeCalled(); @@ -59,23 +58,23 @@ final class CalendarForShortMessageProviderTest extends TestCase $rangeGenerator->reveal() ); - $calendars = iterator_to_array($provider->getCalendars(new DateTimeImmutable('now'))); + $calendars = iterator_to_array($provider->getCalendars(new \DateTimeImmutable('now'))); - $this->assertEquals(0, count($calendars)); + $this->assertEquals(0, \count($calendars)); } public function testGetCalendars() { $calendarRepository = $this->prophesize(CalendarRepository::class); $calendarRepository->findByNotificationAvailable( - Argument::type(DateTimeImmutable::class), - Argument::type(DateTimeImmutable::class), + Argument::type(\DateTimeImmutable::class), + Argument::type(\DateTimeImmutable::class), Argument::type('int'), Argument::exact(0) )->will(static fn ($args) => array_fill(0, $args[2], new Calendar()))->shouldBeCalledTimes(1); $calendarRepository->findByNotificationAvailable( - Argument::type(DateTimeImmutable::class), - Argument::type(DateTimeImmutable::class), + Argument::type(\DateTimeImmutable::class), + Argument::type(\DateTimeImmutable::class), Argument::type('int'), Argument::not(0) )->will(static fn ($args) => array_fill(0, $args[2] - 1, new Calendar()))->shouldBeCalledTimes(1); @@ -89,10 +88,10 @@ final class CalendarForShortMessageProviderTest extends TestCase new DefaultRangeGenerator() ); - $calendars = iterator_to_array($provider->getCalendars(new DateTimeImmutable('now'))); + $calendars = iterator_to_array($provider->getCalendars(new \DateTimeImmutable('now'))); - $this->assertGreaterThan(1, count($calendars)); - $this->assertLessThan(100, count($calendars)); + $this->assertGreaterThan(1, \count($calendars)); + $this->assertLessThan(100, \count($calendars)); $this->assertContainsOnly(Calendar::class, $calendars); } @@ -100,14 +99,14 @@ final class CalendarForShortMessageProviderTest extends TestCase { $calendarRepository = $this->prophesize(CalendarRepository::class); $calendarRepository->findByNotificationAvailable( - Argument::type(DateTimeImmutable::class), - Argument::type(DateTimeImmutable::class), + Argument::type(\DateTimeImmutable::class), + Argument::type(\DateTimeImmutable::class), Argument::type('int'), Argument::exact(0) )->will(static fn ($args) => array_fill(0, 1, new Calendar()))->shouldBeCalledTimes(1); $calendarRepository->findByNotificationAvailable( - Argument::type(DateTimeImmutable::class), - Argument::type(DateTimeImmutable::class), + Argument::type(\DateTimeImmutable::class), + Argument::type(\DateTimeImmutable::class), Argument::type('int'), Argument::not(0) )->will(static fn ($args) => [])->shouldBeCalledTimes(1); @@ -121,9 +120,9 @@ final class CalendarForShortMessageProviderTest extends TestCase new DefaultRangeGenerator() ); - $calendars = iterator_to_array($provider->getCalendars(new DateTimeImmutable('now'))); + $calendars = iterator_to_array($provider->getCalendars(new \DateTimeImmutable('now'))); - $this->assertEquals(1, count($calendars)); + $this->assertEquals(1, \count($calendars)); $this->assertContainsOnly(Calendar::class, $calendars); } } diff --git a/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/DefaultRangeGeneratorTest.php b/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/DefaultRangeGeneratorTest.php index de2b97963..552595414 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/DefaultRangeGeneratorTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/DefaultRangeGeneratorTest.php @@ -19,12 +19,11 @@ declare(strict_types=1); namespace Chill\CalendarBundle\Tests\Service\ShortMessageNotification; use Chill\CalendarBundle\Service\ShortMessageNotification\DefaultRangeGenerator; -use DateTimeImmutable; -use Iterator; use PHPUnit\Framework\TestCase; /** * @internal + * * @coversNothing */ final class DefaultRangeGeneratorTest extends TestCase @@ -36,46 +35,46 @@ final class DefaultRangeGeneratorTest extends TestCase * * Jeudi => envoi des rdv du samedi et dimanche * * Vendredi => Envoi des rdv du lundi. */ - public function generateData(): Iterator + public function generateData(): \Iterator { yield [ - new DateTimeImmutable('2022-06-13 10:45:00'), - new DateTimeImmutable('2022-06-14 00:00:00'), - new DateTimeImmutable('2022-06-16 00:00:00'), + new \DateTimeImmutable('2022-06-13 10:45:00'), + new \DateTimeImmutable('2022-06-14 00:00:00'), + new \DateTimeImmutable('2022-06-16 00:00:00'), ]; yield [ - new DateTimeImmutable('2022-06-14 15:45:00'), - new DateTimeImmutable('2022-06-16 00:00:00'), - new DateTimeImmutable('2022-06-17 00:00:00'), + new \DateTimeImmutable('2022-06-14 15:45:00'), + new \DateTimeImmutable('2022-06-16 00:00:00'), + new \DateTimeImmutable('2022-06-17 00:00:00'), ]; yield [ - new DateTimeImmutable('2022-06-15 13:45:18'), - new DateTimeImmutable('2022-06-17 00:00:00'), - new DateTimeImmutable('2022-06-18 00:00:00'), + new \DateTimeImmutable('2022-06-15 13:45:18'), + new \DateTimeImmutable('2022-06-17 00:00:00'), + new \DateTimeImmutable('2022-06-18 00:00:00'), ]; yield [ - new DateTimeImmutable('2022-06-16 01:30:55'), - new DateTimeImmutable('2022-06-18 00:00:00'), - new DateTimeImmutable('2022-06-20 00:00:00'), + new \DateTimeImmutable('2022-06-16 01:30:55'), + new \DateTimeImmutable('2022-06-18 00:00:00'), + new \DateTimeImmutable('2022-06-20 00:00:00'), ]; yield [ - new DateTimeImmutable('2022-06-17 21:30:55'), - new DateTimeImmutable('2022-06-20 00:00:00'), - new DateTimeImmutable('2022-06-21 00:00:00'), + new \DateTimeImmutable('2022-06-17 21:30:55'), + new \DateTimeImmutable('2022-06-20 00:00:00'), + new \DateTimeImmutable('2022-06-21 00:00:00'), ]; yield [ - new DateTimeImmutable('2022-06-18 21:30:55'), + new \DateTimeImmutable('2022-06-18 21:30:55'), null, null, ]; yield [ - new DateTimeImmutable('2022-06-19 21:30:55'), + new \DateTimeImmutable('2022-06-19 21:30:55'), null, null, ]; @@ -84,7 +83,7 @@ final class DefaultRangeGeneratorTest extends TestCase /** * @dataProvider generateData */ - public function testGenerateRange(DateTimeImmutable $date, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate) + public function testGenerateRange(\DateTimeImmutable $date, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate) { $generator = new DefaultRangeGenerator(); @@ -94,8 +93,8 @@ final class DefaultRangeGeneratorTest extends TestCase $this->assertNull($actualStartDate); $this->assertNull($actualEndDate); } else { - $this->assertEquals($startDate->format(DateTimeImmutable::ATOM), $actualStartDate->format(DateTimeImmutable::ATOM)); - $this->assertEquals($endDate->format(DateTimeImmutable::ATOM), $actualEndDate->format(DateTimeImmutable::ATOM)); + $this->assertEquals($startDate->format(\DateTimeImmutable::ATOM), $actualStartDate->format(\DateTimeImmutable::ATOM)); + $this->assertEquals($endDate->format(\DateTimeImmutable::ATOM), $actualEndDate->format(\DateTimeImmutable::ATOM)); } } } diff --git a/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/DefaultShortMessageForCalendarBuilderTest.php b/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/DefaultShortMessageForCalendarBuilderTest.php index 67d124c40..222d3a451 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/DefaultShortMessageForCalendarBuilderTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Service/ShortMessageNotification/DefaultShortMessageForCalendarBuilderTest.php @@ -23,17 +23,15 @@ use Chill\CalendarBundle\Service\ShortMessageNotification\DefaultShortMessageFor use Chill\MainBundle\Entity\Location; use Chill\MainBundle\Entity\User; use Chill\PersonBundle\Entity\Person; -use DateInterval; -use DateTimeImmutable; use libphonenumber\PhoneNumberFormat; use libphonenumber\PhoneNumberUtil; use PHPUnit\Framework\TestCase; use Prophecy\Argument; use Prophecy\PhpUnit\ProphecyTrait; -use Symfony\Component\Templating\EngineInterface; /** * @internal + * * @coversNothing */ final class DefaultShortMessageForCalendarBuilderTest extends TestCase @@ -51,8 +49,8 @@ final class DefaultShortMessageForCalendarBuilderTest extends TestCase { $calendar = new Calendar(); $calendar - ->setStartDate(new DateTimeImmutable('now')) - ->setEndDate($calendar->getStartDate()->add(new DateInterval('PT30M'))) + ->setStartDate(new \DateTimeImmutable('now')) + ->setEndDate($calendar->getStartDate()->add(new \DateInterval('PT30M'))) ->setMainUser($user = new User()) ->addPerson($person = new Person()) ->setSendSMS(false); diff --git a/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php b/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php index c6a3fb63c..08425bcf0 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php +++ b/src/Bundle/ChillCustomFieldsBundle/Command/CreateFieldsOnGroupCommand.php @@ -15,7 +15,6 @@ use Chill\CustomFieldsBundle\Entity\CustomField; use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup; use Chill\CustomFieldsBundle\Service\CustomFieldProvider; use Doctrine\ORM\EntityManager; -use RuntimeException; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Input\InputInterface; @@ -26,8 +25,6 @@ use Symfony\Component\Validator\Validator\ValidatorInterface; use Symfony\Component\Yaml\Exception\ParseException; use Symfony\Component\Yaml\Parser; -use function count; - /** * Class for the command 'chill:custom_fields:populate_group' that * Create custom fields from a yml file. @@ -40,9 +37,6 @@ class CreateFieldsOnGroupCommand extends Command /** * CreateFieldsOnGroupCommand constructor. - * - * @param $availableLanguages - * @param $customizablesEntities */ public function __construct( private readonly CustomFieldProvider $customFieldProvider, @@ -95,9 +89,9 @@ class CreateFieldsOnGroupCommand extends Command ->getRepository(\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class) ->findAll(); - if (count($customFieldsGroups) === 0) { + if (0 === \count($customFieldsGroups)) { $output->writeln('There aren\'t any CustomFieldsGroup recorded' - . ' Please create at least one.'); + .' Please create at least one.'); } $table = new Table($output); @@ -120,7 +114,7 @@ class CreateFieldsOnGroupCommand extends Command } } - throw new RuntimeException('The id does not match an existing CustomFieldsGroup'); + throw new \RuntimeException('The id does not match an existing CustomFieldsGroup'); } ); $customFieldsGroup = $helper->ask($input, $output, $question); @@ -135,6 +129,7 @@ class CreateFieldsOnGroupCommand extends Command ); $fields = $this->_addFields($customFieldsGroup, $fieldsInput, $output); + return 0; } @@ -145,12 +140,11 @@ class CreateFieldsOnGroupCommand extends Command $languages = $this->availableLanguages; foreach ($values['fields'] as $slug => $field) { - //check the cf type exists + // check the cf type exists $cfType = $this->customFieldProvider->getCustomFieldByType($field['type']); if (null === $cfType) { - throw new RuntimeException('the type ' . $field['type'] . ' ' - . 'does not exists'); + throw new \RuntimeException('the type '.$field['type'].' does not exists'); } $cf = new CustomField(); @@ -161,21 +155,21 @@ class CreateFieldsOnGroupCommand extends Command ->setType($field['type']) ->setCustomFieldsGroup($group); - //add to table + // add to table $names = []; foreach ($languages as $lang) { - //todo replace with service to find lang when available + // todo replace with service to find lang when available $names[] = $cf->getName()[$lang] ?? 'Not available in this language'; } if ($this->validator->validate($cf)) { $em->persist($cf); $output->writeln('Adding Custom Field of type ' - . $cf->getType() . "\t with slug " . $cf->getSlug() . - "\t and names : " . implode(', ', $names) . ''); + .$cf->getType()."\t with slug ".$cf->getSlug(). + "\t and names : ".implode(', ', $names).''); } else { - throw new RuntimeException('Error in field ' . $slug); + throw new \RuntimeException('Error in field '.$slug); } } @@ -187,13 +181,13 @@ class CreateFieldsOnGroupCommand extends Command $parser = new Parser(); if (!file_exists($path)) { - throw new RuntimeException('file does not exist'); + throw new \RuntimeException('file does not exist'); } try { $values = $parser->parse(file_get_contents($path)); } catch (ParseException $ex) { - throw new RuntimeException('The yaml file is not valid', 0, $ex); + throw new \RuntimeException('The yaml file is not valid', 0, $ex); } return $values; @@ -203,7 +197,7 @@ class CreateFieldsOnGroupCommand extends Command { $rows = []; $languages = $this->availableLanguages; - //gather entitites and create an array to access them easily + // gather entitites and create an array to access them easily $customizableEntities = []; foreach ($this->customizablesEntities as $entry) { @@ -213,14 +207,14 @@ class CreateFieldsOnGroupCommand extends Command array_walk( $customFieldsGroups, static function (CustomFieldsGroup $customFieldGroup, $key) use ($languages, &$rows, $customizableEntities) { - //set id and entity + // set id and entity $row = [ $customFieldGroup->getId(), $customizableEntities[$customFieldGroup->getEntity()], ]; foreach ($languages as $lang) { - //todo replace with service to find lang when available + // todo replace with service to find lang when available $row[] = $customFieldGroup->getName()[$lang] ?? 'Not available in this language'; } $rows[] = $row; diff --git a/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldController.php b/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldController.php index fff8e3216..3bba08b01 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldController.php +++ b/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldController.php @@ -26,6 +26,7 @@ class CustomFieldController extends AbstractController { /** * Creates a new CustomField entity. + * * @Route("/{_locale}/admin/customfield/new", name="customfield_new") */ public function createAction(Request $request) @@ -86,7 +87,7 @@ class CustomFieldController extends AbstractController { $entity = new CustomField(); - //add the custom field group if defined in URL + // add the custom field group if defined in URL $cfGroupId = $request->query->get('customFieldsGroup', null); if (null !== $cfGroupId) { @@ -95,8 +96,7 @@ class CustomFieldController extends AbstractController ->find($cfGroupId); if (!$cfGroup) { - throw $this->createNotFoundException('CustomFieldsGroup with id ' - . $cfGroupId . ' is not found !'); + throw $this->createNotFoundException('CustomFieldsGroup with id '.$cfGroupId.' is not found !'); } $entity->setCustomFieldsGroup($cfGroup); } @@ -111,6 +111,7 @@ class CustomFieldController extends AbstractController /** * Edits an existing CustomField entity. + * * @Route("/{_locale}/admin/customfield/update", name="customfield_update") */ public function updateAction(Request $request, mixed $id) diff --git a/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldsGroupController.php b/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldsGroupController.php index e6ac19b74..829ca5c55 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldsGroupController.php +++ b/src/Bundle/ChillCustomFieldsBundle/Controller/CustomFieldsGroupController.php @@ -27,7 +27,6 @@ use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Annotation\Route; use Symfony\Contracts\Translation\TranslatorInterface; -use function in_array; /** * Class CustomFieldsGroupController. @@ -41,6 +40,7 @@ class CustomFieldsGroupController extends AbstractController /** * Creates a new CustomFieldsGroup entity. + * * @Route("/{_locale}/admin/customfieldsgroup/create", name="customfieldsgroup_create") */ public function createAction(Request $request) @@ -71,6 +71,7 @@ class CustomFieldsGroupController extends AbstractController /** * Displays a form to edit an existing CustomFieldsGroup entity. + * * @Route("/{_locale}/admin/customfieldsgroup/{id}/edit", name="customfieldsgroup_edit") */ public function editAction(mixed $id) @@ -106,7 +107,7 @@ class CustomFieldsGroupController extends AbstractController $makeDefaultFormViews = []; foreach ($cfGroups as $group) { - if (!in_array($group->getId(), $defaultGroups, true)) { + if (!\in_array($group->getId(), $defaultGroups, true)) { $makeDefaultFormViews[$group->getId()] = $this->createMakeDefaultForm($group)->createView(); } } @@ -120,6 +121,7 @@ class CustomFieldsGroupController extends AbstractController /** * Set the CustomField Group with id $cFGroupId as default. + * * @Route("/{_locale}/admin/customfieldsgroup/makedefault", name="customfieldsgroup_makedefault") */ public function makeDefaultAction(Request $request) @@ -134,9 +136,7 @@ class CustomFieldsGroupController extends AbstractController $cFGroup = $em->getRepository(\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class)->findOneById($cFGroupId); if (!$cFGroup) { - throw $this - ->createNotFoundException('customFieldsGroup not found with ' - . "id {$cFGroupId}"); + throw $this->createNotFoundException('customFieldsGroup not found with '."id {$cFGroupId}"); } $cFDefaultGroup = $em->getRepository(\Chill\CustomFieldsBundle\Entity\CustomFieldsDefaultGroup::class) @@ -207,7 +207,7 @@ class CustomFieldsGroupController extends AbstractController $this->get('twig.loader') ->addPath( - __DIR__ . '/../Tests/Fixtures/App/app/Resources/views/', + __DIR__.'/../Tests/Fixtures/App/app/Resources/views/', $namespace = 'test' ); @@ -219,8 +219,8 @@ class CustomFieldsGroupController extends AbstractController ]); } - //dump($form->getData()); - //dump(json_enccode($form->getData())); + // dump($form->getData()); + // dump(json_enccode($form->getData())); } return $this @@ -233,7 +233,6 @@ class CustomFieldsGroupController extends AbstractController * Finds and displays a CustomFieldsGroup entity. * * @Route("/{_locale}/admin/customfieldsgroup/{id}/show", name="customfieldsgroup/show") - * */ public function showAction(mixed $id) { @@ -294,8 +293,7 @@ class CustomFieldsGroupController extends AbstractController { $fieldChoices = []; - foreach ($this->customFieldProvider->getAllFields() - as $key => $customType) { + foreach ($this->customFieldProvider->getAllFields() as $key => $customType) { $fieldChoices[$key] = $customType->getName(); } @@ -361,11 +359,9 @@ class CustomFieldsGroupController extends AbstractController /** * create a form to make the group default. * - * @param CustomFieldsGroup $group - * * @return \Symfony\Component\Form\Form */ - private function createMakeDefaultForm(?CustomFieldsGroup $group = null) + private function createMakeDefaultForm(CustomFieldsGroup $group = null) { return $this->createFormBuilder($group, [ 'method' => 'POST', @@ -387,8 +383,8 @@ class CustomFieldsGroupController extends AbstractController $em = $this->getDoctrine()->getManager(); $customFieldsGroupIds = $em->createQuery('SELECT g.id FROM ' - . 'ChillCustomFieldsBundle:CustomFieldsDefaultGroup d ' - . 'JOIN d.customFieldsGroup g') + .'ChillCustomFieldsBundle:CustomFieldsDefaultGroup d ' + .'JOIN d.customFieldsGroup g') ->getResult(Query::HYDRATE_SCALAR); $result = []; @@ -409,7 +405,7 @@ class CustomFieldsGroupController extends AbstractController private function getOptionsAvailable($entity) { $options = $this->getParameter('chill_custom_fields.' - . 'customizables_entities'); + .'customizables_entities'); foreach ($options as $key => $definition) { if ($definition['class'] === $entity) { diff --git a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldChoice.php b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldChoice.php index 2ee0a9c48..8fd91f27d 100644 --- a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldChoice.php +++ b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldChoice.php @@ -18,18 +18,9 @@ use Chill\CustomFieldsBundle\Form\Type\ChoicesType; use Chill\CustomFieldsBundle\Form\Type\ChoiceWithOtherType; use Chill\MainBundle\Form\Type\TranslatableStringFormType; use Chill\MainBundle\Templating\TranslatableStringHelper; -use LogicException; -use Symfony\Bridge\Twig\TwigEngine; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Contracts\Translation\TranslatorInterface; - use Twig\Environment; -use function array_key_exists; -use function count; -use function in_array; -use function is_array; -use function LogicException; class CustomFieldChoice extends AbstractCustomField { @@ -61,7 +52,7 @@ class CustomFieldChoice extends AbstractCustomField public function buildForm(FormBuilderInterface $builder, CustomField $customField) { - //prepare choices + // prepare choices $choices = []; $customFieldOptions = $customField->getOptions(); @@ -71,7 +62,7 @@ class CustomFieldChoice extends AbstractCustomField } } - //prepare $options + // prepare $options $options = [ 'multiple' => $customFieldOptions[self::MULTIPLE], 'choices' => array_combine(array_values($choices), array_keys($choices)), @@ -79,11 +70,11 @@ class CustomFieldChoice extends AbstractCustomField 'label' => $this->translatableStringHelper->localize($customField->getName()), ]; - //if allow_other = true + // if allow_other = true if (true === $customFieldOptions[self::ALLOW_OTHER]) { $otherValueLabel = null; - if (array_key_exists(self::OTHER_VALUE_LABEL, $customFieldOptions)) { + if (\array_key_exists(self::OTHER_VALUE_LABEL, $customFieldOptions)) { $otherValueLabel = $this->translatableStringHelper->localize( $customFieldOptions[self::OTHER_VALUE_LABEL] ); @@ -99,8 +90,8 @@ class CustomFieldChoice extends AbstractCustomField ) ->addModelTransformer(new CustomFieldDataTransformer($this, $customField)) ); - } else { //if allow_other = false - //we add the 'expanded' to options + } else { // if allow_other = false + // we add the 'expanded' to options $options['expanded'] = $customFieldOptions[self::EXPANDED]; $builder->add( @@ -164,7 +155,7 @@ class CustomFieldChoice extends AbstractCustomField return $serialized; } - public function extractOtherValue(CustomField $cf, ?array $data = null) + public function extractOtherValue(CustomField $cf, array $data = null) { return $data['_other']; } @@ -185,7 +176,7 @@ class CustomFieldChoice extends AbstractCustomField if ($this->allowOtherChoice($cf)) { $labels = $cf->getOptions()[self::OTHER_VALUE_LABEL]; - if (!is_array($labels) || count($labels) === 0) { + if (!\is_array($labels) || 0 === \count($labels)) { $labels['back'] = 'other value'; } $choices['_other'] = $this->translatableStringHelper @@ -210,8 +201,8 @@ class CustomFieldChoice extends AbstractCustomField * * Used in list exports. * - * @param string $choiceSlug the slug of the choice we want to know if it was checked - * @param array|string $data the data of the field + * @param string $choiceSlug the slug of the choice we want to know if it was checked + * @param array|string $data the data of the field * * @return bool */ @@ -223,10 +214,10 @@ class CustomFieldChoice extends AbstractCustomField if ($cf->getOptions()[self::MULTIPLE]) { if ($cf->getOptions()[self::ALLOW_OTHER]) { - return in_array($choiceSlug, $this->deserialize($data, $cf)['_choices'], true); + return \in_array($choiceSlug, $this->deserialize($data, $cf)['_choices'], true); } - return in_array($choiceSlug, $this->deserialize($data, $cf), true); + return \in_array($choiceSlug, $this->deserialize($data, $cf), true); } if ($cf->getOptions()[self::ALLOW_OTHER]) { @@ -243,9 +234,9 @@ class CustomFieldChoice extends AbstractCustomField } // if multiple choice OR multiple/single choice with other - if (is_array($value)) { + if (\is_array($value)) { // if allow other - if (array_key_exists('_choices', $value)) { + if (\array_key_exists('_choices', $value)) { if (null === $value['_choices']) { return true; } @@ -253,7 +244,7 @@ class CustomFieldChoice extends AbstractCustomField return empty($value['_choices']); } // we do not have 'allow other' - if (count($value) === 1) { + if (1 === \count($value)) { return empty($value[0]); } @@ -262,7 +253,7 @@ class CustomFieldChoice extends AbstractCustomField return empty($value); - throw LogicException('This case is not expected.'); + throw \LogicException('This case is not expected.'); } public function isMultiple(CustomField $cf) @@ -273,19 +264,16 @@ class CustomFieldChoice extends AbstractCustomField /** * @internal this function is able to receive data whichever is the value of "other", "multiple" * - * @param mixed $value - * @param mixed $documentType - * * @return string html representation */ public function render($value, CustomField $customField, $documentType = 'html') { - //extract the data. They are under a _choice key if they are stored with allow_other + // extract the data. They are under a _choice key if they are stored with allow_other $data = $value['_choices'] ?? $value; - $selected = (is_array($data)) ? $data : [$data]; + $selected = (\is_array($data)) ? $data : [$data]; $choices = $customField->getOptions()[self::CHOICES]; - if (in_array('_other', $selected, true)) { + if (\in_array('_other', $selected, true)) { $choices[] = ['name' => $value['_other'], 'slug' => '_other']; } @@ -323,7 +311,7 @@ class CustomFieldChoice extends AbstractCustomField $value = $this->guessValue($serialized); // set in an array : we want a multiple - $fixedValue = is_array($value) ? $value : [$value]; + $fixedValue = \is_array($value) ? $value : [$value]; if ($allowOther) { return $this->deserializeWithAllowOther($serialized, $fixedValue); @@ -337,9 +325,9 @@ class CustomFieldChoice extends AbstractCustomField $value = $this->guessValue($serialized); // set in a single value. We must have a single string - $fixedValue = is_array($value) ? + $fixedValue = \is_array($value) ? // check if the array has an element, if not replace by empty string - count($value) > 0 ? end($value) : '' + \count($value) > 0 ? end($value) : '' : $value; @@ -372,16 +360,17 @@ class CustomFieldChoice extends AbstractCustomField return null; } - if (!is_array($value)) { + if (!\is_array($value)) { return $value; } // we have a field with "allow other" - if (array_key_exists('_choices', $value)) { + if (\array_key_exists('_choices', $value)) { return $value['_choices']; } + // we have a field with "multiple" return $value; - throw LogicException('This case is not expected.'); + throw \LogicException('This case is not expected.'); } } diff --git a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldDate.php b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldDate.php index 5e0592f8e..a535f805e 100644 --- a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldDate.php +++ b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldDate.php @@ -15,9 +15,6 @@ use Chill\CustomFieldsBundle\Entity\CustomField; use Chill\CustomFieldsBundle\Form\DataTransformer\CustomFieldDataTransformer; use Chill\MainBundle\Form\Type\ChillDateType; use Chill\MainBundle\Templating\TranslatableStringHelper; -use DateTime; -use Exception; -use Symfony\Bundle\TwigBundle\TwigEngine; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; @@ -34,7 +31,7 @@ use Twig\Environment; */ class CustomFieldDate extends AbstractCustomField { - final public const DATE_FORMAT = DateTime::RFC3339; + final public const DATE_FORMAT = \DateTime::RFC3339; final public const FORMAT = 'format'; @@ -71,8 +68,8 @@ class CustomFieldDate extends AbstractCustomField { $validatorFunction = static function ($value, ExecutionContextInterface $context) { try { - $date = new DateTime($value); - } catch (Exception) { + $date = new \DateTime($value); + } catch (\Exception) { $context->buildViolation('The expression "%expression%" is invalid', [ '%expression%' => $value, ]) @@ -107,7 +104,7 @@ class CustomFieldDate extends AbstractCustomField return null; } - return DateTime::createFromFormat(self::DATE_FORMAT, $serialized); + return \DateTime::createFromFormat(self::DATE_FORMAT, $serialized); } public function getName() @@ -129,7 +126,7 @@ class CustomFieldDate extends AbstractCustomField default: $template = 'ChillCustomFieldsBundle:CustomFieldsRendering:date.' - . $documentType . '.twig'; + .$documentType.'.twig'; return $this->templating ->render($template, [ @@ -165,7 +162,7 @@ class CustomFieldDate extends AbstractCustomField // add required $fieldOptions['required'] = false; - //add label + // add label $fieldOptions['label'] = $this->translatableStringHelper->localize($customField->getName()); // add constraints if required @@ -176,8 +173,8 @@ class CustomFieldDate extends AbstractCustomField return; } - $value = DateTime::createFromFormat(self::DATE_FORMAT, $timestamp); - $after = new DateTime($options[self::MIN]); + $value = \DateTime::createFromFormat(self::DATE_FORMAT, $timestamp); + $after = new \DateTime($options[self::MIN]); if ($value < $after) { $context @@ -197,8 +194,8 @@ class CustomFieldDate extends AbstractCustomField return; } - $value = DateTime::createFromFormat(self::DATE_FORMAT, $timestamp); - $before = new DateTime($options[self::MAX]); + $value = \DateTime::createFromFormat(self::DATE_FORMAT, $timestamp); + $before = new \DateTime($options[self::MAX]); if ($value > $before) { $context diff --git a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldInterface.php b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldInterface.php index 43902a7e3..ff89c04d2 100644 --- a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldInterface.php +++ b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldInterface.php @@ -21,7 +21,7 @@ interface CustomFieldInterface * user. * * @param \Chill\CustomFieldsBundle\CustomField\FormBuilderInterface $builder - * @param \Chill\CustomFieldsBundle\CustomField\CustomField $customField + * @param \Chill\CustomFieldsBundle\CustomField\CustomField $customField * * @return \Symfony\Component\Form\FormTypeInterface the form type */ @@ -42,7 +42,6 @@ interface CustomFieldInterface * value which may be used in the process. * * @param \Chill\CustomFieldsBundle\CustomField\CustomField $customField - * @param mixed $serialized */ public function deserialize($serialized, CustomField $customField); @@ -58,9 +57,8 @@ interface CustomFieldInterface /** * Return a repsentation of the value of the CustomField. * - * @param mixed $value the raw value, **not deserialized** (= as stored in the db) + * @param mixed $value the raw value, **not deserialized** (= as stored in the db) * @param \Chill\CustomFieldsBundle\CustomField\CustomField $customField - * @param mixed $documentType * * @return string an html representation of the value */ @@ -69,7 +67,6 @@ interface CustomFieldInterface /** * Transform the value into a format that can be stored in DB. * - * @param mixed $value * @param \Chill\CustomFieldsBundle\CustomField\CustomField $customField */ public function serialize($value, CustomField $customField); diff --git a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php index e7886daff..885a02f2d 100644 --- a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php +++ b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldLongChoice.php @@ -15,19 +15,11 @@ use Chill\CustomFieldsBundle\Entity\CustomField; use Chill\CustomFieldsBundle\Entity\CustomFieldLongChoice\Option; use Chill\CustomFieldsBundle\EntityRepository\CustomFieldLongChoice\OptionRepository; use Chill\CustomFieldsBundle\Form\DataTransformer\CustomFieldDataTransformer; -use Chill\FamilyMembersBundle\Templating\Twig; use Chill\MainBundle\Form\Type\Select2ChoiceType; use Chill\MainBundle\Templating\TranslatableStringHelper; -use LogicException; -use Symfony\Bridge\Twig\TwigEngine; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Templating\EngineInterface; -use function get_class; -use function gettype; -use function is_object; - class CustomFieldLongChoice extends AbstractCustomField { final public const KEY = 'key'; @@ -46,7 +38,7 @@ class CustomFieldLongChoice extends AbstractCustomField false, true ); - //create a local copy of translatable string helper + // create a local copy of translatable string helper $translatableStringHelper = $this->translatableStringHelper; $builder->add($customField->getSlug(), Select2ChoiceType::class, [ 'choices' => $entries, @@ -73,7 +65,7 @@ class CustomFieldLongChoice extends AbstractCustomField public function buildOptionsForm(FormBuilderInterface $builder) { - //create a selector between different keys + // create a selector between different keys $keys = $this->optionRepository->getKeys(); $choices = []; @@ -105,7 +97,7 @@ class CustomFieldLongChoice extends AbstractCustomField { $option = $this->deserialize($value, $customField); $template = 'ChillCustomFieldsBundle:CustomFieldsRendering:choice_long.' - . $documentType . '.twig'; + .$documentType.'.twig'; return $this->templating ->render($template, [ @@ -120,9 +112,7 @@ class CustomFieldLongChoice extends AbstractCustomField } if (!$value instanceof Option) { - throw new LogicException('the value should be an instance of ' - . 'Chill\CustomFieldsBundle\Entity\CustomFieldLongChoice\Option, ' - . is_object($value) ? $value::class : gettype($value) . ' given'); + throw new \LogicException('the value should be an instance of Chill\CustomFieldsBundle\Entity\CustomFieldLongChoice\Option, '.\is_object($value) ? $value::class : \gettype($value).' given'); } // we place the id in array, to allow in the future multiple select diff --git a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldNumber.php b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldNumber.php index 2071c3606..979d96540 100644 --- a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldNumber.php +++ b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldNumber.php @@ -13,7 +13,6 @@ namespace Chill\CustomFieldsBundle\CustomFields; use Chill\CustomFieldsBundle\Entity\CustomField; use Chill\MainBundle\Templating\TranslatableStringHelper; -use Symfony\Bundle\TwigBundle\TwigEngine; use Symfony\Component\Form\Extension\Core\Type\IntegerType; use Symfony\Component\Form\Extension\Core\Type\NumberType; use Symfony\Component\Form\Extension\Core\Type\TextType; @@ -49,10 +48,10 @@ class CustomFieldNumber extends AbstractCustomField { $options = $customField->getOptions(); - //select the type depending to the SCALE + // select the type depending to the SCALE $type = (0 === $options[self::SCALE] || null === $options[self::SCALE]) ? IntegerType::class : NumberType::class; - //'integer' : 'number'; + // 'integer' : 'number'; $fieldOptions = $this->prepareFieldOptions($customField, $type); @@ -97,7 +96,7 @@ class CustomFieldNumber extends AbstractCustomField public function render($value, CustomField $customField, $documentType = 'html') { $template = 'ChillCustomFieldsBundle:CustomFieldsRendering:number.' - . $documentType . '.twig'; + .$documentType.'.twig'; $options = $customField->getOptions(); return $this->templating @@ -132,7 +131,7 @@ class CustomFieldNumber extends AbstractCustomField // add required $fieldOptions['required'] = false; - //add label + // add label $fieldOptions['label'] = $this->translatableStringHelper->localize($customField->getName()); // add constraints if required diff --git a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldText.php b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldText.php index 0584d770d..f95048e21 100644 --- a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldText.php +++ b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldText.php @@ -13,16 +13,12 @@ namespace Chill\CustomFieldsBundle\CustomFields; use Chill\CustomFieldsBundle\Entity\CustomField; use Chill\MainBundle\Templating\TranslatableStringHelper; -use Symfony\Bundle\TwigBundle\TwigEngine; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\IntegerType; use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\HttpFoundation\RequestStack; - use Twig\Environment; -use function array_key_exists; class CustomFieldText extends AbstractCustomField { @@ -51,7 +47,7 @@ class CustomFieldText extends AbstractCustomField $attrArray = []; if ( - array_key_exists(self::MULTIPLE_CF_INLINE, $options) + \array_key_exists(self::MULTIPLE_CF_INLINE, $options) && $options[self::MULTIPLE_CF_INLINE] ) { $attrArray['class'] = 'multiple-cf-inline'; diff --git a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldTitle.php b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldTitle.php index 305cc6c3e..302e04350 100644 --- a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldTitle.php +++ b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldTitle.php @@ -14,10 +14,8 @@ namespace Chill\CustomFieldsBundle\CustomFields; use Chill\CustomFieldsBundle\Entity\CustomField; use Chill\CustomFieldsBundle\Form\Type\CustomFieldsTitleType; use Chill\MainBundle\Templating\TranslatableStringHelper; -use Symfony\Bundle\TwigBundle\TwigEngine; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\HttpFoundation\RequestStack; use Twig\Environment; class CustomFieldTitle extends AbstractCustomField diff --git a/src/Bundle/ChillCustomFieldsBundle/DataFixtures/ORM/LoadOption.php b/src/Bundle/ChillCustomFieldsBundle/DataFixtures/ORM/LoadOption.php index 8b827b535..f95991b7c 100644 --- a/src/Bundle/ChillCustomFieldsBundle/DataFixtures/ORM/LoadOption.php +++ b/src/Bundle/ChillCustomFieldsBundle/DataFixtures/ORM/LoadOption.php @@ -73,7 +73,7 @@ class LoadOption extends AbstractFixture implements OrderedFixtureInterface ->setText($text) ->setParent($parent) ->setActive(true) - ->setInternalKey($parent->getKey() . '-' . $this->counter); + ->setInternalKey($parent->getKey().'-'.$this->counter); } private function loadingCompanies(ObjectManager $manager) @@ -103,7 +103,7 @@ class LoadOption extends AbstractFixture implements OrderedFixtureInterface ->setKey('company'); $manager->persist($parent); - //Load children + // Load children $expected_nb_children = random_int(10, 50); for ($i = 0; $i < $expected_nb_children; ++$i) { @@ -143,7 +143,7 @@ class LoadOption extends AbstractFixture implements OrderedFixtureInterface ->setKey('word'); $manager->persist($parent); - //Load children + // Load children $expected_nb_children = random_int(10, 50); for ($i = 0; $i < $expected_nb_children; ++$i) { diff --git a/src/Bundle/ChillCustomFieldsBundle/DependencyInjection/ChillCustomFieldsExtension.php b/src/Bundle/ChillCustomFieldsBundle/DependencyInjection/ChillCustomFieldsExtension.php index 3a188f4c1..724fd01ca 100644 --- a/src/Bundle/ChillCustomFieldsBundle/DependencyInjection/ChillCustomFieldsExtension.php +++ b/src/Bundle/ChillCustomFieldsBundle/DependencyInjection/ChillCustomFieldsExtension.php @@ -29,15 +29,15 @@ class ChillCustomFieldsExtension extends Extension implements PrependExtensionIn $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); - $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../config')); + $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../config')); $loader->load('services.yaml'); $loader->load('services/fixtures.yaml'); $loader->load('services/controller.yaml'); $loader->load('services/command.yaml'); $loader->load('services/menu.yaml'); - //add at least a blank array at 'customizable_entities' options - //$customizable_entities = (isset($config['customizables_entities']) + // add at least a blank array at 'customizable_entities' options + // $customizable_entities = (isset($config['customizables_entities']) // && $config['customizables_entities'] !== FALSE) // ? $config['customizables_entities'] : array(); @@ -64,7 +64,7 @@ class ChillCustomFieldsExtension extends Extension implements PrependExtensionIn ]; $container->prependExtensionConfig('twig', $twigConfig); - //add routes for custom bundle + // add routes for custom bundle $container->prependExtensionConfig('chill_main', [ 'routing' => [ 'resources' => [ diff --git a/src/Bundle/ChillCustomFieldsBundle/DependencyInjection/CustomFieldCompilerPass.php b/src/Bundle/ChillCustomFieldsBundle/DependencyInjection/CustomFieldCompilerPass.php index 0cf1a67eb..6e68a248a 100644 --- a/src/Bundle/ChillCustomFieldsBundle/DependencyInjection/CustomFieldCompilerPass.php +++ b/src/Bundle/ChillCustomFieldsBundle/DependencyInjection/CustomFieldCompilerPass.php @@ -11,7 +11,6 @@ declare(strict_types=1); namespace Chill\CustomFieldsBundle\DependencyInjection; -use LogicException; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; @@ -21,8 +20,7 @@ class CustomFieldCompilerPass implements CompilerPassInterface public function process(ContainerBuilder $container) { if (!$container->hasDefinition('chill.custom_field.provider')) { - throw new LogicException('service chill.custom_field.provider ' - . 'is not defined.'); + throw new \LogicException('service chill.custom_field.provider is not defined.'); } $definition = $container->getDefinition( diff --git a/src/Bundle/ChillCustomFieldsBundle/Entity/CustomField.php b/src/Bundle/ChillCustomFieldsBundle/Entity/CustomField.php index 509f53a38..b75d23e5e 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Entity/CustomField.php +++ b/src/Bundle/ChillCustomFieldsBundle/Entity/CustomField.php @@ -17,7 +17,9 @@ use Doctrine\ORM\Mapping as ORM; * CustomField. * * @ORM\Entity + * * @ORM\Table(name="customfield") + * * @ORM\HasLifecycleCallbacks */ class CustomField @@ -39,10 +41,10 @@ class CustomField private ?\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup $customFieldGroup = null; /** - * @var int - * * @ORM\Id + * * @ORM\Column(name="id", type="integer") + * * @ORM\GeneratedValue(strategy="AUTO") */ private ?int $id = null; @@ -60,8 +62,6 @@ class CustomField private array $options = []; /** - * @var float - * * @ORM\Column(type="float") */ private ?float $ordering = null; @@ -72,15 +72,11 @@ class CustomField private false $required = false; /** - * @var string - * * @ORM\Column(type="string", length=255) */ private ?string $slug = null; /** - * @var string - * * @ORM\Column(type="string", length=255) */ private ?string $type = null; @@ -214,11 +210,9 @@ class CustomField /** * Set customFieldGroup. * - * @param CustomFieldsGroup $customFieldGroup - * * @return CustomField */ - public function setCustomFieldsGroup(?CustomFieldsGroup $customFieldGroup = null) + public function setCustomFieldsGroup(CustomFieldsGroup $customFieldGroup = null) { $this->customFieldGroup = $customFieldGroup; @@ -273,8 +267,6 @@ class CustomField } /** - * @param $slug - * * @return $this */ public function setSlug($slug) diff --git a/src/Bundle/ChillCustomFieldsBundle/Entity/CustomFieldLongChoice/Option.php b/src/Bundle/ChillCustomFieldsBundle/Entity/CustomFieldLongChoice/Option.php index 964160de6..b6f371c8e 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Entity/CustomFieldLongChoice/Option.php +++ b/src/Bundle/ChillCustomFieldsBundle/Entity/CustomFieldLongChoice/Option.php @@ -18,6 +18,7 @@ use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity( * repositoryClass="Chill\CustomFieldsBundle\EntityRepository\CustomFieldLongChoice\OptionRepository") + * * @ORM\Table(name="custom_field_long_choice_options") */ class Option @@ -29,6 +30,7 @@ class Option /** * @var Collection