Port from symfony/framework-standard-edition 2.6.