For example, there are 2 interfaces:
interface IParser {
function toObject(string $str): IEntity;
}
interface IEntity {
static function getParser(): IParser;
}
And each child class implements interface methods with concrete objects of that class:
class Entity implements IEntity {
static function getParser(): Parser {
return new Parser();
}
}
class Parser implements IParser {
function toObject(string $str): Entity {
return new Entity();
}
}