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

AbstractResolver::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
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
     * @param mixed            $rootValue
11
     * @param array            $args
12
     * @param mixed            $contextValues
13
     * @param ResolveInfo|null $info
14
     * @return mixed
15
     */
16
    abstract public function resolve($rootValue, array $args, $contextValues = null, ?ResolveInfo $info = null);
17
18
    /**
19
     * @return mixed
20
     */
21
    public function __invoke()
22
    {
23
        return $this->resolve(...\func_get_args());
24
    }
25
26
    /**
27
     * @inheritdoc
28
     */
29
    public function getResolveCallback(): ?callable
30
    {
31
        return function ($rootValue, array $args, $contextValues = null, ?ResolveInfo $info = null) {
32
            return $this->resolve(...\func_get_args());
33
        };
34
    }
35
36
    /**
37
     * @inheritdoc
38
     */
39
    public function getTypeResolver(): ?callable
40
    {
41
        return function ($rootValue, $contextValues = null, ?ResolveInfo $info = null) {
42
            return $this->resolveType(...\func_get_args());
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->resolveType(func_get_args()) 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...
Bug introduced by
func_get_args() is expanded, but the parameter $rootValue of Digia\GraphQL\Schema\Res...Resolver::resolveType() does not expect variable arguments. ( Ignorable by Annotation )

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

42
            return $this->resolveType(/** @scrutinizer ignore-type */ ...\func_get_args());
Loading history...
43
        };
44
    }
45
46
    /**
47
     * @param mixed            $rootValue
48
     * @param mixed            $contextValues
49
     * @param ResolveInfo|null $info
50
     * @return callable|null
51
     */
52
    public function resolveType($rootValue, $contextValues = null, ?ResolveInfo $info = null): ?callable
0 ignored issues
show
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

52
    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...
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

52
    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

52
    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...
53
    {
54
        // Override this method when your resolver returns an interface or an union type.
55
        return null;
56
    }
57
}
58