On Wed, Jun 17, 2020, at 2:41 PM, Matthew Weier O'Phinney wrote:
> Per the discussions started earlier this year, I've opened two pull 
> requests to "evolve" the PSR-11 ContainerInterface to use explicit type 
> hints:
> 
> The first — https://github.com/php-fig/container/pull/27 — updates the 
> psr/container package to require PHP 7.2, and adds the `string` 
> typehint to the `$id` parameters of each of the `has()` and `get()` 
> methods. The intention is for this to be tagged as v2.0, and would 
> allow implementations:
> 
> - Immediate forwards compatibility, as the covariance/contravariance 
> rules of PHP 7.2 allow implementations to accept wider type ranges for 
> parameters.
> - The ability to make themselves forwards compatible with a later 
> release by adding return type hints, as this is be covered by the same 
> covariance/contravariance rules (implementations can return a narrower 
> set of types than their parent types).
> 
> The second — https://github.com/php-fig/container/pull/28 — builds on 
> the previous, and updates the psr/container package to add a return 
> type of `bool` to the `ContainerInterface::has()` method. The intention 
> is for this to be tagged as v3.0.
> 
> These changes follow the specification verbatim, as the `$id` arguments 
> are documented as strings. Further, I do not think this is a place 
> where the proposed `Stringable` interface for PHP 8 comes into play; 
> the context when pulling from a service container is generally to 
> provide either a class name or a string service name; using a class to 
> represent that is a sufficiently edge case that I see no good argument 
> to wait for PHP 8 so we can do `string|Stringable` in this particular 
> specification.
> 
> Finally, I have not proposed a return typehint for `get()`, as the 
> specification as written explicitly allows `mixed`. Not having a return 
> type is the technically correct approach in this context.
> 
> If there are no objections, I'd like to get these moved forward.
> 
> Thanks!

This all makes sense to me, and the PRs look good.

The one note I'd have is that an explicit `mixed` type hint is probably going 
up for vote for PHP 8 very soon; I don't know if that justifies waiting on that 
for the second PR/3.0 release.  For "mixed" probably not as it doesn't really 
offer much, but I mention it for completeness.

--Larry Garfield

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/php-fig/1cf7a387-38d8-48b6-87db-58d7cfbbd655%40www.fastmail.com.

Reply via email to