Skip to content

Commit

Permalink
cs-fix; phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
pmattmann committed Aug 8, 2024
1 parent 630b9ab commit 5cf86d5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) {}
Expand All @@ -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()
;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion api/tests/Api/ChecklistItems/UpdateChecklistItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function testPatchhChecklistItemValidatesNoParentLoop() {
'headers' => ['Content-Type' => 'application/merge-patch+json'],
]
);

$this->assertResponseStatusCodeSame(422);
$this->assertJsonContains([
'title' => 'An error occurred',
Expand Down

0 comments on commit 5cf86d5

Please sign in to comment.