Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Type Info Extras Laravel Package

radebatz/type-info-extras

Extra type information helpers for radebatz/type-info. Adds additional utilities for describing, inspecting, and working with PHP types, improving reflection-based tooling and type metadata in your projects.

View on GitHub
Deep Wiki
Context7

Getting Started

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+.

Implementation Patterns

  • Enhanced Property Type Resolution: Use the 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.
  • Conditional Shape Types: Where 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-Aware Formatters & Serializers: Wrap your type resolver with the extras’ extensions to produce accurate type metadata for GraphQL, OpenAPI, or DTO hydration layers.
  • Testing & Mocking: When writing tests for type-sensitive services, use the extras to assert against resolved Type instances beyond basic scalars or class names.

Gotchas and Tips

  • Strict PHP Version Dependency: Requires PHP ≥8.2 — ensure your dev/test environments match. Failure here leads to cryptic TypeError or autoloading issues.
  • No Standalone Usage: This is not a replacement for symfony/type-info — it extends it. You must still instantiate/autowire the base TypeResolver and augment it with the extras.
  • Version Pinning on Dependencies: With support for multiple 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.
  • Empty Composer 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).
  • Debug Tip: Enable Xdebug or var_dump($type->toString()) to inspect resolved ObjectShapeType members — the internal shape keys may differ from PHPDoc string representation, especially with @phpstan-type aliases.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport