type-lang / printer
Library for rendering TypeLange AST nodes into it's string representation
Installs: 14 839
Dependents: 4
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^8.1
- type-lang/parser: ^1.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.53
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^1.11
- phpstan/phpstan-strict-rules: ^1.6
- phpunit/phpunit: ^10.5|^11.0
- rector/rector: ^1.1
This package is auto-updated.
Last update: 2024-11-08 16:22:03 UTC
README
Reference implementation for TypeLang Printer.
Resources
Installation
TypeLang Printer is available as Composer repository and can be installed using the following command in a root of your project:
composer require type-lang/printer
Quick Start
$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_*, // ... // }