Hi Pedro,

Interestingly enough, I think we completly agree.

If you look at your sentence, you say: "*A container should "contain" 
services, not create services on each call, return them and then discard 
them.*"
Notice that you used the word "should", not "must".

This is exactly what the PSR is stating: "*Two successive calls to get with 
the same identifier SHOULD return the same value.*"

Because this is what we expect overall from a container.

Yet, some containers give you the freedom to have a new entry returned at 
each call. In this case, the container acts as a factory. Should we 
completely forbid that?
I see no point in putting a hard ban on it.

As you noted in your post, if the user configured its container so that a 
new dispatcher is injected in each service, this is configuration issue, 
not an issue with the standard. The user is simply misusing its container.

Also, many containers already allow creating new entries at each call to 
get. For instance, in Pimple, you can do this with the `factory` method.

If the PSR stated "*Two successive calls to get with the same identifier 
MUST return the same value.*", Pimple (and many other containers) could 
never be compatible with PSR-11.
This would be a shame as it would hinder adoption, without so far any clear 
benefits.

So I'd really want to keep this "SHOULD" in place.
However, maybe the second sentence can be worked upon.

Maybe the problematic part is: "However, depending on the implementor 
design and/or user configuration, different values might be returned, so 
user SHOULD NOT rely on getting the same value on 2 successive calls."

Of course, the user knows how it configured its container so it can rely on 
it to return the same entry on SOME known identifiers. If you have an idea 
on how to rephrase this in a more intelligible way, I'd be interested.

Best regards,
---
David.
Twitter: @david_negrier
Github: @moufmouf

