phpstan-doctrine
phpstan-doctrine copied to clipboard
Using variadic functions with ... notation causes phpstan error
Using ...$arguments
notation when calling functions such as orX(...$orParts)
results in phpstan error
In Base.php line 95:
Expression of type '' not allowed in this context.
This appears to be a phpstan-doctrine specific issue as without it phpstan detects no issues, but that may be because it doesn't run the same checks.
A minimal example which reproduces the issue on my setup (phpstan-doctrine 0.12.17, phpstan 0.12.49, php 7.3.19, symfony 3.4.40):
<?php
use Doctrine\ORM\EntityManagerInterface;
class PhpStanVariadicIssue
{
public function __construct(EntityManagerInterface $em)
{
$qb = $em->createQueryBuilder();
$orParts = ["1 = 2", "2 = 2"];
$qb->expr()->orX(...$orParts);
}
}
Also getting this with phpstan-doctrine 0.12.22 and php 7.2.34. Any chance of a fix or work-around?