Open janedbal opened 2 days ago
Related issues:
StringType
is meant to be used on VARCHAR
data coming from a database server. Since no DBMS supported by DBAL would return a VARCHAR
as something other than a string, we don't perform any type conversion here.
I understand that, but since you are using Type
s even in other contexts (like TypedExpression
), it causes issues like described above.
given that the ORM currently does not allow registering custom boolean functions for instance (see the list of Configuration::addCustom*Function
methods), adding an explicit cast in StringType could actually break some existing cases.
While implementing better expression type inference in phpstan-doctrine, I added support even for
TypedExpression
as those are the only way how to have type inference with custom functions.But the problem is that it is designed to use
Type::convertToPHPValue
which is no-op forStringType
(it keeps whatever the value is, no casting performed). This means that all TypedExpressions returning StringType are actually not typed at all.I kept this exception in phpstan-doctrine, but this feels like a design flaw and can definitelly cause some WTF moments.
Obviously, anybody can solve it by custom Type that do cast to string, but that requires deeper knowledge of how things work.
I dont really have any proposal of how to make this better. Maybe just document it?