Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Passed
Push — annotations ( ce3247...ddf0da )
by Jérémiah
22:02 queued 14s
created

ExtensibleSchema::addDefaultFallBackToTypeLoader()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 23

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 23
ccs 13
cts 13
cp 1
rs 9.552
c 0
b 0
f 0
cc 2
nc 1
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Overblog\GraphQLBundle\Definition\Type;
6
7
use GraphQL\Type\Definition\Type;
8
use GraphQL\Type\Schema;
9
use GraphQL\Type\SchemaConfig;
10
use Overblog\GraphQLBundle\Definition\Type\SchemaExtension\SchemaExtensionInterface;
11
use Overblog\GraphQLBundle\Resolver\UnresolvableException;
12
13
class ExtensibleSchema extends Schema
14
{
15 95
    public function __construct($config)
16
    {
17 95
        parent::__construct($this->addDefaultFallBackToTypeLoader(
18 95
            $config instanceof SchemaConfig ? $config : SchemaConfig::create($config)
0 ignored issues
show
Bug introduced by
The class GraphQL\Type\SchemaConfig does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
19
        ));
20 95
    }
21
22
    /** @var SchemaExtensionInterface[] */
23
    private $extensions = [];
24
25
    /**
26
     * @param SchemaExtensionInterface[] $extensions
27
     *
28
     * @return $this
29
     */
30 91
    public function setExtensions(array $extensions)
31
    {
32 91
        $this->extensions = [];
33 91
        foreach ($extensions as $extension) {
34 84
            $this->addExtension($extension);
35
        }
36
37 91
        return $this;
38
    }
39
40
    /**
41
     * @param SchemaExtensionInterface $extension
42
     */
43 84
    public function addExtension(SchemaExtensionInterface $extension): void
44
    {
45 84
        $this->extensions[] = $extension;
46 84
    }
47
48
    /**
49
     * @return $this
50
     */
51 82
    public function processExtensions()
52
    {
53 82
        foreach ($this->extensions as $extension) {
54 76
            $extension->process($this);
55
        }
56
57 82
        return $this;
58
    }
59
60 95
    private function addDefaultFallBackToTypeLoader(SchemaConfig $schemaConfig): SchemaConfig
61
    {
62 95
        $typeLoader = $schemaConfig->typeLoader;
63 95
        $loaderWrapper = null;
64
        $loaderWrapper = function ($name) use ($typeLoader, &$schemaConfig, &$loaderWrapper): ?Type {
65 82
            $type = null;
66
            try {
67 82
                $type = $typeLoader($name);
68 3
            } catch (UnresolvableException $e) {
69
                // second chance for types with un-registered name in TypeResolver
70
                // we disabled the custom typeLoader to force default loader usage
71 3
                $schemaConfig->typeLoader = null;
72 3
                $type = $this->getType($name);
73 3
                $schemaConfig->typeLoader = $loaderWrapper;
74
            }
75
76 82
            return $type;
77 95
        };
78
79 95
        $schemaConfig->typeLoader = $loaderWrapper;
80
81 95
        return $schemaConfig;
82
    }
83
}
84