You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now, the phpstan-doctrine extension is able to validate that common loading patterns (findBy and friends) are only passed mapped columns, which is awesome and has saved me from more errors than I'd care to admit!
Today, I noticed that if you need to perform a more advanced query using Criteria (e.g. fields greater/less than some value), that same validation doesn't appear to take place - I can mistype a field name and get a runtime error without advance warning from the plugin. This appears to be the case with or without the "advanced" configuration (objectManagerLoader) being performed.
I expect this is a low-priority, low-volume scenario - but it would be really great if somehow these mappings could get tracked all the way through and make it into analysis.
Rough example (setup excluded):
#[Entity]
classMyModel
{
#[Column]
public ?DateTime$dueAt;
}
// ...useDoctrine\Common\Collections\Criteria;
$expr = Criteria::expr();
$criteria = Criteria::create()->where($expr->lt('due', newDateTime())); // note field name mismatchassert($em instanceof Doctrine\ORM\EntityManagerInterface);
$models = $em->getRepository(MyModel::class)->matching($criteria)->toArray();
I expect based on type information, the error would probably have to appear on the matching() call rather than in the criteria setup (since criteria on its own is basically a context-free WHERE clause); that would still be more than sufficient to get advance warning of a problem :)
The text was updated successfully, but these errors were encountered:
Right now, the phpstan-doctrine extension is able to validate that common loading patterns (findBy and friends) are only passed mapped columns, which is awesome and has saved me from more errors than I'd care to admit!
Today, I noticed that if you need to perform a more advanced query using
Criteria
(e.g. fields greater/less than some value), that same validation doesn't appear to take place - I can mistype a field name and get a runtime error without advance warning from the plugin. This appears to be the case with or without the "advanced" configuration (objectManagerLoader) being performed.I expect this is a low-priority, low-volume scenario - but it would be really great if somehow these mappings could get tracked all the way through and make it into analysis.
Rough example (setup excluded):
I expect based on type information, the error would probably have to appear on the
matching()
call rather than in the criteria setup (since criteria on its own is basically a context-free WHERE clause); that would still be more than sufficient to get advance warning of a problem :)The text was updated successfully, but these errors were encountered: