Back to ExceptionHandler class

Method handleUserDeprecatedErrors

public static bool
handleUserDeprecatedErrors
(int $errorNumber, string $errorMessage, string $errorFile, int $errorLine)
Handles an error triggered with the E_USER_DEPRECATED level.
Parameters
  • int $errorNumber The level of the raised error, represented by the E_* constants.
  • string $errorMessage The error message.
  • string $errorFile The file the error was triggered from.
  • int $errorLine The line number the error was triggered from.
Returns
  • bool
Since
  • 4.0.0

Method handleUserDeprecatedErrors - Source code

/**
 * Handles an error triggered with the E_USER_DEPRECATED level.
 *
 * @param   integer  $errorNumber   The level of the raised error, represented by the E_* constants.
 * @param   string   $errorMessage  The error message.
 * @param   string   $errorFile     The file the error was triggered from.
 * @param   integer  $errorLine     The line number the error was triggered from.
 *
 * @return  boolean
 *
 * @since   4.0.0
 */
public static function handleUserDeprecatedErrors(int $errorNumber, string $errorMessage, string $errorFile, int $errorLine) : bool
{
    // We only want to handle user deprecation messages, these will be triggered in code
    if ($errorNumber === E_USER_DEPRECATED) {
        try {
            Log::add($errorMessage, Log::WARNING, 'deprecated');
        } catch (\Exception $e) {
            // Silence
        }
        // If debug mode is enabled, we want to let PHP continue to handle the error; otherwise, we can bail early
        if (\defined('JDEBUG') && JDEBUG) {
            return true;
        }
    }
    // Always return false, this will tell PHP to handle the error internally
    return false;
}