As PHP 8.1allows to use Newin the initializers, it's now possible to write FeedIo's constructor like this:
public function __construct(
protected ClientInterface $client = new \FeedIo\Adapter\Guzzle\Client(new \GuzzleHttp\Client()),
protected LoggerInterface $logger = new \Psr\Log\NullLogger(),
protected ?SpecificationInterface $specification = new Specification(),
) {
so in the client code, devs can create it with just:
$feedIo = new FeedIo;
or if we want to specify a logger:
$logger = new \Whatever\Complies\With\Psr\Log($file);
$feedIo = new FeedIo(logger: $logger);
Which is simpler and cleaner than trying to invoke the Factory to build FeedIo with its dependencies. As the main motivation behind the Factory was to provide a simple way to build FeedIo, this is no more relevant with PHP 8.1's new abilities. So it's time to deprecate it.
As PHP 8.1allows to use
New
in the initializers, it's now possible to writeFeedIo
's constructor like this:so in the client code, devs can create it with just:
or if we want to specify a logger:
Which is simpler and cleaner than trying to invoke the Factory to build
FeedIo
with its dependencies. As the main motivation behind theFactory
was to provide a simple way to buildFeedIo
, this is no more relevant with PHP 8.1's new abilities. So it's time to deprecate it.