# Remove strict\_types from \`ClassMethodsHydrator\`?

**URL:** <https://discourse.laminas.dev/t/remove-strict-types-from-classmethodshydrator/1475>\
**Category:** Contributors\
**Created:** [March 25, 2020, 6:09pm UTC](https://discourse.laminas.dev/t/remove-strict-types-from-classmethodshydrator/1475 "2020-03-25T18:09:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kynx](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/kynx/32/142_2.png) [@kynx](https://discourse.laminas.dev/u/kynx)\
**Post date:** [March 25, 2020, 6:09pm UTC](https://discourse.laminas.dev/t/remove-strict-types-from-classmethodshydrator/1475/1 "2020-03-25T18:09:56Z")

</div>

A problem I’ve been putting off is slowly creeping up my board and I’d like your opinion on it.

We use `ClassMethodsHydrator` for populating models from database query results. The setters have type hints. Prior to 3.0 all worked well - although the database returns things as strings, they were coerced to the correct type by PHP.

With the introduction of `strict_types` all this is broken, so we’ve had to pin to 2.4.2 until we sort it out, either by removing the type hints and explicitly casting on assignment or by doing something even more fancy. Whatever, it’s going to be a lot of work.

Personally I’m not at all sure that a library designed to call user code should use strict\_types. I can’t see it flagged in the changelog (might have missed it) and wonder if the impact was fully thought through. If not, would you consider removing it from `ClassMethodsHydrator`? I’m happy to do a PR!

Otherwise, does anyone have suggestions for working around this?

[DB2 datatypes and laminas/laminas-hydrator - Decimal, Numeric and BigInt are treated as strings](https://discourse.laminas.dev/t/db2-datatypes-and-laminas-laminas-hydrator-decimal-numeric-and-bigint-are-treated-as-strings/1468) looks like a similar issue.

---

<div class="post-metadata">

**Author:** ![dlanz](https://avatars.discourse-cdn.com/v4/letter/d/22d042/32.png) [@dlanz](https://discourse.laminas.dev/u/dlanz)\
**Post date:** [May 14, 2020, 2:26pm UTC](https://discourse.laminas.dev/t/remove-strict-types-from-classmethodshydrator/1475/2 "2020-05-14T14:26:16Z")

</div>

Alternative to using 2.4.2 can be found here:

> [@DB2 datatypes and laminas/laminas-hydrator - Decimal, Numeric and BigInt are treated as strings](https://discourse.laminas.dev/t/db2-datatypes-and-laminas-laminas-hydrator-decimal-numeric-and-bigint-are-treated-as-strings/1468#post_3):
>
> I’m running PHP 7.3.11 with laminas/laminas-hydrator 3.0.2 against a DB2 for IBM i database. I’m using the ClassMethodsHydrator with a model class which uses typehinting (on parameters and return type) in the get/set methods. I’m noticing that DB2 Decimal, Numeric and BigInt datatypes are being treated as strings while Integer DB2 datatypes are correctly treated as a PHP [integer](https://www.php.net/manual/en/language.types.integer.php). Is there a way to have Decimal, Numeric and BigInt datatypes treated as PHP integers?
