php-fig / container

MIT License
9.93k stars 52 forks source link

Compatibility with scalar type hints #12

Closed Trainmaster closed 7 years ago

Trainmaster commented 7 years ago

It should be possible to support PSR-11 using:

<?php
class Container extends \Psr\Container\ContainerInterface {
    public function get(string $id)
    {
        // ...
    }

    public function has(string $id)
    {
        // ...
    }
}

Any ideas?

weierophinney commented 7 years ago

The spec was written targeting all currently supported versions of PHP, which at this time also includes 5.6. As such, the interfaces do not use scalar type hints.

lisachenko commented 6 years ago

Related to #19

BenMorel commented 5 years ago

Note that all versions not supporting scalar type hints are now EOL. Even PHP 7.0 is.

Isn't it time for a v2?

Jean85 commented 5 years ago

PSRs are standards, hence immutable. Creating BC means breaking the PSR itself, it's not the same as updating a normal OSS project. We started a discussion around this issue: https://groups.google.com/d/topic/php-fig/OyC3plRYhqg/discussion