Sammaye/MongoYii

Strings converted to int.

shruggr opened this issue · 2 comments

In EMongoModel->setAttributes there is elaborate logic to determine if a string consists of a value which could be cast as an integer and if so, the cast is applied:
$this->$name=!is_bool($value) && !is_array($value) && !is_object($value) &amp;&amp; preg_match('/^([0-9]|[1-9]{1}\d+)$$/' /* Will only match real integers, unsigned */, $value) > 0 && ( (PHP_INT_MAX > 2147483647 && (string)$value < '9223372036854775807') || (string)$value < '2147483647') ? (int)$value : $value;

This is very messy and requires much re-casting in our system. Is there a reason for this casting in the first place?

The reason was for forms, more specifically 0/1 checkboxes but since then it has been worked into many projects as such it was never taken out

Thanks for your feedback. We'll just override it in our inherited classes.