Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QueryBuilderSetParameter: Create page on psalm.dev to show best practice #131

Open
ThomasLandauer opened this issue Nov 13, 2022 · 2 comments

Comments

@ThomasLandauer
Copy link

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:

  1. At QueryBuilderSetParameter error w/ typed variables psalm-plugin-symfony#158 there is a link to Massive performance issue with setParameter() and DateTime* objects doctrine/orm#8113. But that talks only about DateTime* (not other objects). And in Doctrine\DBAL\Types\Types this one is the only object I can see where adding the 3rd type argument to ->setParameter() does make sense. So the error message "set explicit type for objects" in fact only makes sense for DateTime?
  2. 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())
@allansun
Copy link

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.

@weirdan
Copy link
Member

weirdan commented Dec 31, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants