<commit_before><?php

namespace Nip\Debug;

use Symfony\Component\Debug\BufferingLogger;
use Symfony\Component\Debug\Debug as SymfonyDebug;

/**
 * Class Debug
 * @package Nip\Debug
 */
class Debug extends SymfonyDebug
{
    private static $enabled = false;

    /**
     * Enables the debug tools.
     *
     * This method registers an error handler and an exception handler.
     *
     * If the Symfony ClassLoader component is available, a special
     * class loader is also registered.
     *
     * @param int $errorReportingLevel The level of error reporting you want
     * @param bool $displayErrors Whether to display errors (for development) or just log them (for production)
     */
    public static function enable($errorReportingLevel = E_ALL, $displayErrors = true)
    {
        if (static::$enabled) {
            return;
        }

        static::$enabled = true;

        if (null !== $errorReportingLevel) {
            error_reporting($errorReportingLevel);
        } else {
            error_reporting(E_ALL);
        }

        if ('cli' !== PHP_SAPI) {
            ini_set('display_errors', 0);
            ExceptionHandler::register();
        } elseif ($displayErrors && (!ini_get('log_errors') || ini_get('error_log'))) {
            // CLI - display errors only if they're not already logged to STDERR
            ini_set('display_errors', 1);
        }

        if ($displayErrors) {
            $handler = ErrorHandler::register(new ErrorHandler(new BufferingLogger()));
        } else {
            $handler = ErrorHandler::register();
            $handler->throwAt(0, true);
        }

        app('container')->share(ErrorHandler::class, $handler);
//        DebugClassLoader::enable();<commit_msg>fix debug enable<commit_after><?php

namespace Nip\Debug;

use Symfony\Component\Debug\BufferingLogger;
use Symfony\Component\Debug\Debug as SymfonyDebug;

/**
 * Class Debug
 * @package Nip\Debug
 */
class Debug extends SymfonyDebug
{
    private static $enabled = false;

    /**
     * Enables the debug tools.
     *
     * This method registers an error handler and an exception handler.
     *
     * If the Symfony ClassLoader component is available, a special
     * class loader is also registered.
     *
     * @param int $errorReportingLevel The level of error reporting you want
     * @param bool $displayErrors Whether to display errors (for development) or just log them (for production)
     */
    public static function enable($errorReportingLevel = E_ALL, $displayErrors = true)
    {
        if (static::$enabled) {
            return;
        }

        static::$enabled = true;

        if (null !== $errorReportingLevel) {
            error_reporting($errorReportingLevel);
        } else {
            error_reporting(E_ALL);
        }

        if ('cli' !== PHP_SAPI) {
            ini_set('display_errors', 0);
            ExceptionHandler::register($displayErrors);
        } elseif ($displayErrors && (!ini_get('log_errors') || ini_get('error_log'))) {
            // CLI - display errors only if they're not already logged to STDERR
            ini_set('display_errors', 1);
        }

        if ($displayErrors) {
            $handler = ErrorHandler::register(new ErrorHandler(new BufferingLogger()));
        } else {
            $handler = ErrorHandler::register();
            $handler->throwAt(0, true);
        }

        app('container')->share(ErrorHandler::class, $handler);
//        DebugClassLoader::enable();
{'fraction_non_alphanumeric': 0.11155721250358475, 'fraction_numerical': 0.0017206767995411529, 'mean_word_length': 2.4568880079286424, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '1506000', 'n_tokens_mistral': 940, 'n_tokens_neox': 917, 'n_words': 259}