Skip to content

A TdLib PHP Schema with generator for generating PHP objects from td_api.tl file

License

Notifications You must be signed in to change notification settings

aurimasniekis/php-tdlib-schema

Repository files navigation

PHP TdLib TD-API Schema

Latest Version on Packagist Software License Build Status Code Quality Total Downloads

Email

A TdLib PHP Schema with generator for generating PHP objects from td_api.tl file.

Install

Via Composer

$ composer require aurimasniekis/tdlib-schema

Usage

<?php

use AurimasNiekis\TdLibSchema\TdSchemaRegistry;

$input = [
    '@type' => 'updateOption',
    'name' => 'version',
    'value' => [
        '@type' => 'optionValueString',
        'value' => '1.6.0',
    ],
];

TdSchemaRegistry::fromArray($input);

Will parse TdLib response to PHP Objects

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
}

Another example:

<?php

use AurimasNiekis\TdLibSchema\TdSchemaRegistry;

$input = [
    '@extra' => 'foo',
    '@type' => 'updateAuthorizationState',
    'authorization_state' => [
        '@type' => 'authorizationStateWaitTdlibParameters',
    ],
];

TdSchemaRegistry::fromArray($input);

Will produce:

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"
}

Regenerate Objects

$ bin/generator

Also run code style fix to fix code generation style issues:

$ composer cs-fix

Testing

Run PHP style checker

$ composer cs-check

Run PHP style fixer

$ composer cs-fix

Run all continuous integration tests

$ composer ci-run

Contributing

Please see CONTRIBUTING and CONDUCT for details.

License

Please see License File for more information.

About

A TdLib PHP Schema with generator for generating PHP objects from td_api.tl file

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages