qmetrics.net

PHP Parser

PHP library for parsing and manipulating PHP ASTs

A PHP package that parses PHP source into an abstract syntax tree for analysis and code transformation. It targets static analysis and programmatic rewriting workflows.

Overview

PHP Parser is a parser implemented in PHP whose role is to simplify static analysis and source manipulation. You install it as a Composer dependency and use it from PHP application or tooling code.

It parses modern PHP into an AST, including partial trees when input is syntactically invalid. Nodes carry accurate source locations. You can dump ASTs for inspection, pretty-print them back to PHP, and preserve formatting when only part of the tree changes.

The library includes traversal and visitor infrastructure, namespace name resolution, evaluation of constant expressions, and fluent builders for generating nodes. ASTs can serialize to JSON and round-trip again for tooling pipelines.

Documentation covers walking and modifying trees, short-circuiting traversals, parent and sibling references, lexer behavior, error recovery, and performance considerations such as reusing objects and optional Xdebug disabling.

Key features

  • PHP 7 and 8 AST parsing
  • Partial parse on invalid code
  • AST dump and pretty-print
  • Formatting-preserving transforms
  • Visitors and traversal APIs
  • Namespace resolution
  • Constant expression evaluation
  • JSON AST encoding

Use cases

  • Building static analysis tools
  • Automated PHP refactors
  • Code generators
  • Linting or custom fixers

Tags

Similar software

Prettier

Opinionated multi-language code formatter

Prettier enforces consistent style by parsing code and reprinting it with fixed rules and line wrapping. It supports many web and data languages.

  • AST-based consistent reprinting
  • Wide language and plugin support
  • Editor and CI integration
JavaScriptDetails →
★ 52.5k⟳ yesterdayMIT

Oxc

Rust-based JavaScript and TypeScript compiler toolkit

Oxc bundles a parser, linter, formatter, transformer, resolver, and minifier for JavaScript and TypeScript. Oxlint and Oxfmt run via npx for everyday lint and format tasks.

  • Oxlint ESLint-compatible linter
  • Oxfmt Prettier-compatible formatter
  • JavaScript and TypeScript parser
RustLinux, macOSDetails →
★ 23.8k⟳ todayMIT

typescript-eslint

ESLint tooling for linting TypeScript codebases

typescript-eslint connects ESLint to TypeScript syntax and ships parser services plus lint rules. It enables standard and type-aware linting for JavaScript and TypeScript projects.

  • TypeScript parser for ESLint
  • Parser services for other tools
  • Large standard rule catalog
TypeScriptDetails →
★ 16.5k⟳ todayMIT

laravel-ide-helper

Laravel IDE helper and PHPDoc generator package

A Composer package for Laravel apps that builds helper files and PHPDoc so IDEs can autocomplete facades, models, fluent APIs, and container bindings from your project source.

  • Facade PHPDoc via ide-helper:generate
  • Model property docs from database schema
  • PhpStorm meta for container bindings
PHPDetails →
★ 15k⟳ 1 month agoMIT

quicktype

Type and serializer generator from JSON, Schema, and GraphQL

Quicktype infers strongly typed models and serializers from JSON samples, JSON Schema, TypeScript, or GraphQL. Output targets many programming languages via the web app, CLI, or JavaScript API.

  • JSON and JSON Schema inputs
  • GraphQL and TypeScript sources
  • Twenty-five plus target languages
TypeScriptWeb, macOS, Windows, CLIDetails →
★ 13.9k⟳ 2 months agoApache-2.0

JavaParser

Java source parser and abstract syntax tree toolkit

JavaParser builds an AST for Java source from early language versions through current releases. Optional symbol resolution links code elements to declarations for analysis and refactoring.

  • Java 1 through modern syntax parsing
  • Programmatic AST traversal
  • Optional JavaSymbolSolver module
JavaDetails →
★ 6.2k⟳ 2 days agoApache-2.0 · open core