TypeLang is a declarative type language inspired by static analyzers like
PHPStan and Psalm. It
describes the type syntax found in PHPDoc comments (int[], array<string, T>,
Foo::CONST_*, T is U ? A : B, ...) and provides a set of components to work
with it.
This is the development monorepo for all TypeLang components. Each package listed below is also published as a standalone, read-only repository via git subtree split.
- Full documentation is available at typelang.dev.
- PHP Type Language specification is available here.
| Package | Description | Tests |
|---|---|---|
type-lang/types |
AST node classes (TypeLang\Type\*) — the shared vocabulary of the ecosystem. |
|
type-lang/parser |
Parses TypeLang syntax into an AST, validating the grammar. | |
type-lang/printer |
Renders AST nodes back into their string representation. | |
type-lang/reader |
Builds AST nodes from types exposed by PHP Reflection objects. | |
type-lang/phpdoc |
Parses /** ... */ DocBlock comments into a graph of description and tags. |
This repository contains all components together. Changes are contributed here and then split into the individual read-only package repositories.
git clone https://github.com/php-type-language/dev.git
cd dev
composer installCommon tasks:
composer test:unit # run the PHPUnit test suite
composer linter:check # run PHPStan static analysis
composer phpcs:check # check the code style (php-cs-fixer, dry-run)
composer phpcs:fix # apply the code style fixesTypeLang is licensed under the MIT License.