PHPackages                             type-lang/reader - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. type-lang/reader

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

type-lang/reader
================

Library for reading TypeLang AST nodes from types exposed by PHP Reflection objects

1.1.1(1y ago)65.6kMITPHPPHP ^8.1CI passing

Since Apr 1Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/php-type-language/reader)[ Packagist](https://packagist.org/packages/type-lang/reader)[ RSS](/packages/type-lang-reader/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (8)Dependencies (7)Versions (10)Used By (0)

[ ![](https://github.com/php-type-language/.github/raw/master/assets/dark.png?raw=true)](https://github.com/php-type-language) [![PHP 8.1+](https://camo.githubusercontent.com/204f5d78b32fe5b650e7f6c8a63f9ff3a82b4b7212cdf7185ade8c3ea64ca6f6/68747470733a2f2f706f7365722e707567782e6f72672f747970652d6c616e672f7265616465722f726571756972652f7068703f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/type-lang/reader) [![Latest Stable Version](https://camo.githubusercontent.com/e6925323bb4221f8d89db4d6397c7122473b5096989de104d1c7bbe72b2ee671/68747470733a2f2f706f7365722e707567782e6f72672f747970652d6c616e672f7265616465722f76657273696f6e3f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/type-lang/reader) [![Latest Unstable Version](https://camo.githubusercontent.com/03c046dd36e2acbcee54e572e6b75fec387089056f0a2e3a280ff1763620097d/68747470733a2f2f706f7365722e707567782e6f72672f747970652d6c616e672f7265616465722f762f756e737461626c653f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/type-lang/reader) [![License MIT](https://camo.githubusercontent.com/0c3b37980bf0d5e9c38276446252c75a1b4cd56f08c46f5b91b95af5f845a966/68747470733a2f2f706f7365722e707567782e6f72672f747970652d6c616e672f7265616465722f6c6963656e73653f7374796c653d666f722d7468652d6261646765)](https://raw.githubusercontent.com/php-type-language/reader/blob/master/LICENSE)

 [![](https://github.com/php-type-language/reader/workflows/tests/badge.svg)](https://github.com/php-type-language/reader/actions)

---

Converts native PHP types exposed by Reflection objects into **TypeLang**`TypeLang\Type\*` AST nodes.

Given a `ReflectionClassConstant`, `ReflectionProperty`, `ReflectionParameter`or `ReflectionFunctionAbstract`, it returns the matching type node (or `null`when no type is declared).

Full documentation is available at [typelang.dev](https://typelang.dev).

Installation
------------

[](#installation)

Install the package via [Composer](https://getcomposer.org):

```
composer require type-lang/reader
```

**Requirements:**

- PHP 8.4+

Usage
-----

[](#usage)

`TypeLang\Reader\ReflectionReader` exposes a `find*Type()` method for every kind of Reflection object:

```
$reader = new TypeLang\Reader\ReflectionReader();

$node = $reader->findFunctionType(
    new ReflectionFunction(function (): void {}),
);

var_dump($node);
// object(TypeLang\Type\NamedTypeNode) {
//   ["name"] => "void"
//   ...
// }
```

Combine it with [`type-lang/printer`](https://packagist.org/packages/type-lang/printer)to dump the resolved types of a whole class:

```
$class = new ReflectionClass(Path\To\Example::class);
$reader = new TypeLang\Reader\ReflectionReader();
$printer = new TypeLang\Printer\PrettyTypePrinter();

foreach ($class->getProperties() as $property) {
    if ($type = $reader->findPropertyType($property)) {
        echo "property {$property->name}: {$printer->print($type)}\n";
    }
}

foreach ($class->getMethods() as $method) {
    if ($type = $reader->findFunctionType($method)) {
        echo "method {$method->name}(): {$printer->print($type)}\n";
    }
}
```

Constants (`findConstantType()`) and parameters (`findParameterType()`) are read the same way.

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance68

Regular maintenance activity

Popularity22

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~103 days

Recently: every ~203 days

Total

9

Last Release

37d ago

Major Versions

1.1.1 → 2.0.0-beta12026-07-12

PHP version history (2 changes)1.0.0-beta1PHP ^8.1

2.0.0-beta1PHP ^8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/150420?v=4)[Ruslan Sharipov](/maintainers/Serafim)[@serafim](https://github.com/serafim)

---

Top Contributors

[![SerafimArts](https://avatars.githubusercontent.com/u/2461257?v=4)](https://github.com/SerafimArts "SerafimArts (5 commits)")

---

Tags

astconverterphpreaderreflectiontypesphplanguageparserreflectionconverter

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/type-lang-reader/health.svg)

```
[![Health](https://phpackages.com/badges/type-lang-reader/health.svg)](https://phpackages.com/packages/type-lang-reader)
```

###  Alternatives

[doctrine/lexer

PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.

11.2k980.3M171](/packages/doctrine-lexer)[simplehtmldom/simplehtmldom

A fast, simple and reliable HTML document parser for PHP.

1901.4M15](/packages/simplehtmldom-simplehtmldom)[type-lang/parser

Library for parsing and validating TypeLang syntax and converting it into AST nodes

5160.7k6](/packages/type-lang-parser)[corveda/php-sandbox

A PHP library that can be used to run PHP code in a sandboxed environment

238100.2k2](/packages/corveda-php-sandbox)[sbsaga/toon

🧠 TOON for Laravel — a compact, human-readable, and token-efficient data format for AI prompts &amp; LLM contexts. Perfect for ChatGPT, Gemini, Claude, Mistral, and OpenAI integrations (JSON ⇄ TOON).

6665.2k](/packages/sbsaga-toon)[goetas/xsd2php-runtime

Convert XSD (XML Schema) definitions into PHP classes

493.3k](/packages/goetas-xsd2php-runtime)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
