Closed hemberger closed 1 year ago
Passing a benevolent (float|int) to an int column.
do you say a regular float|int
works but a benevolent (float|int)
does not?
I kind of can't believe it :)
do you say a regular
float|int
works but a benevolent(float|int)
does not? I kind of can't believe it :)
Given an int
column, float|int
is an error (as it should be), but currently (float|int)
is also an error, and I was thinking that perhaps it shouldn't be given this documentation about them:
Benevolent unions aren’t checked strictly even at the highest level
But if you say otherwise, I'll take your word for it! :)
Benevolent unions aren’t checked strictly even at the highest level
i guess you took that sentence from the phpstan docs somewhere? If so: it describes how native phpstan rules behave according to analysis level.
atm the phpstan-dba rules do not at all depend on phpstan rule levels (which does not mean that our RuntimeConfig could take inspiration of the ideas behind phpstan-src rules or implement similar ideas).
i don‘t know how phpstan-dba rules work with benevolent unions atm. We would need unit tests to verify it
thank you
Using
$databaseType->isSuperTypeOf($valueType)
to check if the input value type matches the database column type was too strict. It was incorrectly raising errors for various legal scenarios, e.g.:The
accepts
method correctly handles these cases. Add extra logic forMixedType
, since mixed types are always accepted.NOTE: The
MixedType
case may be demoted to a debug-mode-only error, depending on the answer to https://github.com/staabm/phpstan-dba/pull/564#discussion_r1141097432.