The fact that you can't do this has always bugged me.
$plugins->add_hook('some_hook', function() {
do_something();
});
In an age where pretty much every host has PHP 5.3, I don't see why not.
Whats wrong with this?
$plugins->add_hook('some_hook', 'some_function');
function some_function () {
do_something();
};
And how would you use $plugins->remove_hook('some_hook', 'some_function') with closures?
You wouldn't stefan. I'd like to see Closures supported too though if it's at all possible.
As long MyBB supports PHP 5.2 it is quite impossible...
(2013-04-17, 07:52 AM)StefanT Wrote: [ -> ]And how would you use $plugins->remove_hook('some_hook', 'some_function') with closures?
In no way trying to incite an argument, but I'd like to hear the answer to that question as well . . . from a purely academic aspect.
You could probably use create_function()
(2013-04-17, 07:52 AM)StefanT Wrote: [ -> ]And how would you use $plugins->remove_hook('some_hook', 'some_function') with closures?
I didn't know that existed, good point I guess. Maybe another parameter to use as a "key"?
(2013-04-17, 09:15 AM)StefanT Wrote: [ -> ]As long MyBB supports PHP 5.2 it is quite impossible...
Who still uses 5.2?
Cheap/free hosts - which unfortunately makes up a fairly large proportion of our user base I believe. I've asked in the past about upping the minimum requirements to 5.3+ and was told we'd need to check the installation stats.