Pull merge.
[yaffs-website] / vendor / consolidation / robo / src / Contract / InflectionInterface.php
1 <?php
2 namespace Robo\Contract;
3
4 interface InflectionInterface
5 {
6     /**
7      * Based on league/container inflection: http://container.thephpleague.com/inflectors/
8      *
9      * This allows us to run:
10      *
11      *  (new SomeTask($args))
12      *    ->inflect($this)
13      *    ->initializer()
14      *    ->...
15      *
16      * Instead of:
17      *
18      *  (new SomeTask($args))
19      *    ->setLogger($this->logger)
20      *    ->initializer()
21      *    ->...
22      *
23      * The reason `inflect` is better than the more explicit alternative is
24      * that subclasses of BaseTask that implement a new FooAwareInterface
25      * can override injectDependencies() as explained below, and add more
26      * dependencies that can be injected as needed.
27      *
28      * @param \Robo\Contract\InflectionInterface $parent
29      */
30     public function inflect(InflectionInterface $parent);
31
32     /**
33      * Take all dependencies availble to this task and inject any that are
34      * needed into the provided task.  The general pattern is that, for every
35      * FooAwareInterface that this class implements, it should test to see
36      * if the child also implements the same interface, and if so, should call
37      * $child->setFoo($this->foo).
38      *
39      * The benefits of this are pretty large. Any time an object that implements
40      * InflectionInterface is created, just call `$child->inflect($this)`, and
41      * any available optional dependencies will be hooked up via setter injection.
42      *
43      * The required dependencies of an object should be provided via constructor
44      * injection, not inflection.
45      *
46      * @param InflectionInterface $child An object created by this class that
47      *   should have its dependencies injected.
48      *
49      * @see https://mwop.net/blog/2016-04-26-on-locators.html
50      */
51     public function injectDependencies(InflectionInterface $child);
52 }