onepix/psr11-container-interface-generic

A generic, type-safe container interface (PSR-compatible) with support for retrieving items of a specified type

1.0.0 2025-01-19 19:42 UTC

This package is auto-updated.

Last update: 2025-02-19 20:00:41 UTC


README

Config

<stubs>
    <file name="vendor/onepix/psr11-container-interface-generic/ContainerInterface.php"/>
</stubs>

Usage

final class App 
{
     /**
     * @param  ContainerInterface<Controller>  $controllers
     */
    public function __construct(
        private ContainerInterface $controllers,
    ) {
    }
}
/**
 * @implements ContainerInterface<Controller>
 */
final class ControllerContainer implements ContainerInterface
{
    public function get(string $id) {}

    public function has(string $id): bool {}
}