Example #1
0
 /**
  * Default error handler
  * 
  * @param int    $errno   Give the error number
  * @param string $errstr  Give the error description
  * @param string $errfile Give file from which came the error
  * @param int    $errline Give line from which came the error
  * 
  * @return void|boolean
  */
 public function error($errno, $errstr, $errfile, $errline)
 {
     $msg = '';
     switch ($errno) {
         case E_USER_ERROR:
             $msg = "Duality Fatal Error [{$errno}] {$errstr}" . " on line {$errline} in file {$errfile}\n";
             $msg .= "PHP " . PHP_VERSION . " (" . PHP_OS . ")\n";
             $msg .= "Cannot continue. Aborting...\n";
             // Set error on fatal
             $this->error = true;
             break;
         case E_USER_WARNING:
             $msg = "Duality Warning [{$errno}] {$errstr}" . " on line {$errline} in file {$errfile}\n";
             break;
         default:
             $msg = "Duality Notice [{$errno}] {$errstr}";
             $msg .= !empty($errline) ? " on line {$errline}" : '';
             $msg .= !empty($errfile) ? " in file {$errfile}" : '';
             $msg .= "\n";
             break;
     }
     // Add date to message
     $msg = date('Y-m-d H:i:s') . ": " . $msg;
     // write log to buffer
     $this->stream->write($msg);
     /* Don't execute PHP internal error handler */
     return true;
 }
Example #2
0
 /**
  * Test forbidden file
  * 
  * @expectedException \Duality\Core\DualityException
  */
 public function testForbiddenFile()
 {
     $file = new StreamFile(DATA_PATH . '/forbidden');
     $file->open('w');
 }