PHPackages                             componenta/tokenizer - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. componenta/tokenizer

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

componenta/tokenizer
====================

Token-based PHP source inspection helpers for Componenta

v1.0.0(1mo ago)095MITPHPPHP ^8.4

Since Jun 16Pushed 1mo agoCompare

[ Source](https://github.com/componenta/tokenizer)[ Packagist](https://packagist.org/packages/componenta/tokenizer)[ RSS](/packages/componenta-tokenizer/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)DependenciesVersions (2)Used By (5)

Componenta Tokenizer
====================

[](#componenta-tokenizer)

PHP declaration tokenizer used by class discovery.

Installation
------------

[](#installation)

```
composer require componenta/tokenizer
```

Requirements
------------

[](#requirements)

- PHP 8.4+

Related Packages
----------------

[](#related-packages)

PackageWhy it matters here`componenta/class-finder`Walks PHP files and uses this tokenizer for each source file.`componenta/app` and `*-app` packagesUse class discovery during application cache compilation.PHP ReflectionUsed only when `ClassInfo::$reflector` is requested and the declaration is autoloadable.What It Provides
----------------

[](#what-it-provides)

- `TokenizerInterface`: public contract for parsing PHP source.
- `Tokenizer`: token-based parser for named declarations.
- `ClassInfo`: immutable declaration metadata with lazy reflection.
- `DeclarationType`: enum for class, interface, trait, and enum declarations.

Anonymous classes are ignored. The tokenizer assumes syntactically valid PHP input.

Parsing Source
--------------

[](#parsing-source)

```
use Componenta\Tokenizer\Tokenizer;

$declarations = (new Tokenizer())->parse(
