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

Completed
Pull Request — annotations (#407)
by Vincent
23:05
created

InvalidArgumentsError   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 41
ccs 0
cts 24
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getErrors() 0 4 1
A toState() 0 16 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Overblog\GraphQLBundle\Error;
6
7
use GraphQL\Error\UserError;
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, Overblog\GraphQLBundle\Error\UserError.

Let’s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let’s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
8
9
/**
10
 * Class InvalidArgumentError.
11
 */
12
class InvalidArgumentsError extends UserError
13
{
14
    /** @var InvalidArgumentError */
15
    private $errors = [];
16
17
    public function __construct(array $errors, $message = '', $code = 0, \Exception $previous = null)
18
    {
19
        $this->errors = $errors;
0 ignored issues
show
Documentation Bug introduced by
It seems like $errors of type array is incompatible with the declared type object<Overblog\GraphQLB...r\InvalidArgumentError> of property $errors.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
20
        parent::__construct($message, $code, $previous);
21
    }
22
23
    /**
24
     * @return InvalidArgumentError[]
25
     */
26
    public function getErrors()
27
    {
28
        return $this->errors;
29
    }
30
31
    /**
32
     * Return a serializable array of validation errors for each argument.
33
     *
34
     * @return array
35
     */
36
    public function toState()
37
    {
38
        $state = [];
39
        foreach ($this->getErrors() as $error) {
40
            $state[$error->getName()] = [];
41
            foreach ($error->getErrors() as $violation) {
42
                $state[$error->getName()][] = [
43
                    'path' => $violation->getPropertyPath(),
44
                    'message' => $violation->getMessage(),
45
                    'code' => $violation->getCode(),
46
                ];
47
            }
48
        }
49
50
        return $state;
51
    }
52
}
53