I have tried to insert PaginationRecallComponent (http://bakery.cakephp.org/articles/Zaphod/2012/03/27/paginationrecall_for_cakephp_2_x), in
App -> Controller -> Component -> PaginationRecallComponent.php
UserController: public $components = array('PaginationRecall');
Why I received the following error:
Strict (2048): Declaration of PaginationRecallComponent::initialize() should be compatible with Component::initialize(Controller $controller) [APP/Controller/Component/PaginationRecallComponent.php, line 46]
Code Context
App::load() - CORE/Cake/Core/App.php, line 567
App::load() - CORE/Cake/Core/App.php, line 567
spl_autoload_call - [internal], line ??
class_exists - [internal], line ??
ComponentCollection::load() - CORE/Cake/Controller/ComponentCollection.php, line 110
ComponentCollection::init() - CORE/Cake/Controller/ComponentCollection.php, line 53
Controller::constructClasses() - CORE/Cake/Controller/Controller.php, line 652
Dispatcher::_invoke() - CORE/Cake/Routing/Dispatcher.php, line 183
Dispatcher::dispatch() - CORE/Cake/Routing/Dispatcher.php, line 162
[main] - APP/webroot/index.php, line 97
CakePHP 2.4.2
You get this error because the signature of the initialize method in the PaginationRecallComponent class is different from the one in its parent class.
If you look at the code you will see that in Cake/Controller/Component.php the signature is:
public function initialize(Controller $controller)
whereas in the PaginationRecallComponent it is:
function initialize(&$controller)
In the first case the $controller parameter must be an instance of Controller, whereas in the second case there is no such constraint. To get rid of the error you simply have to add this constraint to the signature of the initialize method of the PaginationRecallComponent.
来源:https://stackoverflow.com/questions/20186038/cakephp-paginationrecallcomponent-strict-2048-declaration-of-paginationrecal