website/errors/doctrine.findOneByArgument.md
<?php declare(strict_types = 1);
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
class User
{
#[ORM\Id]
#[ORM\Column]
private int $id;
#[ORM\Column]
private string $email;
}
<?php declare(strict_types = 1);
/** @var \Doctrine\ORM\EntityRepository<User> $repository */
$user = $repository->findOneBy(['username' => 'john']);
This error is reported by the phpstan-doctrine extension.
The criteria array passed to findOneBy() contains a key (username) that does not correspond to any field or association on the entity (User). This likely indicates a typo or a reference to a field that does not exist.
Use a field name that exists on the entity:
<?php declare(strict_types = 1);
/** @var \Doctrine\ORM\EntityRepository<User> $repository */
-$user = $repository->findOneBy(['username' => 'john']);
+$user = $repository->findOneBy(['email' => '[email protected]']);