Factory specialization

I just knocked this up to confirm my thinking was right:

<?php

class StdFeature {

}

class AppFeature extends StdFeature {

}

class FactoryBase {

  public function new_feature() : StdFeature { return new StdFeature; }

}

class Factory extends FactoryBase {

  public function new_feature() : AppFeature { return new AppFeature; }

}

$factory = new Factory();

$feature = $factory->new_feature();

assert( is_a( $feature, 'AppFeature' ) );