0

I am working on a PocketMine-MP plugin with an API accessible by other plugins on the server. Other plugins can't use the class, so I return it (via ::class) from a method on an object that the other plugin can access. Other plugins need to extend this class.

So that gets to my problem. I can't find a way to extend from a class that's only known at runtime.

$var = Provider::class;

class ConfigProvider extends $var {}
/* $var will come from a function call otherwise this would be pointless */
Finnbar M
  • 110
  • 1
  • 5
  • I guess you could define all the classes in advance and then decide which one to instantiate with the factory method https://refactoring.guru/design-patterns/factory-method/php/example. – Matt Korostoff Dec 11 '21 at 19:21

0 Answers0