mirror of
https://github.com/Sysbot-org/tgscraper.git
synced 2025-01-15 21:27:32 +01:00
Converted API from Class to Trait
This commit is contained in:
parent
d406940453
commit
032684b93a
@ -47,7 +47,7 @@ if (is_dir($output)) {
|
||||
echo '> Extracting JSON scheme.' . PHP_EOL;
|
||||
$data = $generator->toJson();
|
||||
} catch (Exception $e) {
|
||||
echo '> ERROR: Unable to extract scheme:' . $e->getMessage() . PHP_EOL;
|
||||
echo '> ERROR: Unable to extract scheme: ' . $e->getMessage() . PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
@ -65,7 +65,7 @@ if (is_dir($output)) {
|
||||
echo '> Extracting JSON scheme.' . PHP_EOL;
|
||||
$data = $generator->toJson();
|
||||
} catch (Exception $e) {
|
||||
echo '> ERROR: Unable to extract scheme:' . $e->getMessage() . PHP_EOL;
|
||||
echo '> ERROR: Unable to extract scheme: ' . $e->getMessage() . PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
echo sprintf('> Outputting PHP stubs to %s.%s', realpath($output), PHP_EOL);
|
||||
|
@ -177,23 +177,20 @@ class StubCreator
|
||||
$file = new PhpFile;
|
||||
$file->addComment('@noinspection PhpUnused');
|
||||
$file->addComment('@noinspection PhpUnusedParameterInspection');
|
||||
$file->addComment('@noinspection PhpIncompatibleReturnTypeInspection');
|
||||
$file->addComment('@noinspection PhpVoidFunctionResultUsedInspection');
|
||||
$phpNamespace = $file->addNamespace($this->namespace);
|
||||
$apiClass = $phpNamespace->addClass('API')
|
||||
->setType('class');
|
||||
->setTrait();
|
||||
$apiClass->addMethod('__construct')
|
||||
->setPublic()
|
||||
->addPromotedParameter('client')
|
||||
->setType('\GuzzleHttp\Client')
|
||||
->setPrivate();
|
||||
->setAbstract();
|
||||
$sendRequest = $apiClass->addMethod('sendRequest')
|
||||
->setPublic();
|
||||
->setPublic()
|
||||
->setAbstract()
|
||||
->setReturnType(Type::MIXED);
|
||||
$sendRequest->addParameter('method')
|
||||
->setType(Type::STRING);
|
||||
$sendRequest->addParameter('args')
|
||||
->setType(Type::ARRAY);
|
||||
$sendRequest->addBody('//TODO: add your logic here');
|
||||
foreach ($this->scheme['methods'] as $method) {
|
||||
$function = $apiClass->addMethod($method['name'])
|
||||
->setPublic()
|
||||
|
Loading…
x
Reference in New Issue
Block a user