From 318599334e77c8b8db3d41db9cd064e165abdc20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 28 Feb 2023 21:43:28 +0100 Subject: [PATCH] Fix phpstan issues --- phpstan-baseline-level-3.neon | 123 ------------------ phpstan-baseline-level-4.neon | 10 -- .../Menu/AccompanyingCourseMenuBuilder.php | 3 + .../Menu/AdminMenuBuilder.php | 3 + .../Menu/PersonMenuBuilder.php | 6 +- .../Service/DocGenerator/CalendarContext.php | 9 +- .../DocGenerator/CalendarContextInterface.php | 18 +-- .../Context/DocGeneratorContextInterface.php | 9 +- ...eneratorContextWithPublicFormInterface.php | 23 +++- .../ORM/LoadDocGeneratorTemplate.php | 2 +- .../Service/Generator/Generator.php | 4 +- .../RelatedEntityNotFoundException.php | 2 +- .../Service/Messenger/OnGenerationFails.php | 5 +- .../Doctrine/Type/NativeDateIntervalType.php | 3 + .../Routing/LocalMenuBuilderInterface.php | 10 ++ .../Menu/PersonMenuBuilder.php | 2 + .../AccompanyingPeriodContext.php | 8 +- .../AccompanyingPeriodWorkContext.php | 17 +-- ...ccompanyingPeriodWorkEvaluationContext.php | 16 +-- .../Service/DocGenerator/PersonContext.php | 3 - .../DocGenerator/PersonContextInterface.php | 13 +- 21 files changed, 81 insertions(+), 208 deletions(-) diff --git a/phpstan-baseline-level-3.neon b/phpstan-baseline-level-3.neon index 4259ab0b2..c5e4d32fc 100644 --- a/phpstan-baseline-level-3.neon +++ b/phpstan-baseline-level-3.neon @@ -80,70 +80,6 @@ parameters: count: 1 path: src/Bundle/ChillCalendarBundle/Security/Voter/InviteVoter.php - - - message: "#^Parameter \\#2 \\$entity \\(Chill\\\\CalendarBundle\\\\Entity\\\\Calendar\\) of method Chill\\\\CalendarBundle\\\\Service\\\\DocGenerator\\\\CalendarContext\\:\\:getFormData\\(\\) should be contravariant with parameter \\$entity \\(mixed\\) of method Chill\\\\DocGeneratorBundle\\\\Context\\\\DocGeneratorContextWithPublicFormInterface\\:\\:getFormData\\(\\)$#" - count: 1 - path: src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContext.php - - - - message: "#^Parameter \\#2 \\$entity \\(Chill\\\\CalendarBundle\\\\Entity\\\\Calendar\\) of method Chill\\\\CalendarBundle\\\\Service\\\\DocGenerator\\\\CalendarContext\\:\\:hasPublicForm\\(\\) should be contravariant with parameter \\$entity \\(mixed\\) of method Chill\\\\DocGeneratorBundle\\\\Context\\\\DocGeneratorContextWithPublicFormInterface\\:\\:hasPublicForm\\(\\)$#" - count: 1 - path: src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContext.php - - - - message: "#^Parameter \\#3 \\$contextGenerationData \\(array\\{mainPerson\\?\\: Chill\\\\PersonBundle\\\\Entity\\\\Person, thirdParty\\?\\: Chill\\\\ThirdPartyBundle\\\\Entity\\\\ThirdParty, title\\: string\\}\\) of method Chill\\\\CalendarBundle\\\\Service\\\\DocGenerator\\\\CalendarContext\\:\\:getData\\(\\) should be contravariant with parameter \\$contextGenerationData \\(array\\) of method Chill\\\\CalendarBundle\\\\Service\\\\DocGenerator\\\\CalendarContextInterface\\:\\:getData\\(\\)$#" - count: 1 - path: src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContext.php - - - - message: "#^Parameter \\#3 \\$contextGenerationData \\(array\\{mainPerson\\?\\: Chill\\\\PersonBundle\\\\Entity\\\\Person, thirdParty\\?\\: Chill\\\\ThirdPartyBundle\\\\Entity\\\\ThirdParty, title\\: string\\}\\) of method Chill\\\\CalendarBundle\\\\Service\\\\DocGenerator\\\\CalendarContext\\:\\:getData\\(\\) should be contravariant with parameter \\$contextGenerationData \\(array\\) of method Chill\\\\DocGeneratorBundle\\\\Context\\\\DocGeneratorContextInterface\\:\\:getData\\(\\)$#" - count: 3 - path: src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContext.php - - - - message: "#^Parameter \\#3 \\$entity \\(Chill\\\\CalendarBundle\\\\Entity\\\\Calendar\\) of method Chill\\\\CalendarBundle\\\\Service\\\\DocGenerator\\\\CalendarContext\\:\\:buildPublicForm\\(\\) should be contravariant with parameter \\$entity \\(mixed\\) of method Chill\\\\DocGeneratorBundle\\\\Context\\\\DocGeneratorContextWithPublicFormInterface\\:\\:buildPublicForm\\(\\)$#" - count: 1 - path: src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContext.php - - - - message: "#^Parameter \\#3 \\$entity \\(Chill\\\\CalendarBundle\\\\Entity\\\\Calendar\\) of method Chill\\\\CalendarBundle\\\\Service\\\\DocGenerator\\\\CalendarContext\\:\\:storeGenerated\\(\\) should be contravariant with parameter \\$entity \\(object\\) of method Chill\\\\DocGeneratorBundle\\\\Context\\\\DocGeneratorContextInterface\\:\\:storeGenerated\\(\\)$#" - count: 3 - path: src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContext.php - - - - message: "#^Parameter \\#4 \\$contextGenerationData \\(array\\{mainPerson\\?\\: Chill\\\\PersonBundle\\\\Entity\\\\Person, thirdParty\\?\\: Chill\\\\ThirdPartyBundle\\\\Entity\\\\ThirdParty, title\\: string\\}\\) of method Chill\\\\CalendarBundle\\\\Service\\\\DocGenerator\\\\CalendarContext\\:\\:storeGenerated\\(\\) should be contravariant with parameter \\$contextGenerationData \\(array\\) of method Chill\\\\CalendarBundle\\\\Service\\\\DocGenerator\\\\CalendarContextInterface\\:\\:storeGenerated\\(\\)$#" - count: 1 - path: src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContext.php - - - - message: "#^Parameter \\#4 \\$contextGenerationData \\(array\\{mainPerson\\?\\: Chill\\\\PersonBundle\\\\Entity\\\\Person, thirdParty\\?\\: Chill\\\\ThirdPartyBundle\\\\Entity\\\\ThirdParty, title\\: string\\}\\) of method Chill\\\\CalendarBundle\\\\Service\\\\DocGenerator\\\\CalendarContext\\:\\:storeGenerated\\(\\) should be contravariant with parameter \\$contextGenerationData \\(array\\) of method Chill\\\\DocGeneratorBundle\\\\Context\\\\DocGeneratorContextInterface\\:\\:storeGenerated\\(\\)$#" - count: 3 - path: src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContext.php - - - - message: "#^Parameter \\#2 \\$entity \\(Chill\\\\CalendarBundle\\\\Entity\\\\Calendar\\) of method Chill\\\\CalendarBundle\\\\Service\\\\DocGenerator\\\\CalendarContextInterface\\:\\:getData\\(\\) should be contravariant with parameter \\$entity \\(mixed\\) of method Chill\\\\DocGeneratorBundle\\\\Context\\\\DocGeneratorContextInterface\\:\\:getData\\(\\)$#" - count: 3 - path: src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContextInterface.php - - - - message: "#^Parameter \\#2 \\$entity \\(Chill\\\\CalendarBundle\\\\Entity\\\\Calendar\\) of method Chill\\\\CalendarBundle\\\\Service\\\\DocGenerator\\\\CalendarContextInterface\\:\\:getFormData\\(\\) should be contravariant with parameter \\$entity \\(mixed\\) of method Chill\\\\DocGeneratorBundle\\\\Context\\\\DocGeneratorContextWithPublicFormInterface\\:\\:getFormData\\(\\)$#" - count: 1 - path: src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContextInterface.php - - - - message: "#^Parameter \\#2 \\$entity \\(Chill\\\\CalendarBundle\\\\Entity\\\\Calendar\\) of method Chill\\\\CalendarBundle\\\\Service\\\\DocGenerator\\\\CalendarContextInterface\\:\\:hasPublicForm\\(\\) should be contravariant with parameter \\$entity \\(mixed\\) of method Chill\\\\DocGeneratorBundle\\\\Context\\\\DocGeneratorContextWithPublicFormInterface\\:\\:hasPublicForm\\(\\)$#" - count: 1 - path: src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContextInterface.php - - - - message: "#^Parameter \\#3 \\$entity \\(Chill\\\\CalendarBundle\\\\Entity\\\\Calendar\\) of method Chill\\\\CalendarBundle\\\\Service\\\\DocGenerator\\\\CalendarContextInterface\\:\\:buildPublicForm\\(\\) should be contravariant with parameter \\$entity \\(mixed\\) of method Chill\\\\DocGeneratorBundle\\\\Context\\\\DocGeneratorContextWithPublicFormInterface\\:\\:buildPublicForm\\(\\)$#" - count: 1 - path: src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContextInterface.php - - - - message: "#^Parameter \\#3 \\$entity \\(Chill\\\\CalendarBundle\\\\Entity\\\\Calendar\\) of method Chill\\\\CalendarBundle\\\\Service\\\\DocGenerator\\\\CalendarContextInterface\\:\\:storeGenerated\\(\\) should be contravariant with parameter \\$entity \\(object\\) of method Chill\\\\DocGeneratorBundle\\\\Context\\\\DocGeneratorContextInterface\\:\\:storeGenerated\\(\\)$#" - count: 3 - path: src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContextInterface.php - message: "#^Return type \\(int\\|void\\|null\\) of method Chill\\\\CustomFieldsBundle\\\\Command\\\\CreateFieldsOnGroupCommand\\:\\:execute\\(\\) should be covariant with return type \\(int\\) of method Symfony\\\\Component\\\\Console\\\\Command\\\\Command\\:\\:execute\\(\\)$#" @@ -840,65 +776,6 @@ parameters: count: 2 path: src/Bundle/ChillPersonBundle/Serializer/Normalizer/WorkflowNormalizer.php - - - message: "#^Parameter \\#3 \\$entity \\(Chill\\\\PersonBundle\\\\Entity\\\\AccompanyingPeriod\\) of method Chill\\\\PersonBundle\\\\Service\\\\DocGenerator\\\\AccompanyingPeriodContext\\:\\:buildPublicForm\\(\\) should be contravariant with parameter \\$entity \\(mixed\\) of method Chill\\\\DocGeneratorBundle\\\\Context\\\\DocGeneratorContextWithPublicFormInterface\\:\\:buildPublicForm\\(\\)$#" - count: 1 - path: src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php - - - - message: "#^Parameter \\#3 \\$entity \\(Chill\\\\PersonBundle\\\\Entity\\\\AccompanyingPeriod\\) of method Chill\\\\PersonBundle\\\\Service\\\\DocGenerator\\\\AccompanyingPeriodContext\\:\\:storeGenerated\\(\\) should be contravariant with parameter \\$entity \\(object\\) of method Chill\\\\DocGeneratorBundle\\\\Context\\\\DocGeneratorContextInterface\\:\\:storeGenerated\\(\\)$#" - count: 3 - path: src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php - - - - message: "#^Parameter \\#2 \\$entity \\(Chill\\\\PersonBundle\\\\Entity\\\\AccompanyingPeriod\\\\AccompanyingPeriodWorkEvaluation\\) of method Chill\\\\PersonBundle\\\\Service\\\\DocGenerator\\\\AccompanyingPeriodWorkEvaluationContext\\:\\:getData\\(\\) should be contravariant with parameter \\$entity \\(mixed\\) of method Chill\\\\DocGeneratorBundle\\\\Context\\\\DocGeneratorContextInterface\\:\\:getData\\(\\)$#" - count: 3 - path: src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php - - - - message: "#^Parameter \\#2 \\$entity \\(Chill\\\\PersonBundle\\\\Entity\\\\AccompanyingPeriod\\\\AccompanyingPeriodWorkEvaluation\\) of method Chill\\\\PersonBundle\\\\Service\\\\DocGenerator\\\\AccompanyingPeriodWorkEvaluationContext\\:\\:getFormData\\(\\) should be contravariant with parameter \\$entity \\(mixed\\) of method Chill\\\\DocGeneratorBundle\\\\Context\\\\DocGeneratorContextWithPublicFormInterface\\:\\:getFormData\\(\\)$#" - count: 1 - path: src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php - - - - message: "#^Parameter \\#2 \\$entity \\(Chill\\\\PersonBundle\\\\Entity\\\\AccompanyingPeriod\\\\AccompanyingPeriodWorkEvaluation\\) of method Chill\\\\PersonBundle\\\\Service\\\\DocGenerator\\\\AccompanyingPeriodWorkEvaluationContext\\:\\:hasPublicForm\\(\\) should be contravariant with parameter \\$entity \\(mixed\\) of method Chill\\\\DocGeneratorBundle\\\\Context\\\\DocGeneratorContextWithPublicFormInterface\\:\\:hasPublicForm\\(\\)$#" - count: 1 - path: src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php - - - - message: "#^Parameter \\#3 \\$entity \\(Chill\\\\PersonBundle\\\\Entity\\\\AccompanyingPeriod\\\\AccompanyingPeriodWorkEvaluation\\) of method Chill\\\\PersonBundle\\\\Service\\\\DocGenerator\\\\AccompanyingPeriodWorkEvaluationContext\\:\\:buildPublicForm\\(\\) should be contravariant with parameter \\$entity \\(mixed\\) of method Chill\\\\DocGeneratorBundle\\\\Context\\\\DocGeneratorContextWithPublicFormInterface\\:\\:buildPublicForm\\(\\)$#" - count: 1 - path: src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php - - - - message: "#^Parameter \\#2 \\$entity \\(Chill\\\\PersonBundle\\\\Entity\\\\Person\\) of method Chill\\\\PersonBundle\\\\Service\\\\DocGenerator\\\\PersonContext\\:\\:hasPublicForm\\(\\) should be contravariant with parameter \\$entity \\(mixed\\) of method Chill\\\\DocGeneratorBundle\\\\Context\\\\DocGeneratorContextWithPublicFormInterface\\:\\:hasPublicForm\\(\\)$#" - count: 1 - path: src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php - - - - message: "#^Parameter \\#3 \\$entity \\(Chill\\\\PersonBundle\\\\Entity\\\\Person\\) of method Chill\\\\PersonBundle\\\\Service\\\\DocGenerator\\\\PersonContext\\:\\:buildPublicForm\\(\\) should be contravariant with parameter \\$entity \\(mixed\\) of method Chill\\\\DocGeneratorBundle\\\\Context\\\\DocGeneratorContextWithPublicFormInterface\\:\\:buildPublicForm\\(\\)$#" - count: 1 - path: src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php - - - - message: "#^Parameter \\#3 \\$entity \\(Chill\\\\PersonBundle\\\\Entity\\\\Person\\) of method Chill\\\\PersonBundle\\\\Service\\\\DocGenerator\\\\PersonContext\\:\\:storeGenerated\\(\\) should be contravariant with parameter \\$entity \\(object\\) of method Chill\\\\DocGeneratorBundle\\\\Context\\\\DocGeneratorContextInterface\\:\\:storeGenerated\\(\\)$#" - count: 3 - path: src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php - - - - message: "#^Parameter \\#2 \\$entity \\(Chill\\\\PersonBundle\\\\Entity\\\\Person\\) of method Chill\\\\PersonBundle\\\\Service\\\\DocGenerator\\\\PersonContextInterface\\:\\:hasPublicForm\\(\\) should be contravariant with parameter \\$entity \\(mixed\\) of method Chill\\\\DocGeneratorBundle\\\\Context\\\\DocGeneratorContextWithPublicFormInterface\\:\\:hasPublicForm\\(\\)$#" - count: 1 - path: src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContextInterface.php - - - - message: "#^Parameter \\#3 \\$entity \\(Chill\\\\PersonBundle\\\\Entity\\\\Person\\) of method Chill\\\\PersonBundle\\\\Service\\\\DocGenerator\\\\PersonContextInterface\\:\\:buildPublicForm\\(\\) should be contravariant with parameter \\$entity \\(mixed\\) of method Chill\\\\DocGeneratorBundle\\\\Context\\\\DocGeneratorContextWithPublicFormInterface\\:\\:buildPublicForm\\(\\)$#" - count: 1 - path: src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContextInterface.php - - - - message: "#^Parameter \\#3 \\$entity \\(Chill\\\\PersonBundle\\\\Entity\\\\Person\\) of method Chill\\\\PersonBundle\\\\Service\\\\DocGenerator\\\\PersonContextInterface\\:\\:storeGenerated\\(\\) should be contravariant with parameter \\$entity \\(object\\) of method Chill\\\\DocGeneratorBundle\\\\Context\\\\DocGeneratorContextInterface\\:\\:storeGenerated\\(\\)$#" - count: 3 - path: src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContextInterface.php - message: "#^Parameter \\#1 \\$entity \\(Chill\\\\PersonBundle\\\\Entity\\\\AccompanyingPeriod\\\\ClosingMotive\\) of method Chill\\\\PersonBundle\\\\Templating\\\\Entity\\\\ClosingMotiveRender\\:\\:renderString\\(\\) should be contravariant with parameter \\$entity \\(object\\) of method Chill\\\\MainBundle\\\\Templating\\\\Entity\\\\ChillEntityRenderInterface\\:\\:renderString\\(\\)$#" diff --git a/phpstan-baseline-level-4.neon b/phpstan-baseline-level-4.neon index 0f8f8adb2..a608e293b 100644 --- a/phpstan-baseline-level-4.neon +++ b/phpstan-baseline-level-4.neon @@ -1150,11 +1150,6 @@ parameters: count: 1 path: src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php - - - message: "#^Property Chill\\\\DocGeneratorBundle\\\\Controller\\\\DocGeneratorTemplateController\\:\\:\\$client is never read, only written\\.$#" - count: 1 - path: src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php - - message: "#^Strict comparison using \\=\\=\\= between null and int will always evaluate to false\\.$#" count: 1 @@ -1225,11 +1220,6 @@ parameters: count: 1 path: src/Bundle/ChillDocStoreBundle/Entity/Document.php - - - message: "#^Method Chill\\\\DocStoreBundle\\\\Entity\\\\StoredObject\\:\\:getCreationDate\\(\\) should return DateTime but returns DateTimeInterface\\.$#" - count: 1 - path: src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php - - message: "#^Property Chill\\\\DocStoreBundle\\\\Entity\\\\StoredObject\\:\\:\\$id is never written, only read\\.$#" count: 1 diff --git a/src/Bundle/ChillActivityBundle/Menu/AccompanyingCourseMenuBuilder.php b/src/Bundle/ChillActivityBundle/Menu/AccompanyingCourseMenuBuilder.php index a177a717c..9884450ec 100644 --- a/src/Bundle/ChillActivityBundle/Menu/AccompanyingCourseMenuBuilder.php +++ b/src/Bundle/ChillActivityBundle/Menu/AccompanyingCourseMenuBuilder.php @@ -18,6 +18,9 @@ use Knp\Menu\MenuItem; use Symfony\Component\Security\Core\Security; use Symfony\Contracts\Translation\TranslatorInterface; +/** + * @implements LocalMenuBuilderInterface + */ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface { protected Security $security; diff --git a/src/Bundle/ChillActivityBundle/Menu/AdminMenuBuilder.php b/src/Bundle/ChillActivityBundle/Menu/AdminMenuBuilder.php index 71a9e3c2a..4b2d348d7 100644 --- a/src/Bundle/ChillActivityBundle/Menu/AdminMenuBuilder.php +++ b/src/Bundle/ChillActivityBundle/Menu/AdminMenuBuilder.php @@ -15,6 +15,9 @@ use Chill\MainBundle\Routing\LocalMenuBuilderInterface; use Knp\Menu\MenuItem; use Symfony\Component\Security\Core\Security; +/** + * @implements LocalMenuBuilderInterface + */ final class AdminMenuBuilder implements LocalMenuBuilderInterface { private Security $security; diff --git a/src/Bundle/ChillActivityBundle/Menu/PersonMenuBuilder.php b/src/Bundle/ChillActivityBundle/Menu/PersonMenuBuilder.php index 89dff9b2b..3a4da753d 100644 --- a/src/Bundle/ChillActivityBundle/Menu/PersonMenuBuilder.php +++ b/src/Bundle/ChillActivityBundle/Menu/PersonMenuBuilder.php @@ -13,11 +13,15 @@ namespace Chill\ActivityBundle\Menu; use Chill\ActivityBundle\Security\Authorization\ActivityVoter; use Chill\MainBundle\Routing\LocalMenuBuilderInterface; +use Chill\PersonBundle\Entity\Person; use Knp\Menu\MenuItem; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Contracts\Translation\TranslatorInterface; -class PersonMenuBuilder implements LocalMenuBuilderInterface +/** + * @implements LocalMenuBuilderInterface + */ +final class PersonMenuBuilder implements LocalMenuBuilderInterface { /** * @var AuthorizationCheckerInterface diff --git a/src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContext.php b/src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContext.php index 4984c359a..779db6a52 100644 --- a/src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContext.php +++ b/src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContext.php @@ -29,6 +29,8 @@ use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; use function count; +/** + */ final class CalendarContext implements CalendarContextInterface { private BaseContextData $baseContextData; @@ -138,8 +140,7 @@ final class CalendarContext implements CalendarContextInterface } /** - * @param array{mainPerson?: Person, thirdParty?: ThirdParty, title: string} $contextGenerationData - * @param mixed $entity + * param array{mainPerson?: Person, thirdParty?: ThirdParty, title: string} $contextGenerationData */ public function getData(DocGeneratorTemplate $template, $entity, array $contextGenerationData = []): array { @@ -237,7 +238,7 @@ final class CalendarContext implements CalendarContextInterface } /** - * @param array{mainPerson?: Person, thirdParty?: ThirdParty, title: string} $contextGenerationData + * param array{mainPerson?: Person, thirdParty?: ThirdParty, title: string} $contextGenerationData */ public function storeGenerated(DocGeneratorTemplate $template, StoredObject $storedObject, object $entity, array $contextGenerationData): void { @@ -250,7 +251,7 @@ final class CalendarContext implements CalendarContextInterface } /** - * @return array{askMainPerson: bool, mainPersonLabel: ?string, askThirdParty: bool, thirdPartyLabel: ?string, trackDateTime: bool} $options + * return array{askMainPerson: bool, mainPersonLabel: ?string, askThirdParty: bool, thirdPartyLabel: ?string, trackDateTime: bool} $options */ private function getOptions(DocGeneratorTemplate $template): array { diff --git a/src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContextInterface.php b/src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContextInterface.php index eeef3b417..4ae85d33a 100644 --- a/src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContextInterface.php +++ b/src/Bundle/ChillCalendarBundle/Service/DocGenerator/CalendarContextInterface.php @@ -18,6 +18,9 @@ use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate; use Chill\DocStoreBundle\Entity\StoredObject; use Symfony\Component\Form\FormBuilderInterface; +/** + * @template-extends DocGeneratorContextWithPublicFormInterface + */ interface CalendarContextInterface extends DocGeneratorContextWithPublicFormInterface, DocGeneratorContextWithAdminFormInterface { public function adminFormReverseTransform(array $data): array; @@ -26,23 +29,14 @@ interface CalendarContextInterface extends DocGeneratorContextWithPublicFormInte public function buildAdminForm(FormBuilderInterface $builder): void; - /** - * @param Calendar $entity - */ public function buildPublicForm(FormBuilderInterface $builder, DocGeneratorTemplate $template, $entity): void; - /** - * @param Calendar $entity - */ public function getData(DocGeneratorTemplate $template, $entity, array $contextGenerationData = []): array; public function getDescription(): string; public function getEntityClass(): string; - /** - * @param Calendar $entity - */ public function getFormData(DocGeneratorTemplate $template, $entity): array; public static function getKey(): string; @@ -51,17 +45,11 @@ interface CalendarContextInterface extends DocGeneratorContextWithPublicFormInte public function hasAdminForm(): bool; - /** - * @param Calendar $entity - */ public function hasPublicForm(DocGeneratorTemplate $template, $entity): bool; public function contextGenerationDataNormalize(DocGeneratorTemplate $template, $entity, array $data): array; public function contextGenerationDataDenormalize(DocGeneratorTemplate $template, $entity, array $data): array; - /** - * @param Calendar $entity - */ public function storeGenerated(DocGeneratorTemplate $template, StoredObject $storedObject, object $entity, array $contextGenerationData): void; } diff --git a/src/Bundle/ChillDocGeneratorBundle/Context/DocGeneratorContextInterface.php b/src/Bundle/ChillDocGeneratorBundle/Context/DocGeneratorContextInterface.php index 24ee030f6..cbd4e6a50 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Context/DocGeneratorContextInterface.php +++ b/src/Bundle/ChillDocGeneratorBundle/Context/DocGeneratorContextInterface.php @@ -16,15 +16,17 @@ use Chill\DocStoreBundle\Entity\StoredObject; /** * Interface for context for document generation. + * + * @template T of object */ interface DocGeneratorContextInterface { /** * Get the data that will be injected to the generated document. * - * @param mixed $entity + * @param T $entity */ - public function getData(DocGeneratorTemplate $template, $entity, array $contextGenerationData = []): array; + public function getData(DocGeneratorTemplate $template, object $entity, array $contextGenerationData = []): array; public function getDescription(): string; @@ -34,5 +36,8 @@ interface DocGeneratorContextInterface public function getName(): string; + /** + * @param T $entity + */ public function storeGenerated(DocGeneratorTemplate $template, StoredObject $storedObject, object $entity, array $contextGenerationData): void; } diff --git a/src/Bundle/ChillDocGeneratorBundle/Context/DocGeneratorContextWithPublicFormInterface.php b/src/Bundle/ChillDocGeneratorBundle/Context/DocGeneratorContextWithPublicFormInterface.php index 4f58bd049..a60a35123 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Context/DocGeneratorContextWithPublicFormInterface.php +++ b/src/Bundle/ChillDocGeneratorBundle/Context/DocGeneratorContextWithPublicFormInterface.php @@ -14,34 +14,43 @@ namespace Chill\DocGeneratorBundle\Context; use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate; use Symfony\Component\Form\FormBuilderInterface; +/** + * @template T + */ interface DocGeneratorContextWithPublicFormInterface extends DocGeneratorContextInterface { /** * Generate the form that display. * - * @param mixed $entity + * @param T $entity */ - public function buildPublicForm(FormBuilderInterface $builder, DocGeneratorTemplate $template, $entity): void; + public function buildPublicForm(FormBuilderInterface $builder, DocGeneratorTemplate $template, mixed $entity): void; /** * Fill the form with initial data + * + * @param T $entity */ - public function getFormData(DocGeneratorTemplate $template, $entity): array; + public function getFormData(DocGeneratorTemplate $template, mixed $entity): array; /** * has form. * - * @param mixed $entity + * @param T $entity */ - public function hasPublicForm(DocGeneratorTemplate $template, $entity): bool; + public function hasPublicForm(DocGeneratorTemplate $template, mixed $entity): bool; /** * Transform the data from the form into serializable data, storable into messenger's message + * + * @param T $entity */ - public function contextGenerationDataNormalize(DocGeneratorTemplate $template, $entity, array $data): array; + public function contextGenerationDataNormalize(DocGeneratorTemplate $template, mixed $entity, array $data): array; /** * Reverse the data from the messenger's message into data usable for doc's generation + * + * @param T $entity */ - public function contextGenerationDataDenormalize(DocGeneratorTemplate $template, $entity, array $data): array; + public function contextGenerationDataDenormalize(DocGeneratorTemplate $template, mixed $entity, array $data): array; } diff --git a/src/Bundle/ChillDocGeneratorBundle/DataFixtures/ORM/LoadDocGeneratorTemplate.php b/src/Bundle/ChillDocGeneratorBundle/DataFixtures/ORM/LoadDocGeneratorTemplate.php index d2a523277..a52381f36 100644 --- a/src/Bundle/ChillDocGeneratorBundle/DataFixtures/ORM/LoadDocGeneratorTemplate.php +++ b/src/Bundle/ChillDocGeneratorBundle/DataFixtures/ORM/LoadDocGeneratorTemplate.php @@ -61,7 +61,7 @@ class LoadDocGeneratorTemplate extends AbstractFixture ->setFilename($template['file']['filename']) ->setKeyInfos(json_decode($template['file']['key'], true)) ->setIv(json_decode($template['file']['iv'], true)) - ->setCreationDate(new DateTime('today')) + ->setCreatedAt(new DateTime('today')) ->setType($template['file']['type']); $manager->persist($newStoredObj); diff --git a/src/Bundle/ChillDocGeneratorBundle/Service/Generator/Generator.php b/src/Bundle/ChillDocGeneratorBundle/Service/Generator/Generator.php index 0775cfb49..394f8148b 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Service/Generator/Generator.php +++ b/src/Bundle/ChillDocGeneratorBundle/Service/Generator/Generator.php @@ -113,7 +113,7 @@ class Generator implements GeneratorInterface throw new GeneratorException($e->getErrors(), $e); } - if ($isTest) { + if (true === $isTest) { $this->logger->info(self::LOG_PREFIX.'Finished generation of a document', [ 'is_test' => true, 'entity_id' => $entityId, @@ -122,7 +122,7 @@ class Generator implements GeneratorInterface return $generatedResource; } - /** @var StoredObject $storedObject */ + /** @var StoredObject $destinationStoredObject */ $destinationStoredObject ->setType($template->getFile()->getType()) ->setFilename(sprintf('%s_odt', uniqid('doc_', true))) diff --git a/src/Bundle/ChillDocGeneratorBundle/Service/Generator/RelatedEntityNotFoundException.php b/src/Bundle/ChillDocGeneratorBundle/Service/Generator/RelatedEntityNotFoundException.php index b451b0ca5..a8e6f4059 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Service/Generator/RelatedEntityNotFoundException.php +++ b/src/Bundle/ChillDocGeneratorBundle/Service/Generator/RelatedEntityNotFoundException.php @@ -4,7 +4,7 @@ namespace Chill\DocGeneratorBundle\Service\Generator; class RelatedEntityNotFoundException extends \RuntimeException { - public function __construct(string $relatedEntityClass, int $relatedEntityId, Throwable $previous = null) + public function __construct(string $relatedEntityClass, int $relatedEntityId, \Throwable $previous = null) { parent::__construct( sprintf("Related entity not found: %s, %s", $relatedEntityClass, $relatedEntityId), diff --git a/src/Bundle/ChillDocGeneratorBundle/Service/Messenger/OnGenerationFails.php b/src/Bundle/ChillDocGeneratorBundle/Service/Messenger/OnGenerationFails.php index e3b91d7e4..cbd539913 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Service/Messenger/OnGenerationFails.php +++ b/src/Bundle/ChillDocGeneratorBundle/Service/Messenger/OnGenerationFails.php @@ -108,10 +108,7 @@ final class OnGenerationFails implements EventSubscriberInterface private function warnCreator(RequestGenerationMessage $message, WorkerMessageFailedEvent $event): void { - if (null === $creatorId = $message->getCreatorId()) { - $this->logger->info(self::LOG_PREFIX.'creator id is null'); - return; - } + $creatorId = $message->getCreatorId(); if (null === $creator = $this->userRepository->find($creatorId)) { $this->logger->error(self::LOG_PREFIX.'Creator not found with given id', ['creator_id', $creatorId]); diff --git a/src/Bundle/ChillMainBundle/Doctrine/Type/NativeDateIntervalType.php b/src/Bundle/ChillMainBundle/Doctrine/Type/NativeDateIntervalType.php index 896ddb600..1d4cd104c 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/Type/NativeDateIntervalType.php +++ b/src/Bundle/ChillMainBundle/Doctrine/Type/NativeDateIntervalType.php @@ -31,6 +31,9 @@ class NativeDateIntervalType extends DateIntervalType { public const FORMAT = '%rP%YY%MM%DDT%HH%IM%SS'; + /** + * @param DateInterval|null $value + */ public function convertToDatabaseValue($value, AbstractPlatform $platform) { if (null === $value) { diff --git a/src/Bundle/ChillMainBundle/Routing/LocalMenuBuilderInterface.php b/src/Bundle/ChillMainBundle/Routing/LocalMenuBuilderInterface.php index c4bb0455f..f2b19f84c 100644 --- a/src/Bundle/ChillMainBundle/Routing/LocalMenuBuilderInterface.php +++ b/src/Bundle/ChillMainBundle/Routing/LocalMenuBuilderInterface.php @@ -13,8 +13,18 @@ namespace Chill\MainBundle\Routing; use Knp\Menu\MenuItem; +/** + * Implements a builder for menu + * + * @template TParams of array + */ interface LocalMenuBuilderInterface { + /** + * @param $menuId + * @param MenuItem $menu + * @param TParams $parameters + */ public function buildMenu($menuId, MenuItem $menu, array $parameters); /** diff --git a/src/Bundle/ChillPersonBundle/Menu/PersonMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/PersonMenuBuilder.php index 8c46b571e..39ac557fb 100644 --- a/src/Bundle/ChillPersonBundle/Menu/PersonMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/PersonMenuBuilder.php @@ -28,6 +28,8 @@ use function count; * * - person details ; * - accompanying period (if `visible`) + * + * @implements LocalMenuBuilderInterface */ class PersonMenuBuilder implements LocalMenuBuilderInterface { diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php index 9ab733d87..00f7a86fb 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php @@ -38,6 +38,9 @@ use Symfony\Contracts\Translation\TranslatorInterface; use function array_key_exists; +/** + * @template-implements DocGeneratorContextWithPublicFormInterface + */ class AccompanyingPeriodContext implements DocGeneratorContextWithAdminFormInterface, DocGeneratorContextWithPublicFormInterface @@ -153,7 +156,7 @@ class AccompanyingPeriodContext implements /** * @param AccompanyingPeriod $entity */ - public function buildPublicForm(FormBuilderInterface $builder, DocGeneratorTemplate $template, $entity): void + public function buildPublicForm(FormBuilderInterface $builder, DocGeneratorTemplate $template, mixed $entity): void { $options = $template->getOptions(); $persons = $entity->getCurrentParticipations()->map(static function (AccompanyingPeriodParticipation $p) { @@ -286,9 +289,6 @@ class AccompanyingPeriodContext implements return $denormalized; } - /** - * @param AccompanyingPeriod $entity - */ public function storeGenerated(DocGeneratorTemplate $template, StoredObject $storedObject, object $entity, array $contextGenerationData): void { $doc = new AccompanyingCourseDocument(); diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkContext.php index 59f5fdb0c..ad1952596 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkContext.php @@ -24,6 +24,8 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface; * * Although there isn't any document associated to AccompanyingPeriodWork, this context * is use by @link{AccompanyingPeriodWorkEvaluationContext}. + * + * @implements DocGeneratorContextWithPublicFormInterface */ class AccompanyingPeriodWorkContext implements DocGeneratorContextWithPublicFormInterface { @@ -56,17 +58,11 @@ class AccompanyingPeriodWorkContext implements DocGeneratorContextWithPublicForm $builder->remove('category'); } - /** - * @param AccompanyingPeriodWork $entity - */ public function buildPublicForm(FormBuilderInterface $builder, DocGeneratorTemplate $template, $entity): void { $this->periodContext->buildPublicForm($builder, $template, $entity->getAccompanyingPeriod()); } - /** - * @param AccompanyingPeriodWork $entity - */ public function getData(DocGeneratorTemplate $template, $entity, array $contextGenerationData = []): array { $data = $this->periodContext->getData($template, $entity->getAccompanyingPeriod(), $contextGenerationData); @@ -88,9 +84,6 @@ class AccompanyingPeriodWorkContext implements DocGeneratorContextWithPublicForm return AccompanyingPeriodWork::class; } - /** - * @param AccompanyingPeriodWork $entity - */ public function getFormData(DocGeneratorTemplate $template, $entity): array { return $this->periodContext->getFormData($template, $entity->getAccompanyingPeriod()); @@ -113,17 +106,17 @@ class AccompanyingPeriodWorkContext implements DocGeneratorContextWithPublicForm public function hasPublicForm(DocGeneratorTemplate $template, $entity): bool { - return $this->periodContext->hasPublicForm($template, $entity); + return $this->periodContext->hasPublicForm($template, $entity->getAccompanyingPeriod()); } public function contextGenerationDataNormalize(DocGeneratorTemplate $template, $entity, array $data): array { - return $this->periodContext->contextGenerationDataNormalize($template, $entity, $data); + return $this->periodContext->contextGenerationDataNormalize($template, $entity->getAccompanyingPeriod(), $data); } public function contextGenerationDataDenormalize(DocGeneratorTemplate $template, $entity, array $data): array { - return $this->periodContext->contextGenerationDataDenormalize($template, $entity, $data); + return $this->periodContext->contextGenerationDataDenormalize($template, $entity->getAccompanyingPeriod(), $data); } public function storeGenerated(DocGeneratorTemplate $template, StoredObject $storedObject, object $entity, array $contextGenerationData): void diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php index 978aac066..4718b7b00 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php @@ -26,6 +26,9 @@ use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; +/** + * @implements DocGeneratorContextWithPublicFormInterface + */ class AccompanyingPeriodWorkEvaluationContext implements DocGeneratorContextWithAdminFormInterface, DocGeneratorContextWithPublicFormInterface @@ -102,17 +105,11 @@ class AccompanyingPeriodWorkEvaluationContext implements ]); } - /** - * @param AccompanyingPeriodWorkEvaluation $entity - */ public function buildPublicForm(FormBuilderInterface $builder, DocGeneratorTemplate $template, $entity): void { $this->accompanyingPeriodWorkContext->buildPublicForm($builder, $template, $entity->getAccompanyingPeriodWork()); } - /** - * @param AccompanyingPeriodWorkEvaluation $entity - */ public function getData(DocGeneratorTemplate $template, $entity, array $contextGenerationData = []): array { $data = $this->accompanyingPeriodWorkContext @@ -139,9 +136,6 @@ class AccompanyingPeriodWorkEvaluationContext implements return AccompanyingPeriodWorkEvaluation::class; } - /** - * @param AccompanyingPeriodWorkEvaluation $entity - */ public function getFormData(DocGeneratorTemplate $template, $entity): array { return $this->accompanyingPeriodWorkContext->getFormData( @@ -177,13 +171,13 @@ class AccompanyingPeriodWorkEvaluationContext implements public function contextGenerationDataNormalize(DocGeneratorTemplate $template, $entity, array $data): array { return $this->accompanyingPeriodWorkContext - ->contextGenerationDataNormalize($template, $entity, $data); + ->contextGenerationDataNormalize($template, $entity->getAccompanyingPeriodWork(), $data); } public function contextGenerationDataDenormalize(DocGeneratorTemplate $template, $entity, array $data): array { return $this->accompanyingPeriodWorkContext - ->contextGenerationDataDenormalize($template, $entity, $data); + ->contextGenerationDataDenormalize($template, $entity->getAccompanyingPeriodWork(), $data); } public function storeGenerated(DocGeneratorTemplate $template, StoredObject $storedObject, object $entity, array $contextGenerationData): void diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php index 988c50829..86b29585c 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php @@ -249,9 +249,6 @@ final class PersonContext implements PersonContextInterface ]; } - /** - * @param Person $entity - */ public function storeGenerated(DocGeneratorTemplate $template, StoredObject $storedObject, object $entity, array $contextGenerationData): void { $doc = new PersonDocument(); diff --git a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContextInterface.php b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContextInterface.php index ab50655a0..6de8c1c50 100644 --- a/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContextInterface.php +++ b/src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContextInterface.php @@ -18,6 +18,9 @@ use Chill\DocStoreBundle\Entity\StoredObject; use Chill\PersonBundle\Entity\Person; use Symfony\Component\Form\FormBuilderInterface; +/** + * @template-extends DocGeneratorContextWithPublicFormInterface + */ interface PersonContextInterface extends DocGeneratorContextWithAdminFormInterface, DocGeneratorContextWithPublicFormInterface { public function adminFormReverseTransform(array $data): array; @@ -26,10 +29,7 @@ interface PersonContextInterface extends DocGeneratorContextWithAdminFormInterfa public function buildAdminForm(FormBuilderInterface $builder): void; - /** - * @param Person $entity - */ - public function buildPublicForm(FormBuilderInterface $builder, DocGeneratorTemplate $template, $entity): void; + public function buildPublicForm(FormBuilderInterface $builder, DocGeneratorTemplate $template, mixed $entity): void; public function getData(DocGeneratorTemplate $template, $entity, array $contextGenerationData = []): array; @@ -37,7 +37,7 @@ interface PersonContextInterface extends DocGeneratorContextWithAdminFormInterfa public function getEntityClass(): string; - public function getFormData(DocGeneratorTemplate $template, $entity): array; + public function getFormData(DocGeneratorTemplate $template, mixed $entity): array; public function getName(): string; @@ -52,8 +52,5 @@ interface PersonContextInterface extends DocGeneratorContextWithAdminFormInterfa public function contextGenerationDataDenormalize(DocGeneratorTemplate $template, $entity, array $data): array; - /** - * @param Person $entity - */ public function storeGenerated(DocGeneratorTemplate $template, StoredObject $storedObject, object $entity, array $contextGenerationData): void; }