PHPackages                             tysonandre/tolerant-php-parser-to-php-ast - 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. tysonandre/tolerant-php-parser-to-php-ast

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

tysonandre/tolerant-php-parser-to-php-ast
=========================================

A pure PHP substitute for nikic/php-ast, using Microsoft/tolerant-php-parser. Can also be used to generate php-ast trees, even for files with some types of syntax errors.

1.0.1(5y ago)9143[2 issues](https://github.com/TysonAndre/tolerant-php-parser-to-php-ast/issues)MITPHPPHP &gt;=7.2CI failing

Since Oct 20Pushed 5y ago1 watchersCompare

[ Source](https://github.com/TysonAndre/tolerant-php-parser-to-php-ast)[ Packagist](https://packagist.org/packages/tysonandre/tolerant-php-parser-to-php-ast)[ RSS](/packages/tysonandre-tolerant-php-parser-to-php-ast/feed)WikiDiscussions master Synced today

READMEChangelog (4)Dependencies (3)Versions (10)Used By (0)

Tolerant-PHP-Parser to php-ast
==============================

[](#tolerant-php-parser-to-php-ast)

[![Build Status](https://camo.githubusercontent.com/1a03d64c888194b6be373075b7065bd64d8e8e8fd30e2a0b605aba1a86b32f15/68747470733a2f2f7472617669732d63692e6f72672f5479736f6e416e6472652f746f6c6572616e742d7068702d7061727365722d746f2d7068702d6173742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/TysonAndre/tolerant-php-parser-to-php-ast)[![Latest Stable Version](https://camo.githubusercontent.com/b8a734eac1fbdb5bf520f7a2acb9592a3d69146efef748c132ba0cbae2d62027/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7479736f6e616e6472652f746f6c6572616e742d7068702d7061727365722d746f2d7068702d6173742e737667)](https://packagist.org/packages/tysonandre/tolerant-php-parser-to-php-ast)[![License](https://camo.githubusercontent.com/6fc01671c13529afde76e1ff8f648502a2b657fceb07fb061a0776d0e6b03756/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7479736f6e616e6472652f746f6c6572616e742d7068702d7061727365722d746f2d7068702d6173742e737667)](https://github.com/tysonandre/tolerant-php-parser-to-php-astn/blob/master/LICENSE)

This project uses Microsoft/tolerant-php-parser to generate a tree with error tolerance, then converts from that tree to ast\\Node from [php-ast](https://github.com/nikic/php-ast)

This release supports AST version 70.

Usage
-----

[](#usage)

Using it as a slow substitute for php-ast

- [tests/TolerantASTConverter/ConversionTest.php](https://github.com/TysonAndre/tolerant-php-parser-to-php-ast/blob/master/tests/TolerantASTConverter/ConversionTest.php)

Using it as an error-tolerant substitute for php-ast (e.g. for use in IDEs)

- There are currently two modes: omitting errors and adding placeholders (e.g. `__INCOMPLETE_VARIABLE__`).
- Omitting errors only handles some common cases that come up while editing a file.
- Placeholders may change in the future.
- [tests/ASTConverter/ErrorTolerantConversionTest.php](https://github.com/TysonAndre/tolerant-php-parser-to-php-ast/blob/master/tests/ASTConverter/ErrorTolerantConversionTest.php)
- [Phan's](https://github.com/phan/phan) Language Server uses this code to do that.

Running unit tests
------------------

[](#running-unit-tests)

To run unit tests, you must install [nikic/php-ast](https://github.com/nikic/php-ast) 1.0.1+ (for the expected results to be created). You must also run `composer install` if you haven't already done so.

- For php 7.4, php-ast 1.0.3+ must be installed.
- For php 8.0, php-ast 1.0.10+ must be installed.
- Then run `vendor/bin/phpunit`

Possible Future Enhancements
----------------------------

[](#possible-future-enhancements)

- Adding a mode to never accept invalid PHP (for completeness)

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.4% 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 ~116 days

Total

4

Last Release

2044d ago

Major Versions

0.1.1 → 1.0.02020-07-03

PHP version history (2 changes)0.1.0PHP &gt;=7.0

1.0.0PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/ffb9e612975be17e9ed477553358f2ced14a904b1031305ad4da55bb3861b332?d=identicon)[TysonAndre](/maintainers/TysonAndre)

---

Top Contributors

[![TysonAndre](https://avatars.githubusercontent.com/u/1904430?v=4)](https://github.com/TysonAndre "TysonAndre (61 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")

---

Tags

phpparserast

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tysonandre-tolerant-php-parser-to-php-ast/health.svg)

```
[![Health](https://phpackages.com/badges/tysonandre-tolerant-php-parser-to-php-ast/health.svg)](https://phpackages.com/packages/tysonandre-tolerant-php-parser-to-php-ast)
```

###  Alternatives

[doctrine/lexer

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

11.2k910.8M118](/packages/doctrine-lexer)[ajthinking/archetype

Programmatically edit PHP and Laravel files.

2723.4M12](/packages/ajthinking-archetype)[simplehtmldom/simplehtmldom

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

1921.3M14](/packages/simplehtmldom-simplehtmldom)[atanamo/php-codeshift

A PHP code transformation toolkit based on 'PHP-Parser'

32158.4k1](/packages/atanamo-php-codeshift)[corveda/php-sandbox

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

23483.5k2](/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).

6115.6k](/packages/sbsaga-toon)

PHPackages © 2026

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