我正在尝试在 php 中使用带有一些类和接口的命名空间。
看来我必须为正在使用的接口和具体类型添加一个 use 语句。这肯定是违背了使用接口的目的吗?
所以我可能有
//Interface
namespace App\MyNamesapce;
interface MyInterface
{}
//Concrete Implementation
namespace App\MyNamesapce;
class MyConcreteClass implements MyInterface
{}
//Client
namespace App;
use App\MyNamespace\MyInterface // i cannot do this!!!!
use App\MyNamespace\MyConcreteClass // i must do this!
class MyClient
{}
不是接口的全部意义在于具体类型是可互换的 - 这肯定与此相反。除非我没有正确地做某事