radebatz/type-info-extras
Type Info Extras extends the radebatz/type-info package with additional type classes and utilities for working with complex PHP types. It helps inspect unions, intersections, generics, and docblock types, making it useful for static analysis, reflection, and code generation tools.
Start by installing the package alongside symfony/type-info (v7.3.8+ or v7.4.1+ or v8.0+). It’s designed as a drop-in extension — no complex setup required. Once installed, the extras are automatically registered via Symfony’s autowiring or manual service registration if needed. The first practical use is extending type resolution for advanced PHPDoc annotations (e.g., @phpstan-type, @psalm-type, or custom shape-like structures) that symfony/type-info alone cannot fully parse. Check the README (if available) or inspect the src/ folder for supported types — especially ObjectShapeType and improved array resolution in v1.0.6+.
TypeInfo extension to accurately resolve types from complex PHPDoc, such as @return array{foo: string, bar: int} or union types with generic-like shapes. Ideal for automated DTO/VO validation, API schemas, or ORM-like metadata extraction.symfony/type-info falls back to mixed for @phpstan-type-defined shapes, this package adds support for ObjectShapeType, enabling more precise reflection — useful in static analysis tooling or schema generation.Type instances beyond basic scalars or class names. From v1.0.10+, add explicit test cases for self-referential @phpstan-type / @psalm-type aliases and assert that resolution throws a clear exception rather than looping forever — this guards against regressions in your own type graphs.TypeError or autoloading issues.symfony/type-info — it extends it. You must still instantiate/autowire the base TypeResolver and augment it with the extras.@phpstan-type that references itself directly or indirectly) now raise an exception instead of recursing until PHP’s memory/stack limit is hit. Catch and surface this as a domain-friendly validation error when resolving untrusted PHP source, and treat it as a signal that your alias taxonomy needs a base case.symfony/type-info branches (^7.3.8, ^7.4.1, ^8.0, ^8.1-@dev), use Composer’s version constraints carefully — mixing incompatible symfony/* versions may cause runtime type errors or missing classes. Check composer.json’s require section before upgrading — v1.0.10 tidies the tooling config and explicitly states the supported type-info compatibility, so re-read it after each bump.suggests/conflicts: The package doesn’t declare conflicts or optional integrations — test in isolation if using alongside phpstan/extension-installer or phpstan/phpdoc-parser v1.x (unsupported).var_dump($type->toString()) to inspect resolved ObjectShapeType members — the internal shape keys may differ from PHPDoc string representation, especially with @phpstan-type aliases. If resolution terminates with an exception in v1.0.10+, inspect the alias chain in the stack trace to locate the cycle.How can I help you explore Laravel packages today?