public function testIgnoreExecutionLoopFilename()
 {
     $e = new ErrorException('{{message}}', 0, 1, '/fake/path/to/Psy/ExecutionLoop/Loop.php');
     $this->assertEmpty($e->getFile());
     $e = new ErrorException('{{message}}', 0, 1, 'c:\\fake\\path\\to\\Psy\\ExecutionLoop\\Loop.php');
     $this->assertEmpty($e->getFile());
     $e = new ErrorException('{{message}}', 0, 1, '/fake/path/to/Psy/File.php');
     $this->assertNotEmpty($e->getFile());
 }
 /**
  * Helper for throwing an ErrorException.
  *
  * This allows us to:
  *
  *     set_error_handler(array($psysh, 'handleError'));
  *
  * Unlike ErrorException::throwException, this error handler respects the
  * current error_reporting level; i.e. it logs warnings and notices, but
  * doesn't throw an exception unless it's above the current error_reporting
  * threshold. This should probably only be used in the inner execution loop
  * of the shell, as most of the time a thrown exception is much more useful.
  *
  * @see \Psy\Exception\ErrorException::throwException
  * @see \Psy\Shell::writeException
  *
  * @param int    $errno   Error type
  * @param string $errstr  Message
  * @param string $errfile Filename
  * @param int    $errline Line number
  */
 public function handleError($errno, $errstr, $errfile, $errline)
 {
     if ($errno & error_reporting()) {
         ErrorException::throwException($errno, $errstr, $errfile, $errline);
     } else {
         // log it and continue...
         $this->writeException(new ErrorException($errstr, 0, $errno, $errfile, $errline));
     }
 }
Exemple #3
0
 /**
  * Create a fatal error.
  *
  * @param string     $message  (default: "")
  * @param int        $code     (default: 0)
  * @param int        $severity (default: 9000)
  * @param string     $filename (default: null)
  * @param int        $lineno   (default: null)
  * @param \Exception $previous (default: null)
  */
 public function __construct($message = "", $code = 0, $severity = 9000, $filename = null, $lineno = null, $previous = null)
 {
     $this->rawMessage = $message;
     $message = sprintf('PHP Fatal error:  %s in %s on line %d', $message, $filename ?: "eval()'d code", $lineno);
     parent::__construct($message, $code, $severity, $filename, $lineno, $previous);
 }