2017 © Pedro Peláez
 

library pharborist

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

image

grom358/pharborist

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

  • Monday, September 21, 2015
  • by grom358
  • Repository
  • 6 Watchers
  • 48 Stars
  • 11,448 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 6 Forks
  • 25 Open issues
  • 13 Versions
  • 4 % Grown

The README.md

pharborist

Pharborist logo, (*1)

A PHP library to query and transform PHP source code via tree operations., (*2)

Roadmap

  • [ ] Tests with 100% code coverage
  • [x] 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:, (*3)

// 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

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, (*4)

The Versions

21/09 2015

dev-master

9999999-dev

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

  Sources   Download

GPL

The Requires

 

The Development Requires

by Cameron Zemek

syntax standards

13/06 2015

dev-indexer_prototype

dev-indexer_prototype

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

  Sources   Download

GPL

The Requires

 

The Development Requires

by Cameron Zemek

syntax standards

23/04 2015

dev-indexer_tests

dev-indexer_tests

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

  Sources   Download

GPL

The Requires

 

The Development Requires

by Cameron Zemek

syntax standards

22/04 2015

dev-bug_206

dev-bug_206

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

  Sources   Download

GPL

The Requires

 

The Development Requires

by Cameron Zemek

syntax standards

22/04 2015

dev-indexer

dev-indexer

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

  Sources   Download

GPL

The Requires

 

The Development Requires

by Cameron Zemek

syntax standards

03/02 2015

dev-use-methods

dev-use-methods

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

  Sources   Download

GPL

The Requires

 

The Development Requires

by Cameron Zemek

syntax standards

11/11 2014

dev-name_resolution

dev-name_resolution

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

  Sources   Download

GPL

The Requires

  • php >=5.4

 

The Development Requires

by Cameron Zemek

syntax standards

25/10 2014

dev-control_structures_ns

dev-control_structures_ns

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

  Sources   Download

GPL

The Requires

  • php >=5.4

 

The Development Requires

by Cameron Zemek

syntax standards

25/10 2014

dev-indent

dev-indent

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

  Sources   Download

GPL

The Requires

  • php >=5.4

 

The Development Requires

by Cameron Zemek

syntax standards

13/10 2014

dev-array_set_key_value

dev-array_set_key_value

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

  Sources   Download

GPL

The Requires

  • php >=5.4

 

The Development Requires

by Cameron Zemek

syntax standards

11/09 2014

dev-scalarCastMethods

dev-scalarCastMethods

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

  Sources   Download

GPL

The Requires

 

by Cameron Zemek

syntax standards

01/09 2014

dev-isScalar

dev-isScalar

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

  Sources   Download

GPL

The Requires

 

by Cameron Zemek

syntax standards

15/08 2014

dev-builder

dev-builder

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

  Sources   Download

GPL

The Requires

 

by Cameron Zemek

syntax standards