psalm-plugin-doctrine
psalm-plugin-doctrine copied to clipboard
QueryBuilderSetParameter: Create page on psalm.dev to show best practice
I'm talking about:
QueryBuilderSetParameter - src/Repository/... - To improve performance set explicit type for objects $queryBuilder->andWhere('a.user = :user')->setParameter('user', $user);
Would it be possible to create a linked "help" page for this? Like e.g. here:
PropertyNotSetInConstructor - ... (see https://psalm.dev/074)
Cause I'd like to collect some best practices there. Some questions:
- At https://github.com/psalm/psalm-plugin-symfony/issues/158 there is a link to https://github.com/doctrine/orm/issues/8113. But that talks only about
DateTime*(not other objects). And inDoctrine\DBAL\Types\Typesthis one is the only object I can see where adding the 3rdtypeargument to->setParameter()does make sense. So the error message "set explicit type for objects" in fact only makes sense forDateTime? - For all other cases, it's not possible to set the type, but it's recommended to switch from the entire object to some property?:
->andWhere('a.userId = :userId')->setParameter('userId', $user->getId())
I have the same question here.
The QueryBuilderSetParameter is quite scary when you see the title Massive performance issue, however to me it should be a 'WARNING' level instead of 'ERROR' level.
Would it be possible to create a linked "help" page for this? Like e.g. here:
Technically you can override $link property of IssueData instance returned from toIssueData() method of the issue class. $link is declared readonly in docblock and IssueData is an internal class though, so that's not something we officially support at the moment.