Symfony version(s) affected
7.0.0
Description
Request declares $requestFactory as a closure:
protected static ?\Closure $requestFactory = null;
::setFactory() declares its argument as a callable:
public static function setFactory(?callable $callable): void
{
self::$requestFactory = $callable;
}
How to reproduce
Drupal calls ::setFactory() with a callable that isn't a closure:
$request_factory = new TrustedHostsRequestFactory('localhost');
Request::setFactory([$request_factory, 'createRequest']);
In Symfony 7 this results in
PHP Fatal error: Uncaught TypeError: Cannot assign array to property Symfony\Component\HttpFoundation\Request::$requestFactory of type ?Closure
Possible Solution
Either convert the callable to a closure internally with Closure::fromCallable() or change the typehint of the setFactory() argument to \Closure, unsure which is the preferred solution here.
Additional Context
No response