phpstan-doctrine
phpstan-doctrine copied to clipboard
Decimal col type throws Property type mapping mismatch:
I have a decimal column in one of the entities, annotating its type with float throws this:
database can contain string but property expects float.
I'm not sure what the issue is here, keeping the type="float" in @ORM\Column doesn't help the same error is throw, what type should i annotate my column with.
Annotating it with float|int|string works but I'm not sure its correct
I'm not sure how this works in PDO, the DecimalType simply returns the value returned by the database driver: https://github.com/doctrine/dbal/blob/37f252326bdc4f83754e114fb64aa0763e73fa48/src/Types/DecimalType.php#L28-L34
So I guess it can really be float|int|string depending on some outside factors.
Is a numeric-string a better type for Decimal columns?