Hi,
I don't know if it is possible to fix that but:
/**
* @param \Swoole\Http\Request $request
* @param \Swoole\Http\Response $response
* @param array $uri
* @return false|null|mixed
*/
protected function _dispatch(Swoole\Http\Request $request, Swoole\Http\Response $response, array $uri)
{
$handlers = [
'*' => Handler\Api::class
];
$currentUri = reset($uri);
foreach($handlers as $matchUri => $handler)
{
if($currentUri === $matchUri || $matchUri === '*')
{
/**
* @var class-string<\PhpCliShell\Application\Firewall\Gui\Handler\HandlerInterface> $handler
*/
$handler = new $handler($this->_manager->logger);
return $handler->handle($request, $uri);
}
}
return false;
}
When we use a variable to instanciate a class, we can use the class-string
type to help the resolver to retrieve the right type.
Here
$handler
has the typestring
The type class-string
can be inline like the example above or about a method argument.
The workaround is to declare the instance type with /** @var ... */
instead of the variable type used to instanciate the new object.
Thank you.