1 | <?php |
||
18 | class OpenCoffeeShop { |
||
19 | |||
20 | /** |
||
21 | * @var CoffeeShop $CoffeeShop |
||
22 | */ |
||
23 | private $CoffeeShop; |
||
24 | |||
25 | /** |
||
26 | * @var DependencyInjector $DependencyInjector |
||
27 | */ |
||
28 | private $DependencyInjector; |
||
29 | |||
30 | |||
31 | |||
32 | /** |
||
33 | * OpenCoffeeShop constructor. |
||
34 | */ |
||
35 | public function __construct() |
||
36 | { |
||
37 | // instantiate the container |
||
38 | $this->CoffeeShop = new CoffeeShop(); |
||
39 | // create a dependency injector class for resolving class constructor arguments |
||
40 | $this->DependencyInjector = new DependencyInjector( |
||
41 | $this->CoffeeShop, |
||
42 | new \EEH_Array() |
||
43 | ); |
||
44 | // and some coffeemakers, one for creating new instances |
||
45 | $this->CoffeeShop->addCoffeeMaker( |
||
46 | new NewCoffeeMaker( $this->CoffeeShop, $this->DependencyInjector ), |
||
47 | CoffeeMaker::BREW_NEW |
||
48 | ); |
||
49 | // one for shared services |
||
50 | $this->CoffeeShop->addCoffeeMaker( |
||
51 | new SharedCoffeeMaker( $this->CoffeeShop, $this->DependencyInjector ), |
||
52 | CoffeeMaker::BREW_SHARED |
||
53 | ); |
||
54 | // and one for classes that only get loaded |
||
55 | $this->CoffeeShop->addCoffeeMaker( |
||
56 | new LoadOnlyCoffeeMaker( $this->CoffeeShop, $this->DependencyInjector ), |
||
57 | CoffeeMaker::BREW_LOAD_ONLY |
||
58 | ); |
||
59 | // add default recipe, which should handle loading for most PSR-4 compatible classes |
||
60 | // as long as they are not type hinting for interfaces |
||
61 | $this->CoffeeShop->addRecipe( |
||
62 | new Recipe( |
||
63 | Recipe::DEFAULT_ID |
||
64 | ) |
||
65 | ); |
||
66 | } |
||
67 | |||
68 | |||
69 | |||
70 | /** |
||
71 | * @return \EventEspresso\core\services\container\CoffeeShop |
||
72 | */ |
||
73 | public function CoffeeShop() { |
||
76 | |||
77 | |||
78 | |||
79 | public function addRecipes() { |
||
176 | |||
177 | |||
178 | |||
179 | |||
180 | } |
||
181 | // End of file OpenCoffeeShop.php |
||
183 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: