PHPackages                             jcnventura/pharborist - 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. jcnventura/pharborist

ActiveLibrary

jcnventura/pharborist
=====================

Pharborist builds a syntax tree for PHP that can be traversed and manipulated.

0120.6k↓12.5%PHP

Since Aug 15Pushed 3y agoCompare

[ Source](https://github.com/jcnventura/pharborist)[ Packagist](https://packagist.org/packages/jcnventura/pharborist)[ RSS](/packages/jcnventura-pharborist/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (13)Used By (0)

pharborist
==========

[](#pharborist)

[![Pharborist logo](./docs/logo_128px.png "Pharborist logo")](./docs/logo_128px.png)

A PHP library to query and transform PHP source code via tree operations.

Roadmap
=======

[](#roadmap)

- Tests with 100% code coverage
- Integration with a third party library for PHPDoc comments
- API to ease querying and transforming of the syntax tree
- Build a PHP source code formatter using the library (Partially completed).
- Build a PHP code check using the library

Below is an example of how the API might look once its more developed:

```
// Add use declaration if it does not already exist. Use UtilityString alias if conflict
$alias = $tree->ensureUseDeclaration('Drupal\Component\Utility\String', 'UtilityString');
// Find all calls to check_plain and rename them to use String::checkPlain
$function_calls = $tree->find(Filter::functionCall('check_plain'));
foreach ($function_calls as $call) {
  $class_method_call = ClassMethodCallNode::create($alias, 'check_plain', $call->getArgumentList());
  $call->replaceWith($class_method_call);
}
```

Usage
=====

[](#usage)

```
require_once 'vendor/autoload.php';

use Pharborist\Parser;
use Pharborist\Namespaces\NamespaceNode;
use Pharborist\Filter;

$filename = $argv[1];
$tree = Parser::parseFile($filename);

// check there only one namespace declaration
$namespaces = $tree->children(Filter::isInstanceOf('\Pharborist\Namespaces\NamespaceNode'));
if ($namespaces->count() > 1) {
  die('More then one namespace at line ' . $namespaces[1]->getLineNumber() . PHP_EOL);
}
```

[![Build Status](https://camo.githubusercontent.com/c77325349972b87f5dbe4a7eb48eeba2c2a6697866f4ba204422624c3209a018/68747470733a2f2f7472617669732d63692e6f72672f67726f6d3335382f70686172626f726973742e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/grom358/pharborist)

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 76% 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/329663?v=4)[Joao Ventura](/maintainers/jcnventura)[@jcnventura](https://github.com/jcnventura)

---

Top Contributors

[![grom358](https://avatars.githubusercontent.com/u/723993?v=4)](https://github.com/grom358 "grom358 (73 commits)")[![larowlan](https://avatars.githubusercontent.com/u/555254?v=4)](https://github.com/larowlan "larowlan (12 commits)")[![jcnventura](https://avatars.githubusercontent.com/u/329663?v=4)](https://github.com/jcnventura "jcnventura (4 commits)")[![goba](https://avatars.githubusercontent.com/u/235185?v=4)](https://github.com/goba "goba (3 commits)")[![webchick](https://avatars.githubusercontent.com/u/332535?v=4)](https://github.com/webchick "webchick (1 commits)")[![martinfrances107](https://avatars.githubusercontent.com/u/1259969?v=4)](https://github.com/martinfrances107 "martinfrances107 (1 commits)")[![nickschuch](https://avatars.githubusercontent.com/u/1459612?v=4)](https://github.com/nickschuch "nickschuch (1 commits)")[![pfrenssen](https://avatars.githubusercontent.com/u/442924?v=4)](https://github.com/pfrenssen "pfrenssen (1 commits)")

### Embed Badge

![Health badge](/badges/jcnventura-pharborist/health.svg)

```
[![Health](https://phpackages.com/badges/jcnventura-pharborist/health.svg)](https://phpackages.com/packages/jcnventura-pharborist)
```

PHPackages © 2026

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