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

not getting QueryBuilderSetParameter exception when using complex psalm-param #270

Open
michnovka opened this issue Jul 22, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@michnovka
Copy link
Contributor

After #269 was closed, I was fixing my code to comply with doctrine recommendations and noticed that the exception is not thrown if the parameter type is defined inside an array:

The below code does give the exception QueryBuilderSetParameter: To improve performance set explicit type for objects

public function getInvoiceTransactions(Invoice $invoice): ?array
    {
        $query = $this->createQueryBuilder('t');
        $query->where('t.invoice = :invoice')->setParameter('invoice', $invoice);
        return $query->getQuery()->getResult();
    }

but this code does not:

    /**
     * @psalm-param array{
     *   invoice: Invoice
     * } $invoice
     */
    public function getInvoiceTransactions(array $invoice): ?array
    {
        $query = $this->createQueryBuilder('t');
        $query->where('t.invoice = :invoice')->setParameter('invoice', $invoice['invoice']);
        return $query->getQuery()->getResult();
    }
@AndrolGenhald AndrolGenhald added the bug Something isn't working label Jul 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants