type-lang / printer
将TypeLange AST节点渲染为其字符串表示的库
1.0.1
2024-06-29 18:02 UTC
Requires
- php: ^8.1
- type-lang/parser: ^1.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.53
- phpstan/extension-installer: ^1.3
- phpstan/phpstan: ^1.11
- phpstan/phpstan-strict-rules: ^1.6
- phpunit/phpunit: ^10.5|^11.0
- rector/rector: ^1.0
This package is auto-updated.
Last update: 2024-09-02 07:49:20 UTC
README

TypeLang Printer的参考实现。
资源
安装
TypeLang Printer作为Composer仓库提供,您可以使用以下命令在项目根目录中安装:
composer require type-lang/printer
快速开始
$parser = new \TypeLang\Parser\Parser(); $type = $parser->parseType(<<<'PHP' array{ field1: (callable(Example,int):mixed), field2: list<Some>, field3: iterable<array-key, array{int, non-empty-string}>, Some::CONST_*, "\njson_flags": \JSON_*, ... } PHP); // Print Statement $native = new \TypeLang\Printer\NativeTypePrinter(); echo $native->print($type); // Expected Output: // array $phpdoc = new \TypeLang\Printer\PrettyPrinter(); echo $phpdoc->print($type); // Expected Output: // array{ // field1: callable(Example, int): mixed, // field2: list<Some>, // field3: iterable<array-key, array{ // int, // non-empty-string // }>, // Some::CONST_*, // "\njson_flags": \JSON_*, // ... // }