tdn/php-types
A small PHP utility for working with types: safely cast values, validate data against expected types, and normalize scalars, arrays and objects. Lightweight and framework-agnostic, it drops easily into Laravel or any Composer project.
Architecture fit
tdn/php-types is a primitive-obsession wrapper library: it boxes PHP scalars (Int, String, Float, Bool, Arr) into immutable value objects with validation and fluent accessors. Architecturally it is a pure domain-layer utility with no framework coupling — no service provider, no facade, no config, no Eloquent integration. That means it is trivially isolatable, but also that "Laravel/PHP package" overstates the integration surface: there is nothing to register in config/app.php or bootstrap/providers.php.
Fit depends entirely on whether the codebase already practices value-object modeling. In a typical Laravel CRUD application the wrappers would be an impedance mismatch — they collide with Eloquent casts, Illuminate\Support\Collection, json_encode serialization, and Laravel's own Str/Arr helpers. In a tightly modelled domain core (hexagonal/DDD), the pattern is legitimate, but the implementation is a decade old.
Integration feasibility
Mechanically easy, practically poor:
dev-master semantics for support purposes.Technical risk
| Risk | Severity | Notes |
|---|---|---|
License NOASSERTION |
Blocker | GitHub still cannot detect a declared license. 2.0.1 does not remediate this. Without an explicit, reviewed OSI license, commercial distribution or inclusion in a proprietary product remains a legal unknown. Counsel sign-off is still required before any code copy. |
| Reserved-word class names | Medium (was High) | 2.0.1 adds aliases to sidestep PHP 7.0 reserved keywords. Verify: do String, Int, Float, Bool classes still exist? If they are merely deprecation-shim aliases on disk, any autoloader path that touches them still fatals on PHP 8.x. Alias strategy is directionally correct but unproven against PHP 8.1–8.3. |
| Archived, no maintainer | High | Release cadence is a single 2015-era point release; no security response path, no PHP-version guarantee, no CVE triage. We remain the de facto maintainer. |
| PHP version skew | High | Release lineage targets PHP 5.x idioms (no scalar type hints, no return types, likely no strict_types). Runtime compatibility with PHP 8.1–8.3 remains unverified; the alias change reduces but does not eliminate breakage surface. |
| Zero dependents, ~7 stars | Medium | No production battle-testing, no ecosystem pressure to fix defects, no StackOverflow corpus. Unchanged by 2.0.1. |
| Serialization friction | Medium | Boxed scalars break json_encode, Eloquent attribute casting, session/queue payloads, and @props-style Blade expectations unless we write converters. 2.0.1 does not add JsonSerializable support. |
Key questions
class_alias targets resolve on PHP 8.2 without fataling on reserved words? This replaces the previous yes/no parse check with a file-level and autoload-level audit.readonly properties, and native enum cover ~90% of the value with zero dependency risk.webmozart/assert, ramsey/uuid, brick/money, native DTOs) cover the same need?Boolean::invoke addition reflect any contract change, or is it purely additive? Confirm no BC break for anyone who already vendored the class.Stack fit
Poor as a dependency; reasonable as a pattern reference. The library provides no Laravel touchpoints, and the modern PHP runtime has absorbed its core value proposition. 2.0.1's alias strategy confirms the original authors knew the design was future-hostile — but aliases are a migration aid, not an ergonomic solution. Treat it as a catalog of ideas to copy, not a component to install.
Migration path
composer.json. No new runtime dependency enters the lockfile. The 2.0.1 alias change does not alter this recommendation.final, readonly, typed properties, Stringable/JsonSerializable implementations. Skip the alias machinery entirely; alias shims are dead weight in greenfield code.Compatibility
CastsAttributes implementations per wrapper if persistence is needed — net-new code the package still does not supply.Boolean::invoke is additive and does not alter equals/toBool semantics that callers may depend on.Sequencing
Maintenance
Effectively unbounded and unfunded. The 2.0.1 release demonstrates the maintainers can still publish, but a single mid-2015-era release cycle does not establish an ongoing maintenance contract. No issue triage, no PHP-version guarantee. Every PHP minor release becomes our regression test. Any fork we create is permanently ours — headcount must be allocated, not assumed.
Support
No vendor, no community, no maintainers, low visibility. Internal support burden falls wholly on the team that adopts it. Any incident — a fatal on a PHP upgrade, a serialization bug in production — has no escalation path. The 2.0.1 fix to a decade-old risk (reserved words) is exactly the kind of issue that should have been retired in 2017, not 2.0.1.
Scaling
Runtime cost of boxing scalars in hot paths (collections, loops, hydration) is non-trivial versus native types: allocation per value plus method-call overhead. At high request volume this is measurable, though rarely decisive. The larger scaling cost is cognitive: every boundary (job payloads, cache, JSON, database) requires an explicit conversion layer that must scale with the team, not the code.
Failure modes
equals/compare semantics from the 2015 lineage may not match PHP 8's comparison rules, yielding subtle logic bugs. Boolean::invoke is new and untested against our workloads.Ramp-up
Low conceptual ramp-up (the primitive-wrapper pattern is well understood, and engineers familiar with value-object/money libraries will recognize it immediately), but negative net ramp-up in practice: onboarding engineers must learn both our domain and a bespoke, undocumented API surface with no external references or examples to search. The 2.0.1 alias layer adds a second mental model (aliased vs. original class names) that no external resource explains. New hires cannot Google it.
TPM recommendation: Do not adopt as a dependency. The 2.0.1 release is a net-neutral signal for adoption: it removes one technical objection (reserved-word parsing) while leaving the dominant blocker (license ambiguity) and the dominant risk (no maintainer, no PHP-8 guarantee, no serialization integration) untouched. Escalate the license question to legal, verify the alias behavior empirically in a spike, and satisfy the underlying requirement with native PHP 8 typed properties, readonly DTOs, and enums — with a short internal spike to prove no functional gap. The package score remains near the floor: 2.0.1 signals the project can ship, not that it will be maintained.
How can I help you explore Laravel packages today?