On May 1, 2015 8:05 PM, "Dracony" <draco...@gmail.com> wrote:
>
> Well to be fair handling appending would be rather simple: get existing, array_merge and use withAttributes() to set the results back.
You completely missed my point: the problem is that you're assuming it should behave a certain way (overwrite), while others indicated such a method should behave quite differently (merge). Because expectations differed, we either needed to have methods to support each use case, or remove the method entirely. We opted for the latter.
I do not disagree that implementing either case is relatively easy; my point was that, to reduce the size of the interface and to reduce ambiguity of expectations, we choose to remove such methods.
> To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/aa5af324-6288-4c0d-9ec2-4d1f8cecb0ea%40googlegroups.com.
What are the pros of having it append attributes vs replace them ? As I already proved appending can be easily achieved by getting and replacing. While the reverse is not true
You received this message because you are subscribed to a topic in the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/php-fig/_DOlNaYrVbY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to php-fig+u...@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/CAJp_myWMZ3J6Vi57qvD63dP5vNYdb%2BN9%2BPkzU%2BacsNJeuZUSxA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/CANamvv3n7KJdLEsBavpr6VngCiho5Q5XypNntStuLs0L%3DLd98g%40mail.gmail.com.
Why would anyone think that withAttributes() somehow implies appending ? Lets look at header methids, we have withHeader() and withAddedHeader() . This makes it clear that only methods containing Added add things instead of replacing.
Every other with* method replaces contents, how would anyone be confused by that method name.
Furthemore this is an amazing nonissue, since even if someone somehow misreads the docblock he will notice how the behavior actually works after first try.
So what you say is that its better to sacrifice a widely used usecase and force people to write same code to remove attrs one by one and add new ones, while doing unnecessary clone() calls all the time, just so some random person hypothetically doesnt get confused ?
This is silly.
--
You received this message because you are subscribed to a topic in the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/php-fig/_DOlNaYrVbY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to php-fig+u...@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/CAJp_myUdK-HM19YG5mjru5Q-udRBP8yMh6EdQujqvQ4Li_BFFg%40mail.gmail.com.
So choose a word that isn't ambiguous.
--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+u...@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/CAJp_myUdK-HM19YG5mjru5Q-udRBP8yMh6EdQujqvQ4Li_BFFg%40mail.gmail.com.
withAttributes that replaces attributes
withAttributes() and withAddedAttributes()?--
You received this message because you are subscribed to a topic in the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/php-fig/_DOlNaYrVbY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to php-fig+u...@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/adc7b7bc-6f95-4466-8d02-3b10435c4145%40googlegroups.com.
"Why don't we just add another method?" you and others ask. Because
then the user has to know how each works, and the methods become
redundant with the API we have already exposed.
And, to be honest, we then have to debate whether or not the one that
merges should do so recursively, and what algorithm is most
appropriate...
The case for replace vs add is easily solved if you consider that you can use "replace" to achieve "add" but not vice versa. So replacing is more versatile and thus superior.
As for the array_merge problem this again is a huge non-issue since it is not going to be called within the implementation anyway. The code that uses the interface can manipulate attributes however it likes before calling the withAttributes method. This makes array_merge vs array_merge_recursive entirely the problem of your hipothetical router library not the interface implementation one .
--
You received this message because you are subscribed to a topic in the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/php-fig/_DOlNaYrVbY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to php-fig+u...@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/B45A5138-D542-480E-89F2-E0B28CDB6EE6%40gmail.com.
On Sun, May 3, 2015 at 4:35 PM, Roman Tsjupa <draco...@gmail.com> wrote:
> withAttributes that replaces attributes
>
> On May 3, 2015 10:12 PM, "Christopher Pitt" <cgp...@gmail.com> wrote:
>>
>> withAttributes() and withAddedAttributes()?
...
Yes, you could say, "withAttributes()" always replaces. But then
you're left with a rather ugly paradigm that will be quite common:
$request->withAttributes(array_merge($request->getAttributes(),
$routeMatches);
(And should that be array_merge? or array_merge_recursive? or
array_replace_recursive()?)
...
Well so you would say array_merge feels more dirty then removing and adding attributes one by one ?
--
You received this message because you are subscribed to a topic in the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/php-fig/_DOlNaYrVbY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to php-fig+u...@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/053b4a63-1ab8-40bc-b302-493ad1649a3d%40googlegroups.com.
Well so you would say array_merge feels more dirty then removing and adding attributes one by one ?
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/CAJp_myV%3Drzd5W%3Dbsnpp0Q5M9H0zW49h6Ut2FfH-AUiJFrC5UFQ%40mail.gmail.com.