slimphp / Slim

Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs.
http://slimframework.com
MIT License
11.98k stars 1.95k forks source link

Cannot instantiate interface Interop\Container\Exception\NotFoundException #1235

Closed kminek closed 9 years ago

kminek commented 9 years ago

above error pops-up after latest changes - this is interface only: Interop/Container/Exception/NotFoundException.php

mnapoli commented 9 years ago

For the record it seems to come from here: https://github.com/slimphp/Slim/blob/develop/Slim/Container.php#L169

akrabat commented 9 years ago

That's weird. This test code doesn't work either:

require "vendor/autoload.php";
$exception = new \Interop\Container\Exception\NotFoundException;
JoeBengalen commented 9 years ago

you did a composer update? container-interop is a new dependency.

akrabat commented 9 years ago

No, it's because NotFoundException is an interface, not a concrete class.

I'm surprised that container-interop doesn't have a concrete class.

JoeBengalen commented 9 years ago

Ohw haha thats a stupid mistake xD

silentworks commented 9 years ago

And this is one of the times when a good IDE is helpful in development. :-)

akrabat commented 9 years ago

Fixed in https://github.com/slimphp/Slim/commit/dbf4334d912d6ecab8bf993359ecad7a44298ddd

mnapoli commented 9 years ago

I'm surprised that container-interop doesn't have a concrete class.

The idea is to be less invasive to existing DI containers: they can keep throwing their own exceptions, they just have to implement the interface. Most containers do have their own NotFoundException.

And from the consumer POV, the fact that it's an interface doesn't impact the catch (NotFoundException $e) ....

akrabat commented 9 years ago

oh, I wasn't querying the interface, just that there wasn't a concrete implementation of it in addition :)

mnapoli commented 9 years ago

yes it could be added for practical purposes, but I'm afraid it could encourage some people to consider it part of the standard and to use it/type-hint against it instead of the interface (which would break if another implementation of the interface is passed later).

akrabat commented 9 years ago

Yeah, I tend to agree.