Skip to content

Commit 6ebaeb5

Browse files
committed
fix: use array shift in error iterator due to laravel bug
1 parent 78c2526 commit 6ebaeb5

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
All notable changes to this project will be documented in this file. This project adheres to
44
[Semantic Versioning](http://semver.org/) and [this changelog format](http://keepachangelog.com/).
55

6+
## Unreleased
7+
8+
### Fixed
9+
10+
- [laravel#287](https://github.com/laravel-json-api/laravel/issues/287) Use `array_shift` to avoid potential problem
11+
introduced in Laravel.
12+
613
## [3.0.0] - 2023-02-14
714

815
### Changed

src/ErrorIterator.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,15 @@ public function getIterator(): Traversable
114114
$failed = $this->failed();
115115

116116
foreach ($this->validator->errors()->messages() as $key => $messages) {
117-
$failures = $this->translator->validationFailures($failed[$key] ?? []);
117+
$failures = $this->translator
118+
->validationFailures($failed[$key] ?? [])
119+
->all();
118120

119121
foreach ($messages as $message) {
120122
yield $this->createError(
121123
$key,
122124
$message,
123-
$failures->shift() ?: []
125+
array_shift($failures) ?: [],
124126
);
125127
}
126128
}

0 commit comments

Comments
 (0)