layas / tdlib-schema
一个TdLib PHP Schema,具有从td_api.tl文件生成PHP对象的生成器
v1.0.2
2022-09-13 07:07 UTC
Requires
- php: ^7.4||^8.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2
- monolog/monolog: ^2.0
- nette/php-generator: ^3.3
- symfony/console: ^5.0
- symfony/monolog-bridge: ^5.0
This package is auto-updated.
Last update: 2024-09-18 21:40:29 UTC
README
一个TdLib PHP Schema,用于从td_api.tl文件生成PHP对象。
安装
通过Composer
$ composer require aurimasniekis/tdlib-schema
用法
<?php use AurimasNiekis\TdLibSchema\TdSchemaRegistry; $input = [ '@type' => 'updateOption', 'name' => 'version', 'value' => [ '@type' => 'optionValueString', 'value' => '1.6.0', ], ]; TdSchemaRegistry::fromArray($input);
将解析TdLib响应为PHP对象
class AurimasNiekis\TdLibSchema\UpdateOption#3 (3) { protected string $name => string(7) "version" protected AurimasNiekis\TdLibSchema\OptionValue $value => class AurimasNiekis\TdLibSchema\OptionValueString#2 (2) { protected string $value => string(5) "1.6.0" public ?string $tdExtra => NULL } public ?string $tdExtra => NULL }
另一个示例
<?php use AurimasNiekis\TdLibSchema\TdSchemaRegistry; $input = [ '@extra' => 'foo', '@type' => 'updateAuthorizationState', 'authorization_state' => [ '@type' => 'authorizationStateWaitTdlibParameters', ], ]; TdSchemaRegistry::fromArray($input);
将产生
class AurimasNiekis\TdLibSchema\UpdateAuthorizationState#3 (2) { protected AurimasNiekis\TdLibSchema\AuthorizationState $authorizationState => class AurimasNiekis\TdLibSchema\AuthorizationStateWaitTdlibParameters#2 (1) { public ?string $tdExtra => NULL } public ?string $tdExtra => string(3) "foo" }
重新生成对象
$ bin/generator
同时运行代码风格修复以修复代码生成风格问题
$ composer cs-fix
测试
运行PHP风格检查器
$ composer cs-check
运行PHP风格修复器
$ composer cs-fix
运行所有持续集成测试
$ composer ci-run
贡献
有关详细信息,请参阅CONTRIBUTING和CONDUCT。
许可证
有关更多信息,请参阅许可证文件。