/**
  * @test
  * @dataProvider invalidCallbackDataProvider
  **/
 public function shouldIgnoreNonFunctionsAndTriggerPhpNotice($var)
 {
     $errorCollector = new ErrorCollector();
     $errorCollector->register();
     $mock = $this->createCallableMock();
     $mock->expects($this->once())->method('__invoke')->with($this->identicalTo(1));
     $d = new Deferred();
     $d->then(null, $var)->then($this->expectCallableNever(), $mock);
     $d->reject(1);
     $errorCollector->assertCollectedError('Invalid $errorHandler argument passed to then(), must be null or callable.', E_USER_NOTICE);
     $errorCollector->unregister();
 }
 /**
  * Construct the error
  *
  * @param string $message
  * @param boolean $is_fatal
  * @return null
  */
 function __construct($message, $is_fatal = null)
 {
     $this->setMessage($message);
     if ($is_fatal === true || $is_fatal === false) {
         $this->is_fatal = $is_fatal;
     }
     // if
     if ($is_fatal) {
         ob_start();
         debug_print_backtrace();
         $this->setBacktrace(ob_get_clean());
     } else {
         $this->setBacktrace('Backtrace is available only for fatal errors');
     }
     // if
     // And log!
     $collector =& ErrorCollector::instance();
     $collector->collect($this);
 }
<?php

global $app_main_dir, $errorManager;
require_once $app_main_dir . '/include/lib/error/Error.class.php';
require_once $app_main_dir . '/include/lib/error/ErrorCollector.class.php';
$errorManager =& ErrorCollector::instance();
// ------------------------------------------------------------
//  Error related functions
// ------------------------------------------------------------
/*
 * create a new error
 */
function error($message, $additional_params = array(), $is_fatal = null)
{
    $error = new Error($message, $additional_params, $is_fatal);
    return $error;
}
/**
 * Check if specific variable is error object
 *
 * @param mixed $var Variable that need to be checked
 * @return boolean
 */
function is_error($var = null)
{
    global $errorManager;
    if (is_null($var)) {
        return $errorManager->hasErrors();
    }
    return instance_of($var, 'Error');
}