vanio/type-parser
Vanio Type Parser is a lightweight PHP library that turns type declaration strings—unions, intersections, nullable types, generics, arrays and callables—into structured, inspectable objects, making it easy to analyze, validate and manipulate type information for reflection, tooling and code generati...
@var annotation?" That makes it a candidate for the buy/borrow side of build-vs-buy analysis whenever a roadmap item depends on reading PHPDoc types — DTO hydration, serializer/denormalizer layers, admin-panel form generation, API schema/documentation generators, or static-analysis-style linting rules.@var comments (common in Laravel codebases handling Collection<int, Model> style annotations), this is a reference point for consolidating that logic behind one internal abstraction instead of maintaining several fragile parsers.Consider it when all of the following hold:
@var PHPDoc types parsed into a usable representation, and Laravel/PHP native reflection does not cover your needs (generics like array<int, Foo>, class-string unions, array shapes).Look elsewhere when:
phpstan/phpdoc-parser for rigor, phpdocumentor/reflection-docblock, or symfony/property-info for framework-agnostic type extraction. Prefer those unless this package's specific output shape saves you real work.For executives (one paragraph): We evaluated a small open-source PHP library for reading type information from code comments. It solves a real but narrow engineering problem that several internal tooling ideas depend on — generating forms, API docs, and data-mapping code automatically. The cost is near zero and the license is permissive, but the project has minimal adoption (7 stars, no known dependents), so we should treat it as a component we own rather than a vendor we rely on. Recommendation: use it as a time-saver inside a prototype, behind our own interface, with no public commitment — not as a platform dependency.
For engineering (the substance): It parses property types declared in @var PHPDoc annotations. That is useful precisely where native reflection falls short — generic collections, class-string types, and array shapes — and it is framework-agnostic, so it works in Laravel packages, CLI tools, and queue contexts alike. The tradeoff is maturity: single-maintainer, negligible ecosystem usage, no evidence of edge-case hardening. The mitigation is architectural, not contractual: wrap it in an internal TypeResolver interface, pin the version, and write characterization tests around the annotations we actually support. If it is abandoned or proves wrong on our inputs, we swap the implementation — or vendor the MIT source — without touching call sites.
Recommendation: Approve as an internal, low-blast-radius utility for prototyping, with a one-sprint timebox and an explicit exit criterion. Do not adopt it for customer-facing or release-blocking paths until it has survived a real workload and we have decided whether to fork it. Reassess against phpstan/phpdoc-parser and symfony/property-info before writing any long-lived code on top of it.
How can I help you explore Laravel packages today?