kvz / cakephp-rest-plugin

Discontinued: recent cakephp versions overlap functionality, there also is @ceeram's plugin. Painless REST server Plugin for CakePHP
http://kvz.io/blog/2010/01/13/cakephp-rest-plugin-presentation/
169 stars 37 forks source link

Strict Standards in PHP 5.4 #28

Closed tabaresjc closed 11 years ago

tabaresjc commented 11 years ago

Hi when I was trying your plugin in PHP 5.4

I keep getting these messages

Strict (2048): Declaration of RestComponent::initialize() should be compatible with Component::initialize(Controller $controller) [CORE\Cake\Core\App.php, line 547] Code Context $file = self::_mapped($className, $plugin); if ($file) { return include $file; $className = 'RestComponent' $parts = array( (int) 0 => 'Rest', (int) 1 => 'Controller/Component' ) $plugin = 'Rest' $package = 'Controller/Component' $file = 'C:\Websites\kanjime\app\Plugin\Rest\Controller\Component\RestComponent.php' App::load() - CORE\Cake\Core\App.php, line 547 App::load() - CORE\Cake\Core\App.php, line 547 spl_autoload_call - [internal], line ?? class_exists - [internal], line ?? ComponentCollection::load() - CORE\Cake\Controller\ComponentCollection.php, line 100 ComponentCollection::init() - CORE\Cake\Controller\ComponentCollection.php, line 53 Controller::constructClasses() - CORE\Cake\Controller\Controller.php, line 639 Dispatcher::_invoke() - CORE\Cake\Routing\Dispatcher.php, line 183 Dispatcher::dispatch() - CORE\Cake\Routing\Dispatcher.php, line 162 [main] - APP\webroot\index.php, line 116 Strict (2048): Declaration of RestComponent::startup() should be compatible with Component::startup(Controller $controller) [CORE\Cake\Core\App.php, line 547] Strict (2048): Declaration of RestComponent::beforeRender() should be compatible with Component::beforeRender(Controller $controller) [CORE\Cake\Core\App.php, line 547] Strict (2048): Declaration of RestComponent::shutdown() should be compatible with Component::shutdown(Controller $controller) [CORE\Cake\Core\App.php, line 547] Strict (2048): Declaration of RestComponent::beforeRedirect() should be compatible with Component::beforeRedirect(Controller $controller, $url, $status = NULL, $exit = true) [CORE\Cake\Core\App.php, line 547]

Apparently PHP5.4 is trying to enforce that the declaration of the method declared in the plugins should match the one expected in the core

I tried applying this error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT

to my PHP.ini file, but I keep getting the errors

Will you help me sort out this error please?

tabaresjc commented 11 years ago

Hello I think I solved this by changing in the file "\Component\RestComponent.php" the signature from public function initialize(&$Controller)

to this: public function initialize(Controller $Controller)

This should be changed in startup() beforeRender() shutdown() beforeRedirect()

Hope this helps for people who are facing the same problem