Basster /
lazy-response-bundle
| 1 | <?php |
||||||
| 2 | declare(strict_types=1); |
||||||
| 3 | |||||||
| 4 | namespace Basster\LazyResponseBundle\Response\Handler; |
||||||
| 5 | |||||||
| 6 | use Basster\LazyResponseBundle\Response\JsonSerializeResponse; |
||||||
| 7 | use Basster\LazyResponseBundle\Response\LazyResponseInterface; |
||||||
| 8 | use Symfony\Component\HttpFoundation\JsonResponse; |
||||||
| 9 | use Symfony\Component\HttpFoundation\Response; |
||||||
| 10 | use Symfony\Component\Serializer\SerializerInterface; |
||||||
| 11 | |||||||
| 12 | /** |
||||||
| 13 | * Class JsonSerializeResponseHandler. |
||||||
| 14 | */ |
||||||
| 15 | final class JsonSerializeResponseHandler extends AbstractLazyResponseHandler |
||||||
| 16 | { |
||||||
| 17 | 4 | public function __construct(private SerializerInterface $serializer) |
|||||
|
0 ignored issues
–
show
|
|||||||
| 18 | { |
||||||
| 19 | 4 | } |
|||||
| 20 | |||||||
| 21 | /** |
||||||
| 22 | * @param JsonSerializeResponse $controllerResult |
||||||
| 23 | * |
||||||
| 24 | * @psalm-suppress MoreSpecificImplementedParamType |
||||||
| 25 | */ |
||||||
| 26 | 3 | protected function generateResponse(LazyResponseInterface $controllerResult): Response |
|||||
| 27 | { |
||||||
| 28 | 3 | return new JsonResponse( |
|||||
| 29 | 3 | $this->serializer->serialize($controllerResult->getData(), 'json'), |
|||||
|
0 ignored issues
–
show
The method
getData() does not exist on Basster\LazyResponseBund...e\LazyResponseInterface. It seems like you code against a sub-type of Basster\LazyResponseBund...e\LazyResponseInterface such as Basster\LazyResponseBund...sponse\TemplateResponse or Basster\LazyResponseBund...e\JsonSerializeResponse.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 30 | 3 | $controllerResult->getStatusCode(), |
|||||
| 31 | 3 | $controllerResult->getHeaders(), |
|||||
|
0 ignored issues
–
show
The method
getHeaders() does not exist on Basster\LazyResponseBund...e\LazyResponseInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to Basster\LazyResponseBund...e\LazyResponseInterface.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 32 | 3 | true |
|||||
| 33 | ); |
||||||
| 34 | } |
||||||
| 35 | |||||||
| 36 | 3 | protected function isSupported(LazyResponseInterface $controllerResult): bool |
|||||
| 37 | { |
||||||
| 38 | 3 | return $controllerResult instanceof JsonSerializeResponse; |
|||||
| 39 | } |
||||||
| 40 | } |
||||||
| 41 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.