On 01/02/2015 01:06, Andrea Faulds wrote:
the intermediate objects are useless and nobody needs 5 new objects when
>you do it. Am I missing something here?
I assume the reason for doing this is so you can’t ever modify the object from
a distance, you must always create a new one to avoid messing up anything with
an existing handle on it.
An alternative, which I'm guessing FIG considered and rejected, is
having a mutable "builder" object, and require the user to specifically
request an immutable object when they're ready to use it:
$builder = new RequestBulider;
$a = $builder->withHeaders(...)->withBody(...)->getRequest();
$a_prime = $builder->withEncoding(...)->withETag(...)->getRequest();
--
Rowan Collins
[IMSoP]
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php