Closed therealgaxbo closed 1 year ago
To reproduce:
POSTAL_CODE='09001'
class Example
{
public readonly string $postalCode;
}
$example = $mapper->map(Example::class);
Fatal error: Uncaught Crell\EnvMapper\TypeMismatch: Could not read environment variable for "postalCode" on Some\Namespace\Example. A string was expected but int provided. in C:...\vendor\crell\envmapper\src\TypeMismatch.php:15
Fixed in master
. The new approach is very slightly slower, but still acceptable, especially as it's more robust. Thanks!
Strings like telephone numbers are numeric but should not be modelled as integers. If there is a leading zero this will even cause data corruption.
Probably should only cast as needed to match the property type.