From 5cf86d54d80c2016d44cef5032fa17f25e07f759 Mon Sep 17 00:00:00 2001 From: Pirmin Mattmann Date: Thu, 8 Aug 2024 20:14:43 +0200 Subject: [PATCH] cs-fix; phpstan --- .../AssertBelongsToSameCampValidator.php | 11 ++++++----- .../Api/ChecklistItems/UpdateChecklistItemTest.php | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/api/src/Validator/ChecklistItem/AssertBelongsToSameCampValidator.php b/api/src/Validator/ChecklistItem/AssertBelongsToSameCampValidator.php index 7716448fa7..373471ef3b 100644 --- a/api/src/Validator/ChecklistItem/AssertBelongsToSameCampValidator.php +++ b/api/src/Validator/ChecklistItem/AssertBelongsToSameCampValidator.php @@ -15,9 +15,9 @@ class AssertBelongsToSameCampValidator extends ConstraintValidator { use GetCampFromContentNodeTrait; - + public function __construct( - public RequestStack $requestStack, + public RequestStack $requestStack, private EntityManagerInterface $em, private ChecklistItemRepository $checklistItemRepository, ) {} @@ -42,13 +42,14 @@ public function validate($value, Constraint $constraint): void { $camp = $this->getCampFromInterface($object, $this->em); - foreach($value as $checklistItemId) { - /** @var ChecklistItem $checklistItem */ + foreach ($value as $checklistItemId) { + /** @var ?ChecklistItem $checklistItem */ $checklistItem = $this->checklistItemRepository->find($checklistItemId); if ($camp != $checklistItem?->getCamp()) { $this->context->buildViolation($constraint->message) - ->addViolation(); + ->addViolation() + ; } } } diff --git a/api/tests/Api/ChecklistItems/UpdateChecklistItemTest.php b/api/tests/Api/ChecklistItems/UpdateChecklistItemTest.php index 5237deb0bb..24462d3c0e 100644 --- a/api/tests/Api/ChecklistItems/UpdateChecklistItemTest.php +++ b/api/tests/Api/ChecklistItems/UpdateChecklistItemTest.php @@ -124,7 +124,7 @@ public function testPatchhChecklistItemValidatesNoParentLoop() { 'headers' => ['Content-Type' => 'application/merge-patch+json'], ] ); - + $this->assertResponseStatusCodeSame(422); $this->assertJsonContains([ 'title' => 'An error occurred',