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
Push — master ( 44993f...7e5601 )
by Jérémiah
17:18
created

InvalidArgumentsError::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 4
crap 1
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. Consider defining an alias.

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 2
    public function __construct(array $errors, $message = '', $code = 0, \Exception $previous = null)
18
    {
19 2
        $this->errors = $errors;
0 ignored issues
show
Documentation Bug introduced by
It seems like $errors of type array is incompatible with the declared type Overblog\GraphQLBundle\Error\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 2
        parent::__construct($message, $code, $previous);
21 2
    }
22
23
    /**
24
     * @return InvalidArgumentError[]
25
     */
26 2
    public function getErrors()
27
    {
28 2
        return $this->errors;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->errors returns the type Overblog\GraphQLBundle\Error\InvalidArgumentError which is incompatible with the documented return type Overblog\GraphQLBundle\E...\InvalidArgumentError[].
Loading history...
29
    }
30
31
    /**
32
     * Return a serializable array of validation errors for each argument.
33
     *
34
     * @return array
35
     */
36 2
    public function toState()
37
    {
38 2
        $state = [];
39 2
        foreach ($this->getErrors() as $error) {
40 2
            $state[$error->getName()] = [];
41 2
            foreach ($error->getErrors() as $violation) {
42 2
                $state[$error->getName()][] = [
43 2
                    'path' => $violation->getPropertyPath(),
44 2
                    'message' => $violation->getMessage(),
45 2
                    'code' => $violation->getCode(),
46
                ];
47
            }
48
        }
49
50 2
        return $state;
51
    }
52
}
53