mirror of
https://github.com/doctrine/orm.git
synced 2026-04-29 17:33:15 +02:00
Integrate TypedExpression::getReturnType into FunctionNode by default #7569
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @beberlei on GitHub (Nov 5, 2025).
Let all function nodes return a specific type, which was added as optional feature to DQL functions in https://github.com/doctrine/orm/commit/24e9a7caaf8f2c02b33c3573486bd0ecfd8fa4a0.
This should be done in a way where users are forced to implement getReturnType, because otherwise people will keep returning the values as "string" from their custom dQL when used in scalar context.
Using a Query Hint, we can make this opt-in in ORM 3 and opt-out in ORM 4. Since we have default query hints, users can use this as a global switch and setting.
$config->setDefaultQueryHints([Query::FORCE_SCALAR_TYPE_CONVERSION => true]);orFORCE_SCALAR_TYPE_AS_STRINGS => true.@greg0ire commented on GitHub (Nov 6, 2025):
Regarding the constant, should it maybe mention functions and dql? Also, why mention scalar? We could name it
CONVERT_DQL_FUNCTION_RETURN_TYPEfor instance.@stof commented on GitHub (Jan 6, 2026):
shouldn't we always trigger a deprecation warning when registering a custom function that does not implement
TypedExpressionin ORM 3.x (we could perform the check at the configuration time to trigger it once per registered function instead of triggering it on usage).I don't see the need for a query hint to opt-in or opt-out from the deprecation for specific queries.
And in 4.0, I would make
FunctionNodeimplementTypedExpressiondirectly, which will force all its concrete child classes to implement the method of the interface.