diff options
Diffstat (limited to 'inc/Debug/DebugHelper.php')
-rw-r--r-- | inc/Debug/DebugHelper.php | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/inc/Debug/DebugHelper.php b/inc/Debug/DebugHelper.php index 3d4b20d62..74dfa9420 100644 --- a/inc/Debug/DebugHelper.php +++ b/inc/Debug/DebugHelper.php @@ -84,6 +84,48 @@ class DebugHelper } /** + * Trigger a custom deprecation event + * + * Usually dbgDeprecatedFunction() or dbgDeprecatedProperty() should be used instead. + * This method is intended only for those situation where they are not applicable. + * + * @param string $alternative + * @param string $deprecatedThing + * @param string $caller + * @param string $file + * @param int $line + * @param int $callerOffset How many lines should be removed from the beginning of the backtrace + */ + public static function dbgCustomDeprecationEvent( + $alternative, + $deprecatedThing, + $caller, + $file, + $line, + $callerOffset = 1 + ) { + global $conf; + /** @var EventHandler $EVENT_HANDLER */ + global $EVENT_HANDLER; + if (!$conf['allowdebug'] && !$EVENT_HANDLER->hasHandlerForEvent(self::INFO_DEPRECATION_LOG_EVENT)) { + // avoid any work if no one cares + return; + } + + $backtrace = array_slice(debug_backtrace(), $callerOffset); + + self::triggerDeprecationEvent( + $backtrace, + $alternative, + $deprecatedThing, + $caller, + $file, + $line + ); + + } + + /** * @param array $backtrace * @param string $alternative * @param string $deprecatedThing |