Deprecation of Strategy/BooleanStrategy
vaclavvanik opened this issue · 5 comments
I use Strategy\BooleanStrategy
to hydrate and extract bool|string
values with PostgreSQL (pdo pgsql needs '1' as true
and '0' as false
). As of v4.2 is Strategy\BooleanStrategy
deprecated and replaced with Strategy\ScalarTypeStrategy
.
Old way:
$boolStrategy = new Hydrator\Strategy\BooleanStrategy('1', '0');
New way is much more verbose:
$extract = static function (bool $value): string {
return $value ? '1': '0';
};
$hydrate = static function (string $value): bool {
return $value === '1';
};
$closureStrategy = new Hydrator\Strategy\ClosureStrategy($extract, $hydrate);
I think the deprecation of Strategy\BooleanStrategy
should be reconsidered.
@vaclavvanik
Can you create a pull request? An update of the documentation for the BooleanStrategy
should be included which describes the additional possibility compared to the ScalarTypeStrategy
.
@froschdesign which branch should I target? 4.2.x?
@vaclavvanik
Correct!
@froschdesign PR #67 prepared :-)
Yah, I'd say hydrators should work both ways and since the ScalarTypeStrategy
does only work in one-direction, I am +1 on removing the deprecation.
/cc @weierophinney