Check headers sent before sending PHP response

If the response contents has been sent before an error occurs, PHP
triggers the warning "Cannot modify header information - headers already sent"

This change ensure that the error message is echoed, while it's impossible
to change the HTTP status code and headers.
Merge branch '2.3' into 2.4

* 2.3:
  Check headers sent before sending PHP response
  Fixed ACE domain checks on UrlValidator (#10031)
  handle array root element
Merge branch '2.4'

* 2.4:
  Check headers sent before sending PHP response
  Fix issue symfony/symfony#10345 '[FrameworkBundle][Console] container:debug --parameter="" not working anymore'
  Fixed ACE domain checks on UrlValidator (#10031)
  handle array root element