Skip to content

Instantly share code, notes, and snippets.

@giorgiosironi
Created January 23, 2018 12:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save giorgiosironi/f421c60cd63c2918e162e27e09d6bb84 to your computer and use it in GitHub Desktop.
Save giorgiosironi/f421c60cd63c2918e162e27e09d6bb84 to your computer and use it in GitHub Desktop.
When your Value Object is so immutable, you remove a field and a non-deterministic value is readded in its place
<?php
require 'vendor/autoload.php';
$response = Symfony\Component\HttpFoundation\Response::create('HelloWorld');
$response->headers->remove('Date');
$response->headers->remove('date'); // just to be sure
var_dump($response->headers->all());
/*
array(2) {
["cache-control"]=>
array(1) {
[0]=>
string(17) "no-cache, private"
}
["date"]=>
array(1) {
[0]=>
string(29) "Tue, 23 Jan 2018 11:53:09 GMT"
}
}
*/
// see https://github.com/symfony/http-foundation/blob/master/ResponseHeaderBag.php#L39-L42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment