<commit_before><?php

namespace webtoolsnz\scheduler;

/**
 * Class ErrorHandler
 * @package webtoolsnz\scheduler
 */
class ErrorHandler extends \yii\console\ErrorHandler
{
    /**
     * @var TaskRunner
     */
    public $taskRunner;

    /**
     *  We need to override the register method to inject our own shutdown handler before the internal yii handler
     *  is registered.
     */
    public function register()
    {
        register_shutdown_function([$this, 'schedulerShutdownHandler']);
        return parent::register();
    }

    public function schedulerShutdownHandler()
    {
        $error = error_get_last();
        if ($this->taskRunner && E_ERROR == $error['type']) {
            $this->taskRunner->handleError($error['type'], $error['message'], $error['file'], $error['line']);
        }
    }
}<commit_msg>Update fatal error handling to work with newer versions of yii<commit_after><?php

namespace webtoolsnz\scheduler;

/**
 * Class ErrorHandler
 * @package webtoolsnz\scheduler
 */
class ErrorHandler extends \yii\console\ErrorHandler
{
    /**
     * @var TaskRunner
     */
    public $taskRunner;

    /**
     *  We need to override the register method to register our own shutdown handler and prevent yii from
     *  intercepting our error handler.
     */
    public function register()
    {
        register_shutdown_function([$this, 'schedulerShutdownHandler']);
    }

    public function schedulerShutdownHandler()
    {
        $error = error_get_last();
        if ($this->taskRunner && E_ERROR == $error['type']) {
            $this->taskRunner->handleError($error['type'], $error['message'], $error['file'], $error['line']);
        }

        // Allow yiis error handler to take over and handle logging
        parent::handleFatalError();
    }
}
{'fraction_non_alphanumeric': 0.1260457334076966, 'fraction_numerical': 0.0, 'mean_word_length': 2.9084967320261437, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7619091', 'n_tokens_mistral': 501, 'n_tokens_neox': 489, 'n_words': 130}