Le jeudi 27 octobre 2016 15:09:06 UTC+2, Pedro Cordeiro a écrit :
>
> A container, like the name says, should "contain" services, not create 
> services on each call, return them and then discard them.
>
> 2016-10-27 11:04 GMT-02:00 Pedro Cordeiro <[email protected] 
> <javascript:>>:
>
>>
>> > Just like @mwop, I've never had an issue with this behaviour.
>> > Actually, I'd be interested in knowing what is your concern with this? 
>> Do you have an actual use case in mind that absolutely requires the 
>> container to always return the same value for all entries?
>>
>> A simple example is an event dispatcher. If I register a listener on one 
>> instance of the dispatcher and trigger an event on another instance of the 
>> dispatcher, my registered listeners will not be called. Again, this is an 
>> application concern, not a framework concern and it could be argued that 
>> this kind of issue is out-of-scope for this PSR.
>>
>> But overall, I agree with Hari that the main use case for a container is 
>> to instance the service once and always return the same instance on further 
>> calls. If you retrieve new instances from your container on each call, your 
>> container is acting like a simple factory, not as a service 
>> container/dependency injection container.
>>
>> -- 
>> 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 [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/php-fig/2c879363-54ca-4723-8a6e-01c1c9917718%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/php-fig/2c879363-54ca-4723-8a6e-01c1c9917718%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
>
> *Pedro Cordeiro*
> Produto
>  
> Phone: +55 31 3024 1115
>
> [image: Logo assinatura] 
> <http://t.rdsv6.net/wf/click?upn=9ID9MxPkUk-2FXCePkr1qGk3jeNsyS6MabLki1WEC2jiXwUuwMLrMuwyQMihLilvGuFQlwqGcwaqcxv14TZBo-2Fkx216CWkoFS-2BFrkKrfuwK-2BVQHJQ1z2pKo2dYIxq5cmilGdRu7bAh5za9wh3RLzO4nA-3D-3D_wKmGSCWlO-2F6J-2FSpm-2BxtvG5JaaAosDe4Q3OV4TyR4tzwOAocQ0H-2BKup9nj5ZrffTGmoFTZ-2FwY-2BiZ62zA9YUETNc69y4PsViv5cHctzYQM9bh8n4o9ivPlzVyx-2BJyllIEnG1Q-2F2tN-2BOSPuz0Nn8uv2ZSfKxBLUbTLKbmGhzSIZRi0PYxNI8DwJc7HKhR0hHwKI8kmuyZfBkzNrxoCmV0NXGSkn3a3WzIqMEkuwdILSgR-2Fm4Yi08v1XJ0ACOgxAjO-2BND8H30UmwWPAPr6joAP3kKuQ6WcA7R-2FTErDPH0l26ly5T8d00DrbMV7fXYAiuL24XcUrHvHs1-2BIk0UWwDs-2F72MMLfB2NOFl6lJHtovPskkuiwYJajeWEJycLVSCkLape6k6LHU-2BSZcF2Uvp2Asye0iUJTldf0eVlnrql-2BA6I-2F6d00ZAiOxLHEVlUTd1ixtgJipaRe0L1jjobMF41uBNJLCRzafhz8q5oziitdm7z7VLEgrZz2klJhql8ltu8q97TK>
>
>
> <http://t.rdsv6.net/wf/click?upn=9ID9MxPkUk-2FXCePkr1qGk3jeNsyS6MabLki1WEC2jiXwUuwMLrMuwyQMihLilvGuFQlwqGcwaqcxv14TZBo-2Fkx216CWkoFS-2BFrkKrfuwK-2BVQHJQ1z2pKo2dYIxq5cmilGdRu7bAh5za9wh3RLzO4nA-3D-3D_wKmGSCWlO-2F6J-2FSpm-2BxtvG5JaaAosDe4Q3OV4TyR4tzwOAocQ0H-2BKup9nj5ZrffTGmoFTZ-2FwY-2BiZ62zA9YUETNc69y4PsViv5cHctzYQM9bh8n4o9ivPlzVyx-2BJyllIEnG1Q-2F2tN-2BOSPuz0Nn8uv2ZSfKxBLUbTLKbmGhzSIZRi0PYxNI8DwJc7HKhR0hHwKI8kmuyZfBkzNrxoCmV0NXGSkn3a3WzIqMEkuwdILSgR-2Fm4Yi08v1XJ0ACOgxAjO-2BND8H30UmwWPAPr6joAP3kKuQ6WcA7R-2FTErDPH0l26ly5T8d00DrbMV7fXYAiuL24XcUrHvHs1-2BIk0UWwDs-2F72MMLfB2NOFl6lJHtovPskkug8HnNMYMLjg6qWS45zCOIrm0vptTNigLUcaaUyHWLPOZGe0FSmf9PqyBfjwjFw-2F88h7bt2F1L5K-2FcCWvoYbYXvfmpn1s4vRjzgBFGFfMaV4wNfAKPCaPqR75Md-2Flsd-2F7ry86VRGQ2Sc0YQoNvf1REv>*O
>  
> site com o maior número de eventos à venda do Brasil!*
>
> <http://t.rdsv6.net/wf/click?upn=9ID9MxPkUk-2FXCePkr1qGk3jeNsyS6MabLki1WEC2jiXwUuwMLrMuwyQMihLilvGuFQlwqGcwaqcxv14TZBo-2Fkx216CWkoFS-2BFrkKrfuwK-2BVQHJQ1z2pKo2dYIxq5cmilGdRu7bAh5za9wh3RLzO4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kKuQ6WcA7R-2FTErDPH0l26ly5T8d00DrbMV7fXYAiuL24XcUrHvHs1-2BIk0UWwDs-2F72MMLfB2NOFl6lJHtovPskkuhalNGqZenIN2ujgLDSs5Ohlft6K9qJu5v-2FZ3QUR1aZ9-2FzqGgwzr01AaKq7A-2FhO998bW0GWIpli0JgybJylzgA2ITDrio-2FSPnUvfYn56sgyWGIEtX1JTsSWBKJ7DZK8go8mcVbmwvX2oitsQJ8jGzKm>
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/php-fig/cd5c2e81-5967-4fd6-a119-44cf33b4598c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to