adachsoft/php-code-reader

Maintainers

Package info

gitlab.com/a.adach/php-code-reader

Issues

pkg:composer/adachsoft/php-code-reader

Statistics

Installs: 1

Dependents: 1

Suggesters: 0

Stars: 0

v0.1.0 2026-03-27 12:26 UTC

This package is not auto-updated.

Last update: 2026-03-27 11:28:55 UTC


README

A small PHP library for static code reading without executing user code, without runtime reflection in the public API and without exposing the underlying AST structures.

Requirements

  • PHP >= 8.2
  • nikic/php-parser as runtime dependency

Installation

composer require adachsoft/php-code-reader

Quick Start

use AdachSoft\PhpCodeReader\CodeReader;
use AdachSoft\PhpCodeReader\ReadOptionsDto;

$reader = new CodeReader();

// Read all classes from a file
$fileDto = $reader->readFile('/path/to/file.php');

// Read a single class by FQCN
$classFileDto = $reader->readClass(App\SomeNamespace\SomeClass::class);

// With options
$options = new ReadOptionsDto(
    visibilityMask: \AdachSoft\PhpCodeReader\VisibilityEnum::PUBLIC->value,
    includeInheritance: true,
);

$classFileDto = $reader->readClass(App\SomeNamespace\SomeClass::class, $options);

Notes

  • The library uses a static AST parser internally.
  • The public API never returns AST nodes and does not require callers to deal with any parser-specific details.