<commit_before><?php

class FirePHP_Plugin_Engine {
    
    protected $traceOffset = 6;

    protected $errorConsole = null;
    protected $errorTypes = null;
    protected $assertionErrorConsole = null;
    protected $exceptionConsole = null;
    protected $inExceptionHandler = false;


    /**
     * Capture all errors and send to provided console
     * 
     * @return mixed Returns a string containing the previously defined error handler (if any)
     */
    public function onError($console, $types = E_ALL) {

        $this->errorConsole = $console;
        $this->errorTypes = $types;

        //NOTE: The following errors will not be caught by this error handler:
        //      E_ERROR, E_PARSE, E_CORE_ERROR,
        //      E_CORE_WARNING, E_COMPILE_ERROR,
        //      E_COMPILE_WARNING, E_STRICT
        return set_error_handler(array($this,'_errorHandler'));     
    }

    public function _errorHandler($errno, $errstr, $errfile, $errline, $errcontext) {
        if(!$this->errorConsole) {
            return;
        }
        // ignore assertion errors if being caught separately
        if(substr($errstr, 0, 8)=='assert()' && preg_match_all('/^assert\(\) \[<a href=\'function.assert\'>function.assert<\/a>\]: Assertion (.*) failed$/si', $errstr, $m)) {
            if($this->assertionErrorConsole) {
                return;
            }
        }
        // Only log errors we are asking for
        if ($this->errorTypes & $errno) {
            $this->errorConsole->setTemporaryTraceOffset($this->traceOffset);
            $this->errorConsole->meta(array(
                'encoder.depthExtend' => 5,
                'encoder.exception.traceOffset' => 1
            ))->error(new ErrorException($errstr, 0, $errno, $errfile, $errline));
        }
    }

    /**
     * Capture all assertion errors and send to provided console
     * 
     * @return mixed Returns the original setting or FALSE on error
     */<commit_msg>Bugfix: Suppress error logging for FirePHP engine plugin if @ used<commit_after><?php

class FirePHP_Plugin_Engine {
    
    protected $traceOffset = 6;

    protected $errorConsole = null;
    protected $errorTypes = null;
    protected $assertionErrorConsole = null;
    protected $exceptionConsole = null;
    protected $inExceptionHandler = false;


    /**
     * Capture all errors and send to provided console
     * 
     * @return mixed Returns a string containing the previously defined error handler (if any)
     */
    public function onError($console, $types = E_ALL) {

        $this->errorConsole = $console;
        $this->errorTypes = $types;

        //NOTE: The following errors will not be caught by this error handler:
        //      E_ERROR, E_PARSE, E_CORE_ERROR,
        //      E_CORE_WARNING, E_COMPILE_ERROR,
        //      E_COMPILE_WARNING, E_STRICT
        return set_error_handler(array($this,'_errorHandler'));     
    }

    public function _errorHandler($errno, $errstr, $errfile, $errline, $errcontext) {
        if(!$this->errorConsole) {
            return;
        }

        // if error has been suppressed with @
        if (error_reporting() == 0) {
            return;
        }

        // ignore assertion errors if being caught separately
        if(substr($errstr, 0, 8)=='assert()' && preg_match_all('/^assert\(\) \[<a href=\'function.assert\'>function.assert<\/a>\]: Assertion (.*) failed$/si', $errstr, $m)) {
            if($this->assertionErrorConsole) {
                return;
            }
        }
        // Only log errors we are asking for
        if ($this->errorTypes & $errno) {
            $this->errorConsole->setTemporaryTraceOffset($this->traceOffset);
            $this->errorConsole->meta(array(
                'encoder.depthExtend' => 5,
                'encoder.exception.traceOffset' => 1
            ))->error(new ErrorException($errstr, 0, $errno, $errfile, $errline));
        }
    }

    /**
     * Capture all assertion errors and send to provided console
     * 
     * @return mixed Returns the original setting or FALSE on error
     */
{'fraction_non_alphanumeric': 0.11831124202258222, 'fraction_numerical': 0.0031909671084928816, 'mean_word_length': 2.280998389694042, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 33, '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': '1553319', 'n_tokens_mistral': 1164, 'n_tokens_neox': 1117, 'n_words': 301}