Since Symfony 5.4 all() has a generic return type defined which is nice, but sadly due to the $key arg it is very variable what you get back: https://github.com/symfony/symfony/blob/f5a8916bad0e45ef125d128dca6c2793bd0c55d2/src/Symfony/Component/HttpFoundation/HeaderBag.php#L66-L68 It'd be great if this extension supported all() like it does get(), switching to the correct return type based on $key being present or not.