Issues (167)

src/Schema/Resolver/ResolverTrait.php (4 issues)

1
<?php
2
3
namespace Digia\GraphQL\Schema\Resolver;
4
5
use Digia\GraphQL\Execution\ResolveInfo;
6
7
trait ResolverTrait
8
{
9
    /**
10
     * @return callable|null
11
     */
12
    public function getTypeResolver(): ?callable
13
    {
14
        return function ($rootValue, $context = null, ?ResolveInfo $info = null) {
15
            return $this->resolveType($rootValue, $context, $info);
0 ignored issues
show
Are you sure the usage of $this->resolveType($rootValue, $context, $info) targeting Digia\GraphQL\Schema\Res...verTrait::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...
16
        };
17
    }
18
19
    /**
20
     * @param mixed            $rootValue
21
     * @param mixed            $context
22
     * @param ResolveInfo|null $info
23
     * @return callable|null
24
     */
25
    public function resolveType($rootValue, $context = null, ?ResolveInfo $info = null): ?callable
0 ignored issues
show
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

25
    public function resolveType($rootValue, $context = 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...
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

25
    public function resolveType(/** @scrutinizer ignore-unused */ $rootValue, $context = 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...
The parameter $context 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

25
    public function resolveType($rootValue, /** @scrutinizer ignore-unused */ $context = 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...
26
    {
27
        // Override this method when your resolver returns an interface or an union type.
28
        return null;
29
    }
30
31
    /**
32
     * @return array|null
33
     */
34
    public function getMiddleware(): ?array
35
    {
36
        return null;
37
    }
38
}
39