PHPackages                             tsufeki/php-lenient-parser - 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. tsufeki/php-lenient-parser

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

tsufeki/php-lenient-parser
==========================

A PHP parser written in PHP, handles partial/illegal input

0.1.5(7y ago)12.2k1BSD-3-ClausePHPPHP &gt;=7.0

Since May 11Pushed 6y ago2 watchersCompare

[ Source](https://github.com/tsufeki/php-lenient-parser)[ Packagist](https://packagist.org/packages/tsufeki/php-lenient-parser)[ RSS](/packages/tsufeki-php-lenient-parser/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (1)Dependencies (2)Versions (7)Used By (1)

PHP Lenient Parser
==================

[](#php-lenient-parser)

This is a PHP 7 parser written in PHP. It handles some partial and illegal code, producing best-effort partial syntax tree. Its purpose is to simplify static code analysis and manipulation.

It's error reporting is not complete though, i.e. it may silently accept illegal PHP input.

As this is just a parser replacement for [PHP Parser](https://github.com/nikic/PHP-Parser), go there for actual documentation.

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

[](#installation)

The preferred installation method is [composer](https://getcomposer.org):

```
php composer.phar require tsufeki/php-lenient-parser

```

Usage
-----

[](#usage)

Use the factory to get an instance of parser:

```
$parser = (new LenientParserFactory())->create();
```

Or provide your own lexer and options (no options are supported at the moment though):

```
$parser = (new LenientParserFactory())->create(LenientParserFactory::ONLY_PHP7, $lexer, $options);
```

Created parser is a drop-in replacement for `php-parser`.

Do not instantiate `LenientParser` directly, use the factory.

Info
----

[](#info)

At the moment parsing of PHP 5 is not supported, only PHP 7.

Internally, the parser is implemented as a Pratt parser (also called "Top down operator precedence parser").

License
-------

[](#license)

Same as `php-parser`, BSD - see [LICENCE](LICENSE).

Test suite and CLI script (below `bin/`, `test/` and `test_old/`) are borrowed from `php-parser` and modified.

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community23

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80.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 ~92 days

Recently: every ~49 days

Total

6

Last Release

2875d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4078572?v=4)[tsufeki](/maintainers/tsufeki)[@tsufeki](https://github.com/tsufeki)

---

Top Contributors

[![nikic](https://avatars.githubusercontent.com/u/216080?v=4)](https://github.com/nikic "nikic (619 commits)")[![tsufeki](https://avatars.githubusercontent.com/u/4078572?v=4)](https://github.com/tsufeki "tsufeki (102 commits)")[![schmittjoh](https://avatars.githubusercontent.com/u/197017?v=4)](https://github.com/schmittjoh "schmittjoh (5 commits)")[![GrahamCampbell](https://avatars.githubusercontent.com/u/2829600?v=4)](https://github.com/GrahamCampbell "GrahamCampbell (5 commits)")[![lisachenko](https://avatars.githubusercontent.com/u/640114?v=4)](https://github.com/lisachenko "lisachenko (4 commits)")[![benedyktbla](https://avatars.githubusercontent.com/u/18659685?v=4)](https://github.com/benedyktbla "benedyktbla (3 commits)")[![hason](https://avatars.githubusercontent.com/u/288535?v=4)](https://github.com/hason "hason (3 commits)")[![ovr](https://avatars.githubusercontent.com/u/572096?v=4)](https://github.com/ovr "ovr (3 commits)")[![remicollet](https://avatars.githubusercontent.com/u/270445?v=4)](https://github.com/remicollet "remicollet (2 commits)")[![jesseschalken](https://avatars.githubusercontent.com/u/1559204?v=4)](https://github.com/jesseschalken "jesseschalken (2 commits)")[![kix](https://avatars.githubusercontent.com/u/345754?v=4)](https://github.com/kix "kix (2 commits)")[![theseer](https://avatars.githubusercontent.com/u/111333?v=4)](https://github.com/theseer "theseer (2 commits)")[![igrizzli](https://avatars.githubusercontent.com/u/960937?v=4)](https://github.com/igrizzli "igrizzli (1 commits)")[![polomsky](https://avatars.githubusercontent.com/u/1607273?v=4)](https://github.com/polomsky "polomsky (1 commits)")[![prayagverma](https://avatars.githubusercontent.com/u/829526?v=4)](https://github.com/prayagverma "prayagverma (1 commits)")[![algo13](https://avatars.githubusercontent.com/u/8383815?v=4)](https://github.com/algo13 "algo13 (1 commits)")[![rmruano](https://avatars.githubusercontent.com/u/1115642?v=4)](https://github.com/rmruano "rmruano (1 commits)")[![royopa](https://avatars.githubusercontent.com/u/442991?v=4)](https://github.com/royopa "royopa (1 commits)")[![sasezaki](https://avatars.githubusercontent.com/u/42755?v=4)](https://github.com/sasezaki "sasezaki (1 commits)")[![hakre](https://avatars.githubusercontent.com/u/378849?v=4)](https://github.com/hakre "hakre (1 commits)")

---

Tags

astparserphppratt-parserstatic-analysisphpparser

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tsufeki-php-lenient-parser/health.svg)

```
[![Health](https://phpackages.com/badges/tsufeki-php-lenient-parser/health.svg)](https://phpackages.com/packages/tsufeki-php-lenient-parser)
```

###  Alternatives

[doctrine/lexer

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

11.2k942.7M157](/packages/doctrine-lexer)[simplehtmldom/simplehtmldom

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

1931.4M15](/packages/simplehtmldom-simplehtmldom)[corveda/php-sandbox

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

23796.2k2](/packages/corveda-php-sandbox)[atanamo/php-codeshift

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

32160.3k1](/packages/atanamo-php-codeshift)[voku/simple-php-code-parser

Get a simple data structure from your php code.

487.3k5](/packages/voku-simple-php-code-parser)[psx/sandbox

PHP sandbox to execute a safe subset of the PHP programming language

1948.0k1](/packages/psx-sandbox)

PHPackages © 2026

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