stable

Clone or download

Read-only

First step to allow PSR2 in plugins

Part of request #10396: Plugins hooks clean up The default callback for a hook is the hook name. This means that for the following code: $this->addHook('my_event'); I must declare the following method: public function my_event() {} Which is not PSR2 compatible because the name of the method is not in camel case. A workaround is to give the callback when we register the hook: $this->addHook('my_event', 'myEvent'); … public function myEvent() {} Which is not really nice for the developers. In order to fix that, this commit introduces the convention (over configuration) that the hook must be implemented by a callback with the same name, but in camel case. This means: $this->addHook('my_event'); … public function myEvent() {} Of course this change is backward compatible, we can still give the callback in arguments if needed and previous implementations of hooks don't need to change. However after this commit, there is no valid reasons that new code added in plugin are not compatible with PSR2. Change-Id: Ide2bf58345050cbd3f5ef3a6f33e0bd3038072bf

Modified Files

Name
M src/common/plugin/Plugin.class.php +36 −6 Go to diff View file
M tests/simpletest/common/plugin/PluginTest.php +110 −61 Go to diff View file