Passed
Pull Request — master (#299)
by Christoffer
02:41
created

AbstractResolver::resolveType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 3
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Digia\GraphQL\Schema\Resolver;
4
5
use Digia\GraphQL\Execution\ResolveInfo;
6
7
abstract class AbstractResolver implements ResolverInterface
8
{
9
    /**
10
     * @return mixed
11
     */
12
    public function __invoke()
13
    {
14
        return $this->resolve(...\func_get_args());
15
    }
16
17
    /**
18
     * @param mixed            $rootValue
19
     * @param array            $args
20
     * @param mixed            $contextValues
21
     * @param ResolveInfo|null $info
22
     * @return mixed
23
     */
24
    abstract public function resolve($rootValue, array $args, $contextValues = null, ?ResolveInfo $info = null);
25
26
    /**
27
     * @inheritdoc
28
     */
29
    public function resolveType($rootValue, $contextValues = null, ?ResolveInfo $info = null): ?callable
0 ignored issues
show
Unused Code introduced by
The parameter $rootValue is not used and could be removed. ( Ignorable by Annotation )

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

29
    public function resolveType(/** @scrutinizer ignore-unused */ $rootValue, $contextValues = null, ?ResolveInfo $info = null): ?callable

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $contextValues is not used and could be removed. ( Ignorable by Annotation )

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

29
    public function resolveType($rootValue, /** @scrutinizer ignore-unused */ $contextValues = null, ?ResolveInfo $info = null): ?callable

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $info is not used and could be removed. ( Ignorable by Annotation )

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

29
    public function resolveType($rootValue, $contextValues = null, /** @scrutinizer ignore-unused */ ?ResolveInfo $info = null): ?callable

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
30
    {
31
        // Override this method when your resolver returns an interface or an union type.
32
        return null;
33
    }
34
35
    /**
36
     * @return callable|null
37
     */
38
    public function getResolveCallback(): ?callable
39
    {
40
        return function ($rootValue, array $args, $contextValues = null, ?ResolveInfo $info = null) {
41
            return $this->resolve(...\func_get_args());
42
        };
43
    }
44
45
    /**
46
     * @return callable|null
47
     */
48
    public function getTypeResolver(): ?callable
49
    {
50
        return function ($rootValue, $contextValues = null, ?ResolveInfo $info = null) {
51
            return $this->resolveType($rootValue, $contextValues, $info);
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->resolveType($root... $contextValues, $info) targeting Digia\GraphQL\Schema\Res...Resolver::resolveType() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
52
        };
53
    }
54
}
55