PHPackages                             raphhh/trex-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. raphhh/trex-parser

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

raphhh/trex-parser
==================

A PHP tool to parse code and extract statements

1.1.0(10y ago)070812MITPHPPHP &gt;=5.4

Since Jan 24Pushed 10y ago1 watchersCompare

[ Source](https://github.com/Raphhh/trex-parser)[ Packagist](https://packagist.org/packages/raphhh/trex-parser)[ Docs](https://github.com/Raphhh/trex-parser)[ RSS](/packages/raphhh-trex-parser/feed)WikiDiscussions master Synced 1mo ago

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

TRex parser
===========

[](#trex-parser)

[![Latest Stable Version](https://camo.githubusercontent.com/bb6dce7ce38752851d7ab43e2ffc44820d537e2d0f6b38ef18e0817b837304e3/68747470733a2f2f706f7365722e707567782e6f72672f7261706868682f747265782d7061727365722f762f737461626c652e737667)](https://packagist.org/packages/raphhh/trex-parser)[![Build Status](https://camo.githubusercontent.com/e8e5e94637637f351e34970bc46ac91bb86a38ae524f5fd331211d9dfa0d342a/68747470733a2f2f7472617669732d63692e6f72672f5261706868682f747265782d7061727365722e706e67)](https://travis-ci.org/Raphhh/trex-parser)[![Scrutinizer Quality Score](https://camo.githubusercontent.com/c1dfcc56ebcb92fe240c32f3cc2591343d088d48a4fa275d246f1bb7bc22e25c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f5261706868682f747265782d7061727365722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Raphhh/trex-parser/)[![Code Coverage](https://camo.githubusercontent.com/f3b6c43e2e58ff0d1a41c59a89ec30daa3f56ee87ef4b77d7c598fe85b638d0a/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f5261706868682f747265782d7061727365722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Raphhh/trex-parser/)[![SensioLabsInsight](https://camo.githubusercontent.com/22307046af2720db56d61dcc5b4709bde1cb9e2c19078a9329fea652a1bc8de2/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f31656166333334352d363865632d343466662d386665642d6263626434373231626231332f6d696e692e706e67)](https://insight.sensiolabs.com/projects/1eaf3345-68ec-44ff-8fed-bcbd4721bb13)[![Dependency Status](https://camo.githubusercontent.com/cba357333b0432349fe43a550cee5d02a38f8c3e8615712fcf4364e810e8e0ef/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f757365722f70726f6a656374732f3534303632656239633463313837666636313030303036662f62616467652e7376673f7374796c653d666c6174)](https://www.versioneye.com/user/projects/54062eb9c4c187ff6100006f)[![Total Downloads](https://camo.githubusercontent.com/23e64ecb8851822ca78510dc86ee6b870dccb908989371de51f531bb447c29f5/68747470733a2f2f706f7365722e707567782e6f72672f7261706868682f747265782d7061727365722f646f776e6c6f6164732e737667)](https://packagist.org/packages/raphhh/trex-parser)[![Reference Status](https://camo.githubusercontent.com/e6544bb48673c4b960f29d2b52f26d678e0191d21cc82a50b6158b2208ddb7fd/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f7068702f7261706868683a747265782d7061727365722f7265666572656e63655f62616467652e7376673f7374796c653d666c6174)](https://www.versioneye.com/php/raphhh:trex-parser/references)[![License](https://camo.githubusercontent.com/4f5376de462b62dbf2d88701f7000691cb163c96fc0f8f1d12ab4f96df7ee2fa/68747470733a2f2f706f7365722e707567782e6f72672f7261706868682f747265782d7061727365722f6c6963656e73652e737667)](https://packagist.org/packages/raphhh/trex-parser)

PHP tool to parse code and extract statements.

Install
-------

[](#install)

`$ composer require raphhh/trex-parser`

Usage
-----

[](#usage)

### ClassAnalyzer

[](#classanalyzer)

First, give the PHP code to analyze:

```
$code = 'class Foo{}';

$analyzer = new ClassAnalyzer();
$classReflections = $analyzer->getClassReflections($code);
```

You can also give a file path to the analyzer:

```
$filePath = 'MyClass.php';

$analyzer = new ClassAnalyzer();
$classReflections = $analyzer->getClassReflectionsFromFile($filePath);
```

`$classReflections` is an array of [ReflectionClass](http://php.net/manual/en/class.reflectionclass.php).

```
$objects = [];
foreach($classReflections as $className => $classReflection){
    $objects[$className] = $classReflection->newInstance();
}
```

### ClassName

[](#classname)

#### Retrieve base name

[](#retrieve-base-name)

```
$className = new ClassName('\Foo\Qux\Bar');
$className->getBaseName(); //"Bar"
```

#### Retrieve namespace

[](#retrieve-namespace)

```
$className = new ClassName('\Foo\Qux\Bar');
$className->getNamespace(); //"Foo\Qux"
```

#### Split

[](#split)

```
$className = new ClassName('\Foo\Qux\Bar');
$className->split(); //["Foo", "Qux", "Bar"]
```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity59

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 ~337 days

Total

2

Last Release

3785d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5fd55d984cf31c25f875f5636331a20f8be77e9443f2fd17fbccf1f9c4fe7a4c?d=identicon)[raphhh](/maintainers/raphhh)

---

Top Contributors

[![Raphhh](https://avatars.githubusercontent.com/u/5206490?v=4)](https://github.com/Raphhh "Raphhh (10 commits)")

---

Tags

bootstrap

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/raphhh-trex-parser/health.svg)

```
[![Health](https://phpackages.com/badges/raphhh-trex-parser/health.svg)](https://phpackages.com/packages/raphhh-trex-parser)
```

###  Alternatives

[mtdowling/jmespath.php

Declaratively specify how to extract elements from a JSON document

2.0k472.8M135](/packages/mtdowling-jmespathphp)[opis/closure

A library that can be used to serialize closures (anonymous functions) and arbitrary data.

2.6k230.0M283](/packages/opis-closure)[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M226](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M63](/packages/sabberworm-php-css-parser)[michelf/php-markdown

PHP Markdown

3.5k52.4M344](/packages/michelf-php-markdown)[jms/metadata

Class/method/property metadata management in PHP

1.8k152.8M88](/packages/jms-metadata)

PHPackages © 2026

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