Skip to content

[Validator] Throw Symfony/OutOfBounds exception instead of default one in ConstraintViolationList #49881

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Symfony/Component/Validator/ConstraintViolationList.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace Symfony\Component\Validator;

use Symfony\Component\Validator\Exception\OutOfBoundsException;

/**
* Default implementation of {@ConstraintViolationListInterface}.
*
Expand Down Expand Up @@ -77,7 +79,7 @@ public function addAll(ConstraintViolationListInterface $otherList)
public function get(int $offset): ConstraintViolationInterface
{
if (!isset($this->violations[$offset])) {
throw new \OutOfBoundsException(sprintf('The offset "%s" does not exist.', $offset));
throw new OutOfBoundsException(sprintf('The offset "%s" does not exist.', $offset));
}

return $this->violations[$offset];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace Symfony\Component\Validator;

use Symfony\Component\Validator\Exception\OutOfBoundsException;

/**
* A list of constraint violations.
*
Expand Down Expand Up @@ -42,7 +44,7 @@ public function addAll(self $otherList);
*
* @param int $offset The offset of the violation
*
* @throws \OutOfBoundsException if the offset does not exist
* @throws OutOfBoundsException if the offset does not exist
*/
public function get(int $offset): ConstraintViolationInterface;

Expand Down