SimpleMachines/SMF2.1 — pull request #1123 by MissAllSunday (2013-12-28 23:26:57+00:00)
Title: Create object

SMF now support calls to static methods (class::method) which is great but having a bunch of static methods is pretty much the same as procedural and global vars so I made a few changes to how methods are handle:

- I added a new param to both add_integration_function() and remove_integration_function to let mod authors to specify if they want to create a new instance of their class when their method is called:

```php
function add_integration_function($hook, $function, $file = '', $object = false, $permanent = true);
function remove_integration_function($hook, $function, $file = '', $object = false);
```
A boolean that defaults to false, if true, a new wildcard will be added (#) which will indicate if the method has to be instantiated. For this to happen, the function must be a call to a method, (class::method) it will not work with calls to pure functions.

- Created a semi-singleton pattern to avoid multiple instances of the same class, if a mod adds several hooks only 1 instance will be created per duration of the request, all created objects during request will reside in $context['instances']. Mod authors could be advised to check this array first before creating new instances.

- In 2.0 if a hooks fails there is no indication that it failed, I added a couple of log_error calls to indicate when a file couldn't been loaded and if a call to a func/method couldn't been performed, this will make it easier to identify why a hook isn't working.

- Added a new field in $context['debug'] for instances and how many of them are active.

- Fixed a couple of errors in ManageMaintenance::get_integration_hooks_data() with handling methods, the code assumed methods had just the name of the function.

- Added some more info n the DocBlock for Subs::add_integration_function() to reflect the new params and how to use them properly.