Using `class-string<T>` in a conditional `Closure` return type results in parsing error.
dantleech opened this issue · 2 comments
dantleech commented
Bug report
Using class-string<T> in a conditional Closure return type results in parsing error.
PHPDoc tag @param has invalid value (Closure(Container):($serviceId is class-string<TService> ? TService : mixed)) $service): Unexpected token "(", expected variable at offset 150
Code snippet that reproduces the problem
<?php
namespace Phpactor\Container;
use Closure;
interface ContainerBuilder
{
/**
* @template TService
* @param class-string<TService>|string $serviceId
* @param Closure(Container):($serviceId is class-string<TService> ? TService : mixed) $service
*/
public function register(string $serviceId, Closure $service): void;
}https://phpstan.org/r/17633639-1608-478a-b439-6fc15373daf5
Did PHPStan help you today? Did it make you happy in any way?
PHPStan helped me several times today, it's awesome.
mvorisek commented
A quick workaround is to wrap the conditional type twice, as the 1st parentheses are consumed (wrongly) by the return type itself.
github-actions commented
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.