jjzjj

SingletonInterface

全部标签

php - 是否可以在 PHP 中定义接口(interface) Singleton?

我想定义一个Singleton基类型,用户将从中派生他的类,所以这就是我的想法:interfaceSingletonInterface{publicstaticfunctiongetInstance();}abstractclassSingletonAbstractimplementsSingletonInterface{abstractprotectedfunction__construct();finalprivatefunction__clone(){}}但是使用这种方法,用户可以实现这个单例......classBadImplimplementsSingletonInterfa