phpstan-doctrine icon indicating copy to clipboard operation
phpstan-doctrine copied to clipboard

Using variadic functions with ... notation causes phpstan error

Open codeTom opened this issue 4 years ago • 1 comments

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);
	}
}

codeTom avatar Oct 16 '20 15:10 codeTom

Also getting this with phpstan-doctrine 0.12.22 and php 7.2.34. Any chance of a fix or work-around?

ianwilk52 avatar Dec 04 '20 00:12 ianwilk52