Test Failed
Pull Request — master (#11)
by
unknown
16:45 queued 43s
created

src/Doctrine/Rest/Fractal/Scope.php (3 issues)

1
<?php namespace Pz\Doctrine\Rest\Fractal;
2
3
use League\Fractal\Resource\Collection;
4
use League\Fractal\Resource\Item;
5
use League\Fractal\Serializer\JsonApiSerializer;
6
use League\Fractal\Serializer\Serializer;
7
8
class Scope extends \League\Fractal\Scope
9
{
10
    /**
11
     * @var bool
12
     */
13
    protected $isRelationships = false;
14
15
    /**
16
     * @param null|bool $value
17
     *
18
     * @return bool|null
19
     */
20 19
    public function isRelationships($value = null)
21
    {
22 19
        if ($value !== null) {
23 19
            $this->isRelationships = $value;
24
        }
25
26 19
        return $this->isRelationships;
27
    }
28
29
    /**
30
     * @param JsonApiSerializer|SerializerAbstract $serializer
0 ignored issues
show
The type Pz\Doctrine\Rest\Fractal\SerializerAbstract was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
31
     * @param mixed                                $data
32
     *
33
     * @return array
34
     */
35 19
    protected function serializeResource(Serializer $serializer, $data): array|null
36
    {
37 19
        $includeAttributes = true;
38 19
        $resourceKey = $this->resource->getResourceKey();
39 19
        if ($this->isRelationships() && $this->isRootScope()) {
40 4
            $includeAttributes = false;
41
        }
42
43 19
        if ($this->resource instanceof Collection) {
44 13
            return $serializer->collection($resourceKey, $data, $includeAttributes);
0 ignored issues
show
The call to League\Fractal\Serializer\Serializer::collection() has too many arguments starting with $includeAttributes. ( Ignorable by Annotation )

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

44
            return $serializer->/** @scrutinizer ignore-call */ collection($resourceKey, $data, $includeAttributes);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
45
        }
46
47 10
        if ($this->resource instanceof Item) {
48 10
            return $serializer->item($resourceKey, $data, $includeAttributes);
0 ignored issues
show
The call to League\Fractal\Serializer\Serializer::item() has too many arguments starting with $includeAttributes. ( Ignorable by Annotation )

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

48
            return $serializer->/** @scrutinizer ignore-call */ item($resourceKey, $data, $includeAttributes);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
49
        }
50
51 3
        return $serializer->null();
52
    }
53
}
54