symfony/type-info
Symfony TypeInfo extracts and models PHP type information from reflections and type strings. Resolve scalars, objects, enums, generics, lists, and nullable types via TypeResolver, inspect identifiers and constraints, and stringify types like Collection.
HttpFoundation is used in Laravel’s HTTP layer). It leverages PHP’s reflection capabilities, which are natively supported in Laravel.phpstan/phpdoc-parser (already used in Laravel’s testing tools) and integrates with reflection-based introspection (e.g., ReflectionClass, ReflectionProperty).composer require symfony/type-info + phpstan/phpdoc-parser).TypeResolver and Type classes can be injected into Laravel services (via container) or used in standalone utilities (e.g., custom validators, API response transformers).TypeContextFactory cache) or Laravel’s cache layer.TypeIdentifier and isSatisfiedBy methods help validate types programmatically.phpdoc-parser: If Laravel’s existing PHPDoc parsing (e.g., in laravel/pint or phpunit) conflicts, conflicts may arise. Test integration early.Illuminate\Validation or Illuminate\Contracts\Container)?TypeContextFactory cache) be enabled?PropertyInfo) already used in Laravel?TypeResolver into Laravel’s service container via bind() or extend() in a service provider.
$app->bind(TypeResolver::class, function () {
return TypeResolver::create();
});
Illuminate\Validation\Rules\Type) or middleware to enforce type constraints.phpunit/phpunit type checks with this package’s Type::isSatisfiedBy().TypeResolver to resolve types from ReflectionProperty or PHPDoc.is_array(), instanceof) with Type::isIdentifiedBy().Type objects.Illuminate\Contracts\Container to resolve types for dependency injection.TypeHelper) to abstract the package’s API.TypeResolver in Laravel’s cache (e.g., Cache::remember) to avoid reflection overhead.array<string, Model>) via TypeResolver::addTypeAlias().@mixin, @template).symfony/property-info (used in Laravel’s serializer package).phpstan/phpdoc-parser@^2.0 (required by the package).symfony/type-info and phpstan/phpdoc-parser to composer.json.TypeResolver.Type::isSatisfiedBy().composer.json to avoid unexpected updates.TypeResolver subclass if Laravel’s PHPDoc or type aliases need special handling.Type objects in validators, serializers, etc.(string) $type for debugging (e.g., in Laravel’s exception handler or Tinker).Type::isSatisfiedBy() to validate types in runtime errors.telescope or laravel-debugbar to log type resolution failures.php artisan type:resolve) to test type resolution for classes/properties.Cache::forever("type:{$class}", $resolvedType)).try-catch blocks around reflection calls and fall back to default types (e.g., Type::mixed()).try {
$type = $resolver->resolve(new ReflectionProperty($class, $property));
} catch (ReflectionException $e) {
$type = Type::mixed();
}
phpstan/phpdoc-parser).Model::saved) to clear type caches.TypeResolver in validators, serializers, and tests.TypeHow can I help you explore Laravel packages today?