diff --git a/tools/gendocs.php b/tools/gendocs.php new file mode 100644 index 0000000..c293ed0 --- /dev/null +++ b/tools/gendocs.php @@ -0,0 +1,145 @@ + ['constants' => true], + \GraphQL\Executor\Executor::class, + \GraphQL\Executor\ExecutionResult::class, + \GraphQL\Executor\Promise\PromiseAdapter::class, + \GraphQL\Type\Definition\ResolveInfo::class, + \GraphQL\Validator\DocumentValidator::class, + \GraphQL\Error\Error::class => ['constants' => true, 'methods' => true, 'props' => true], + \GraphQL\Error\Warning::class => ['constants' => true, 'methods' => true], + \GraphQL\Error\ClientAware::class, + \GraphQL\Error\Debug::class => ['constants' => true], + \GraphQL\Error\FormattedError::class, + \GraphQL\Server\StandardServer::class, + \GraphQL\Server\ServerConfig::class, + \GraphQL\Server\Helper::class, + \GraphQL\Server\OperationParams::class +]; + +function renderClassMethod(ReflectionMethod $method) { + $args = Utils::map($method->getParameters(), function(ReflectionParameter $p) { + $type = ltrim($p->getType() . " "); + $def = $type . '$' . $p->getName(); + + if ($p->isDefaultValueAvailable()) { + $val = $p->isDefaultValueConstant() ? $p->getDefaultValueConstantName() : $p->getDefaultValue(); + $def .= " = " . (is_array($val) ? '[]' : Utils::printSafe($val)); + } + + return $def; + }); + $argsStr = implode(", ", $args); + if (strlen($argsStr) >= 80) { + $argsStr = "\n " . implode(",\n ", $args) . "\n"; + } + $def = "function {$method->getName()}($argsStr)"; + $def = $method->isStatic() ? "static $def" : $def; + $docBlock = unpadDocblock($method->getDocComment()); + + return <<