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.
TypeResolver to enforce strict type contracts in API responses or request validation (e.g., OpenAPI/Swagger generation).ReflectionProperty types to infer schema fields).(string) Type::generic(Type::object(Collection::class), Type::int()) → "Collection<int>").is_int($value)) with declarative rules using Type::isSatisfiedBy().Type::list(Type::nullable(Type::bool())) for arrays of optional booleans).Type::fromValue($entity->getId()) → int).Adopt if:
Look elsewhere if:
is_array(), gettype()). This package is overkill for simple use cases.zod or io-ts instead.#[SensitiveParameter]). Use phpstan/phpstan directly.For Executives: "Symfony’s TypeInfo component lets us automate type safety across our PHP stack—reducing bugs in APIs, validation, and serialization while cutting dev time. For example, instead of manually documenting types in Swagger or validating requests, we can auto-generate schemas from Reflection, ensuring consistency. It’s a low-risk, high-reward investment: MIT-licensed, Symfony-backed, and used in production by thousands of projects. ROI comes from fewer runtime errors and faster tooling development."
For Engineers: *"This is the Swiss Army knife for PHP type introspection. Need to:
Type::isSatisfiedBy(fn (Type $t) => $t->isIdentifiedBy(TypeIdentifier::INT)))?TypeResolver to replace manual type checks in your validation layer, then expand to schema generation or debugging tools."*How can I help you explore Laravel packages today?