Issues (5)

src/Attribute/RequestResolver.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\RequestModel\Attribute;
6
7
use Psr\Http\Message\ServerRequestInterface;
8
9
final class RequestResolver implements HandlerParameterResolverInterface
10
{
11 4
    public function resolve(HandlerParameterAttributeInterface $attribute, ServerRequestInterface $request): mixed
12
    {
13 4
        if ($attribute::class !== Request::class) {
14 1
            throw new \InvalidArgumentException(sprintf('Expected "%s", got "%s".', Request::class, $attribute::class));
15
        }
16
17 3
        $notFoundValue = NotFoundValue::getInstance();
18
19
        /** @var mixed $result */
20 3
        $result = $request->getAttribute($attribute->getName(), $notFoundValue);
0 ignored issues
show
The method getName() does not exist on Yiisoft\RequestModel\Att...meterAttributeInterface. It seems like you code against a sub-type of said class. However, the method does not exist in Yiisoft\RequestModel\Attribute\UploadedFiles or Yiisoft\RequestModel\Tests\Support\MockAttribute. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

20
        $result = $request->getAttribute($attribute->/** @scrutinizer ignore-call */ getName(), $notFoundValue);
Loading history...
21 3
        if ($result === $notFoundValue) {
22
            throw new ValueNotFoundException();
23
        }
24
25 3
        return $result;
26
    }
27
}
28