Skip to content

Instantly share code, notes, and snippets.

@4lun
Created October 16, 2015 10:45
Show Gist options
  • Save 4lun/b402a85ba2f84ce8c966 to your computer and use it in GitHub Desktop.
Save 4lun/b402a85ba2f84ce8c966 to your computer and use it in GitHub Desktop.
Laravel helper log_deprecated_method
<?php
/**
* Writes to the log that a deprecated method was called, and where it was called from.
*/
function log_deprecated_method()
{
list($x, $current, $caller) = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);
$currentMethod = (isset($current['class']) ? $current['class'].'::' : '').$current['function'].'()';
$callerMethod = (isset($caller['class']) ? $caller['class'].'::' : '').$caller['function'].'()';
\Log::notice('Use of deprecated method: '.$currentMethod.', called via: '.$callerMethod);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment