Conditions | 1 |
Paths | 1 |
Total Lines | 97 |
Code Lines | 59 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
79 | public function addRecipes() { |
||
80 | |||
81 | // PSR-4 compatible class with aliases |
||
82 | $this->CoffeeShop->addRecipe( |
||
83 | new Recipe( |
||
84 | 'CommandHandlerManager', |
||
85 | 'EventEspresso\core\services\commands\CommandHandlerManager', |
||
86 | array( |
||
87 | 'CommandHandlerManagerInterface', |
||
88 | 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
||
89 | ), |
||
90 | array(), |
||
91 | CoffeeMaker::BREW_SHARED |
||
92 | ) |
||
93 | ); |
||
94 | // PSR-4 compatible class with aliases, which dependency on CommandHandlerManager |
||
95 | $this->CoffeeShop->addRecipe( |
||
96 | new Recipe( |
||
97 | 'CommandBus', |
||
98 | 'EventEspresso\core\services\commands\CommandBus', |
||
99 | array( |
||
100 | 'CommandBusInterface', |
||
101 | 'EventEspresso\core\services\commands\CommandBusInterface', |
||
102 | ), |
||
103 | array(), |
||
104 | CoffeeMaker::BREW_SHARED |
||
105 | ) |
||
106 | ); |
||
107 | // LEGACY classes that are NOT compatible with PSR-4 autoloading, and so must specify a filepath |
||
108 | // add a wildcard recipe for loading legacy core interfaces |
||
109 | $this->CoffeeShop->addRecipe( |
||
110 | new Recipe( |
||
111 | 'EEI_*', |
||
112 | '', |
||
113 | array(), |
||
114 | array(), |
||
115 | CoffeeMaker::BREW_LOAD_ONLY, |
||
116 | array( |
||
117 | EE_INTERFACES . '*.php', |
||
118 | EE_INTERFACES . '*.interfaces.php', |
||
119 | ) |
||
120 | ) |
||
121 | ); |
||
122 | // add a wildcard recipe for loading models |
||
123 | $this->CoffeeShop->addRecipe( |
||
124 | new Recipe( |
||
125 | 'EEM_*', |
||
126 | '', |
||
127 | array(), |
||
128 | array(), |
||
129 | CoffeeMaker::BREW_SHARED, |
||
130 | EE_MODELS . '*.model.php' |
||
|
|||
131 | ) |
||
132 | ); |
||
133 | // add a wildcard recipe for loading core classes |
||
134 | $this->CoffeeShop->addRecipe( |
||
135 | new Recipe( |
||
136 | 'EE_*', |
||
137 | '', |
||
138 | array(), |
||
139 | array(), |
||
140 | CoffeeMaker::BREW_SHARED, |
||
141 | array( |
||
142 | EE_CORE . '*.core.php', |
||
143 | EE_ADMIN . '*.core.php', |
||
144 | EE_CPTS . '*.core.php', |
||
145 | EE_CORE . 'data_migration_scripts' . DS . '*.core.php', |
||
146 | EE_CORE . 'request_stack' . DS . '*.core.php', |
||
147 | EE_CORE . 'middleware' . DS . '*.core.php', |
||
148 | ) |
||
149 | ) |
||
150 | ); |
||
151 | // load admin page parent class |
||
152 | $this->CoffeeShop->addRecipe( |
||
153 | new Recipe( |
||
154 | 'EE_Admin_Page*', |
||
155 | '', |
||
156 | array(), |
||
157 | array(), |
||
158 | CoffeeMaker::BREW_LOAD_ONLY, |
||
159 | array( EE_ADMIN . '*.core.php' ) |
||
160 | ) |
||
161 | ); |
||
162 | // add a wildcard recipe for loading core classes |
||
163 | // $this->CoffeeShop->addRecipe( |
||
164 | // new Recipe( |
||
165 | // '*_Admin_Page', |
||
166 | // '', |
||
167 | // array(), |
||
168 | // array(), |
||
169 | // CoffeeMaker::BREW_SHARED, |
||
170 | // array( |
||
171 | // EE_ADMIN_PAGES . 'transactions' . DS . '*.core.php', |
||
172 | // ) |
||
173 | // ) |
||
174 | // ); |
||
175 | } |
||
176 | |||
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: