1 | <?php |
||||||
2 | |||||||
3 | declare(strict_types=1); |
||||||
4 | |||||||
5 | namespace MichaelRubel\SafeFormRequest\Traits; |
||||||
6 | |||||||
7 | use Illuminate\Support\Arr; |
||||||
8 | |||||||
9 | trait RetrievesSafeInput |
||||||
10 | { |
||||||
11 | /** |
||||||
12 | * Get an element from the validated input. |
||||||
13 | * |
||||||
14 | * @param string $key |
||||||
15 | * @return mixed |
||||||
16 | */ |
||||||
17 | 1 | public function __get($key): mixed |
|||||
18 | { |
||||||
19 | 1 | $values = rescue( |
|||||
20 | 1 | fn () => $this->validated(), |
|||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||||
21 | 1 | fn () => $this->all(), |
|||||
0 ignored issues
–
show
It seems like
all() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
22 | 1 | false |
|||||
23 | 1 | ); |
|||||
24 | |||||||
25 | 1 | return Arr::get($values, $key, fn () => $this->route($key)); |
|||||
0 ignored issues
–
show
It seems like
route() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() It seems like
$values can also be of type callable ; however, parameter $array of Illuminate\Support\Arr::get() does only seem to accept ArrayAccess|array , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
26 | } |
||||||
27 | } |
||||||
28 |