Issues (15)

src/Serializer/AttachmentNormalizer.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Serializer;
6
7
use App\Entity\Attachment;
8
use App\Serializer\Processor\FileHrefProcessor;
9
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
10
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
11
12
class AttachmentNormalizer implements NormalizerInterface
13
{
14
    private $normalizer;
15
    private $fileHrefProcessor;
16
17
    public function __construct(
18
        ObjectNormalizer $normalizer,
19
        FileHrefProcessor $fileHrefProcessor
20
    ) {
21
        $this->normalizer = $normalizer;
22
        $this->fileHrefProcessor = $fileHrefProcessor;
23
    }
24
25
    public function normalize($object, $format = null, array $context = [])
26
    {
27
        $data = $this->normalizer->normalize($object, $format, $context);
28
        $data = $this->fileHrefProcessor->process($object, $data);
0 ignored issues
show
It seems like $data can also be of type ArrayObject; however, parameter $data of App\Serializer\Processor...refProcessor::process() does only seem to accept 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

28
        $data = $this->fileHrefProcessor->process($object, /** @scrutinizer ignore-type */ $data);
Loading history...
29
30
        return $data;
31
    }
32
33
    public function supportsNormalization($data, $format = null): bool
34
    {
35
        return $data instanceof Attachment;
36
    }
37
}
38