Issue #3239553 by andypost, alexpott, daffie, larowlan: \Symfony\Component\Routing\Route::getRequirement() causes deprecation errors on PHP 8.1 when it returns NULL

merge-requests/902/merge
catch 2021-09-29 10:08:20 +01:00
parent a6cba5751b
commit cd6b58e555
3 changed files with 6 additions and 5 deletions

View File

@ -25,7 +25,7 @@ class ContentTypeHeaderMatcher implements FilterInterface {
$format = $request->getContentType();
foreach ($collection as $name => $route) {
$supported_formats = array_filter(explode('|', $route->getRequirement('_content_type_format')));
$supported_formats = array_filter(explode('|', $route->getRequirement('_content_type_format') ?? ''));
if (empty($supported_formats)) {
// No restriction on the route, so we move the route to the end of the
// collection by re-adding it. That way generic routes sink down in the

View File

@ -383,10 +383,11 @@ class RestExport extends PathPluginBase implements ResponseDisplayPluginInterfac
* TRUE, when the view should override the given route.
*/
protected function overrideApplies($view_path, Route $view_route, Route $route) {
$route_formats = explode('|', $route->getRequirement('_format'));
$view_route_formats = explode('|', $view_route->getRequirement('_format'));
$route_has_format = $route->hasRequirement('_format');
$route_formats = $route_has_format ? explode('|', $route->getRequirement('_format')) : [];
$view_route_formats = $view_route->hasRequirement('_format') ? explode('|', $view_route->getRequirement('_format')) : [];
return $this->overrideAppliesPathAndMethod($view_path, $view_route, $route)
&& (!$route->hasRequirement('_format') || array_intersect($route_formats, $view_route_formats) != []);
&& (!$route_has_format || array_intersect($route_formats, $view_route_formats) != []);
}
/**

View File

@ -24,7 +24,7 @@ class AcceptHeaderMatcher implements FilterInterface {
foreach ($collection as $name => $route) {
// _format could be a |-delimited list of supported formats.
$supported_formats = array_filter(explode('|', $route->getRequirement('_format')));
$supported_formats = array_filter(explode('|', $route->getRequirement('_format') ?? ''));
if (empty($supported_formats)) {
// No format restriction on the route, so it always matches. Move it to