You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Coerce scalar constructor properties without loss #24
Generated hydrators run without strict_types, so PHP's own coercion applies to scalar constructor parameters without a cast:
Property
Input
Result
int
"1.9", 1.9
1 (only a PHP deprecation)
int
true
1
bool
"false"
true
int
"abc"
TypeError naming a library file
Decision needed
A (proposed): explicit lossless coercion in the generated code, only for scalar parameters without a cast. int ← int, a float with no fraction, a digit string in range; float ← int/float/numeric string; string ← string/int/float; bool ← bool and FILTER_VALIDATE_BOOL strings (1/0/true/false/on/off/yes/no/""). Anything else → DataHydrationException with the field name. Fast path stays one inline type check (is_int($v) ? $v : …); the slow path is a static helper.
B:declare(strict_types=1) in the generated code. Cheapest, but "5" → int becomes an error, which breaks form and query-string input.
Notes
Hot path change: benchmarks before/after are mandatory.
Done when
PR into 3.x, tests at 100% coverage, PHPStan and Pint clean
UPGRADE-3.0.md section matches the implemented behaviour
.claude/skills/migrate-from-v2-to-v3/SKILL.md step matches it
Activity
Coerce scalar properties without loss (#37)
yuriizee commentedon Nov 27, 2026
Merged into 3.x in #37.