adachsoft / php-code-reader
v0.1.0
2026-03-27 12:26 UTC
Requires
- php: >=8.2
- nikic/php-parser: ^5.0
Requires (Dev)
- adachsoft/php-code-style: ^0.4.2
- friendsofphp/php-cs-fixer: ^3.94
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^13.0
- rector/rector: ^2.3
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-parseras 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.