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

TooManyArguments: Too many arguments for method Doctrine\Persistence\ObjectManager::find - saw 3 #274

Closed
michnovka opened this issue Sep 9, 2022 · 1 comment

Comments

@michnovka
Copy link
Contributor

Seems that psalm does not support locking arguments in code:

<?php

namespace App\Helper;

use App\Entity\Reseller;
use Decimal\Decimal;
use Doctrine\DBAL\LockMode;
use Doctrine\ORM\EntityManagerInterface;

class ResellerHelper
{
    public function __construct(
        private readonly EntityManagerInterface $entityManager,
    ) {
    }

    public function addCredit(int $resellerId, int $amount): void
    {
        try {
            $this->entityManager->getConnection()->beginTransaction(); // suspend auto-commit

            try {
                $reseller = $this->entityManager->find(Reseller::class, $resellerId, LockMode::PESSIMISTIC_WRITE);

getting:

 TooManyArguments: Too many arguments for method Doctrine\Persistence\ObjectManager::find - saw 3 (see https://psalm.dev/026)

However the code is totally valid as can be seen from the docs

@seferov
Copy link
Member

seferov commented Sep 11, 2022

@michnovka thanks for the report but the issue is not related to this plugin. Make sure psalm-doctrine-plugin is up-to-date https://github.com/psalm/psalm-plugin-doctrine/blob/2.x/stubs/EntityManagerInterface.phpstub

@seferov seferov closed this as completed Sep 11, 2022
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

2 participants