mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
LeftJoin with FQDN as join generates TypeError #6797
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 @rrajkomar on GitHub (Aug 3, 2021).
Bug Report
Summary
Using the \Doctrine\ORM\QueryBuilder::leftJoin method with a FQDN as first parameter causes a type error on the first instruction.
Assuming all namespaces imports and all classes are correctly defined and loaded, a call looking like the following:
will trigger a type error on :
Current behavior
This error is triggered :
Type error: substr() expects parameter 3 to be int, bool given
How to reproduce
Simple use a leftJoin with a FQDN class as the first parameter
Expected behavior
The join should work without issues
Fix
The call should include a typecast to int just as it was done on the innerJoin method.
@dunglas commented on GitHub (Sep 29, 2021):
It looks like a PHP bug to me. According to the documentation:
(emphasis mine)
@drealecs commented on GitHub (Sep 30, 2021):
The documentation needs to be improved.
Also, the documentation is correct if strict types are off as
falseis coerced to0.When strict types are on, you must respect the method signature and either pass an
intornull.Your fix is correct and where it needs to be.
strict_typeswhere enabled in 2.10.x and 3.0.x and this is a change that must go with that. Unfortunately there were not enough tests to catch it initially.