static function (DocumentNode $node) use (&$operationCount) : void { $tmp = Utils::filter( $node->definitions, static function (Node $definition) : bool { return $definition instanceof OperationDefinitionNode; } ); $operationCount = count($tmp); }, NodeKind::OPERATION_DEFINITION => static function (OperationDefinitionNode $node) use ( &$operationCount, $context ) : void { if ($node->name !== null || $operationCount <= 1) { return; } $context->reportError( new Error(self::anonOperationNotAloneMessage(), [$node]) ); }, ]; } public static function anonOperationNotAloneMessage() { return 'This anonymous operation must be the only defined operation.'; } }