Issues (4)

src/Traits/RetrievesSafeInput.php (4 issues)

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
It seems like validated() 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 ignore-call  annotation

20
            fn () => $this->/** @scrutinizer ignore-call */ validated(),
Loading history...
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 ignore-call  annotation

21
            fn () => $this->/** @scrutinizer ignore-call */ all(),
Loading history...
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 ignore-call  annotation

25
        return Arr::get($values, $key, fn () => $this->/** @scrutinizer ignore-call */ route($key));
Loading history...
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 ignore-type  annotation

25
        return Arr::get(/** @scrutinizer ignore-type */ $values, $key, fn () => $this->route($key));
Loading history...
26
    }
27
}
28