Skip to content

has falsely claims unregistered class-string is not known to container #10

@jtojnar

Description

@jtojnar

I am trying to use Symfony’s ContainerCommandLoader with this library but it does not list any commands unless I explicitly register them.

See the following minimal example:

<?php

declare(strict_types=1);

require_once __DIR__ . '/vendor/autoload.php';

class Foo {
}

$container = new Slince\Di\Container();

// $container->register(Foo::class);

var_dump($container->has(Foo::class));
var_dump($container->get(Foo::class));

which returns

bool(false)
object(Foo)#9 (0) {
}

That is a violation of section 1.1.2 Reading from a container of PSR-11 specification:

If has($id) returns false, get($id) MUST throw a NotFoundExceptionInterface.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions