Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

php-type-language/printer

Repository files navigation


PHP 8.1+ Latest Stable Version Latest Unstable Version License MIT

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_*,
// ...
// }

About

πŸ–ŒοΈ Library for rendering TypeLange AST nodes into it's string representation

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Languages

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /