for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Digia\GraphQL\Language\ASTBuilder;
use Digia\GraphQL\Error\SyntaxErrorException;
use Digia\GraphQL\Language\LexerInterface;
use Digia\GraphQL\Language\Node\NodeKindEnum;
use Digia\GraphQL\Language\TokenKindEnum;
class DirectivesASTBuilder extends AbstractASTBuilder
{
/**
* @inheritdoc
*/
public function supportsBuilder(string $kind): bool
return $kind === ASTKindEnum::DIRECTIVES;
}
public function build(LexerInterface $lexer, array $params): ?array
$isConst = $params['isConst'] ?? false;
$directives = [];
while ($this->peek($lexer, TokenKindEnum::AT)) {
$directives[] = $this->parseDirective($lexer, $isConst);
return $directives;
* @param LexerInterface $lexer
* @param bool $isConst
* @return array
* @throws SyntaxErrorException
protected function parseDirective(LexerInterface $lexer, bool $isConst): array
$isConst
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
protected function parseDirective(LexerInterface $lexer, /** @scrutinizer ignore-unused */ bool $isConst): array
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
$start = $lexer->getToken();
$this->expect($lexer, TokenKindEnum::AT);
return [
'kind' => NodeKindEnum::DIRECTIVE,
'name' => $this->buildAST(ASTKindEnum::NAME, $lexer),
'arguments' => $this->buildAST(ASTKindEnum::ARGUMENTS, $lexer),
'loc' => $this->buildLocation($lexer, $start),
];
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.