Symfony PropertyInfo
Extracts PHP class property types, docs, and read/write info by combining reflection, PHPDoc, and Doctrine metadata.
Repository Health
Technical Analysis
PropertyInfo answers a question that comes up constantly in serializers, form builders, and API generators: “what type is this property, is it readable/writable, and what does its docblock say?” Rather than picking one metadata source, it defines a set of extractor interfaces (type, description, access, initializable, list) and ships concrete extractors for reflection (ReflectionExtractor), PHPDoc comments (PhpDocExtractor, PhpStanExtractor), constructor promotion (ConstructorExtractor), and the Serializer component’s own metadata (SerializerExtractor).
A PropertyInfoExtractor composes any number of these extractors and queries them in order until one returns an answer, so consumers get a single unified API regardless of how a given codebase documents its types — native PHP type hints, @var/@param docblocks, or Doctrine/Serializer annotations. It’s a foundational piece behind Symfony’s Serializer, Form, and API Platform’s schema generation.
What You Get
- A
PropertyInfoExtractorInterfacewith focused sub-interfaces for type (PropertyTypeExtractorInterface), description (PropertyDescriptionExtractorInterface), access (PropertyAccessExtractorInterface), and initializability (PropertyInitializableExtractorInterface) - Concrete extractors:
ReflectionExtractor(native type hints and getter/setter conventions),PhpDocExtractor/PhpStanExtractor(docblock type parsing),ConstructorExtractor(promoted constructor properties), andSerializerExtractor(Symfony Serializer metadata) - A composing
PropertyInfoExtractorthat chains multiple extractors and returns the first non-null answer, plusPropertyInfoCacheExtractorto cache results for production performance PropertyReadInfo/PropertyWriteInfovalue objects describing exactly how a property is read (public property, getter,__get) or written (public property, setter, constructor,__set)
Common Use Cases
- Powering Symfony Serializer’s normalize/denormalize type resolution so it knows what type to cast incoming JSON/XML data into
- API Platform and similar API-generation tools that need per-property type/description metadata to build OpenAPI schemas automatically
- Form component type-guessing, inferring a form field type from a bound object’s property types without manual configuration
- Any tool doing PHP object introspection (admin generators, GraphQL schema builders) that needs a single reliable source of truth for a property’s type across mixed docblock/native-type codebases
Under The Hood
Architecture — The component is built around a small interface segregation: each concern (type, description, access, initializable, list) has its own interface, and each extractor implements only the ones it supports. PropertyInfoExtractor (98 lines) is the composition root — it holds ordered lists of extractors per concern and iterates them, returning the first non-null result, which lets consumers register custom extractors without touching the built-ins. PropertyInfoCacheExtractor wraps any extractor with a PSR-6 cache to avoid repeated reflection/docblock parsing in production.
Tech Stack — Pure PHP (>=8.4.1 for this HEAD version), depending on symfony/string and the newer symfony/type-info component for type representation; dev dependencies include phpdocumentor/reflection-docblock and phpstan/phpdoc-parser for docblock-based extractors, plus optional integration with symfony/cache, symfony/dependency-injection, and symfony/serializer.
Code Quality — 66 test files cover each extractor independently plus the composing PropertyInfoExtractor; as a core Symfony component it maintains a documented CHANGELOG, typed properties/return types throughout, and sees consistent commit activity (~5/month) reflecting active maintenance rather than a frozen legacy component.
API Design — The extractor-interface pattern is the standout design choice: rather than one monolithic “get me the type” function, each concern is a separate, independently implementable interface, so a consumer (or a custom extractor) only needs to implement the sub-interfaces it cares about, and PropertyInfoExtractor handles composing them into the single-call API most consumers actually want.
Used by 2 apps in this directory
Craft CMS
CMS
A developer-first PHP CMS with clean-slate content modeling, auto-generated GraphQL API, and a four-tier edition system that scales from solo projects to enterprise deployments.
Hyvor Relay
Devops · AI Development · Monitoring
Self-hosted, open-source email API that automates DNS, manages SMTP delivery, and provides deep observability — replacing SES, Mailgun, and SendGrid with infrastructure you fully own.