Issues (167)

src/Util/ValueHelper.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Digia\GraphQL\Util;
4
5
use Digia\GraphQL\Language\Node\ArgumentNode;
6
use function Digia\GraphQL\printNode;
7
8
class ValueHelper
9
{
10
    /**
11
     * @param ArgumentNode[] $argumentsA
12
     * @param ArgumentNode[] $argumentsB
13
     * @return bool
14
     */
15
    public static function compareArguments(array $argumentsA, array $argumentsB): bool
16
    {
17
        if (\count($argumentsA) !== \count($argumentsB)) {
18
            return false;
19
        }
20
21
        return arrayEvery($argumentsA, function (ArgumentNode $argumentA) use ($argumentsB) {
22
            $argumentB = find($argumentsB, function (ArgumentNode $argument) use ($argumentA) {
23
                return $argument->getNameValue() === $argumentA->getNameValue();
24
            });
25
26
            if (null === $argumentB) {
27
                return false;
28
            }
29
30
            return printNode($argumentA->getValue()) === printNode($argumentB->getValue());
0 ignored issues
show
It seems like $argumentA->getValue() can also be of type null; however, parameter $node of Digia\GraphQL\printNode() does only seem to accept Digia\GraphQL\Language\Node\NodeInterface, maybe add an additional type check? ( Ignorable by Annotation )

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

30
            return printNode(/** @scrutinizer ignore-type */ $argumentA->getValue()) === printNode($argumentB->getValue());
Loading history...
31
        });
32
    }
33
}
34