phpdocumentor/reflection-common
Shared building blocks for phpDocumentor’s reflection ecosystem. Provides common value objects and utilities used by reflection packages, helping model PHP code elements consistently for parsing, analysis, and documentation tooling.
phpdocumentor/reflection-common is a foundational dependency providing shared value objects and interfaces for PHP’s code analysis ecosystem — most notably used by phpdocumentor/reflection (the PHPDoc parser). You’ll rarely install it directly; instead, it’s pulled in as a transitive dependency (e.g., via composer require phpdocumentor/reflection).
First practical step: Use Fqsen::fromString() to parse and validate fully qualified structural names (e.g., \MyApp\Controllers\UserController::index). Start by exploring the src/Fqsen.php, src/Name.php, and src/QualifiedName.php classes — they form the core of type/name normalization in reflection-based tools.
@route or @apiResource tags), use Fqsen to represent controller/method references robustly instead of raw strings — avoids errors from misnormalized names or missing backslashes.Name::fromString($type) to resolve relative names (self, static) or aliased imports against context — critical when generating OpenAPI schemas or DTO builders.Element or Structure interfaces to integrate with existing reflection consumers — keeps your tool interoperable with tools like phpdocumentor/reflection, nikic/php-parser, or symfony/polyfill.symfony/property-info (used by Symfony’s Serializer and Form components) where type extraction relies on similar concepts — especially useful when building custom API resource transformers or Laravel Nova field processors.phpdocumentor/reflection or alternatives like nikic/php-parser directly — this package is best treated as a dependency of higher-level tools, not a first-party dependency.phpdocumentor/reflection (which depends on this) requires ≥7.4 and PHP 8+ features (e.g., union types,Attributes). Mixing with legacy Laravel apps (e.g., Laravel 7 on PHP 7.3) may cause runtime issues.Name = unqualified identifier (e.g., User, parent)QualifiedName = namespace-prefixed (e.g., App\Models\User)Fqsen = fully qualified structural element (e.g., \App\Models\User::find() or \App\Models\User::class)Name where Fqsen is needed (or vice versa) causes silent validation errors — always check the type signature in the library docs you’re consuming.Fqsen|string). Prefer strict usage (Fqsen::fromString($string)) over implicit conversion — Laravel’s string helpers like Str::contains() won’t understand Fqsen objects.dump($fqsen->getFullyQualifiedString()) or (string)$fqsen — never rely on __toString() implicitly. Use var_dump(get_class($object)) when tracing unknown types from docblock parsing.How can I help you explore Laravel packages today?