You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
::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.