Update v1.0.6
This commit is contained in:
@@ -1,39 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Psy Shell
|
||||
*
|
||||
* (c) 2012-2014 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Psy\Exception;
|
||||
|
||||
/**
|
||||
* A break exception, used for halting the Psy Shell.
|
||||
*/
|
||||
class BreakException extends \Exception implements Exception
|
||||
{
|
||||
private $rawMessage;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct($message = "", $code = 0, \Exception $previous = null)
|
||||
{
|
||||
$this->rawMessage = $message;
|
||||
parent::__construct(sprintf('Exit: %s', $message), $code, $previous);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a raw (unformatted) version of the error message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRawMessage()
|
||||
{
|
||||
return $this->rawMessage;
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Psy Shell
|
||||
*
|
||||
* (c) 2012-2014 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Psy\Exception;
|
||||
|
||||
/**
|
||||
* A custom error Exception for Psy with a formatted $message.
|
||||
*/
|
||||
class ErrorException extends \ErrorException implements Exception
|
||||
{
|
||||
private $rawMessage;
|
||||
|
||||
/**
|
||||
* Construct a Psy ErrorException.
|
||||
*
|
||||
* @param string $message (default: "")
|
||||
* @param int $code (default: 0)
|
||||
* @param int $severity (default: 1)
|
||||
* @param string $filename (default: null)
|
||||
* @param int $lineno (default: null)
|
||||
* @param Exception $previous (default: null)
|
||||
*/
|
||||
public function __construct($message = "", $code = 0, $severity = 1, $filename = null, $lineno = null, $previous = null)
|
||||
{
|
||||
$this->rawMessage = $message;
|
||||
|
||||
if (!empty($filename) && preg_match('{Psy[/\\\\]ExecutionLoop}', $filename)) {
|
||||
$filename = null;
|
||||
}
|
||||
|
||||
switch ($severity) {
|
||||
case E_WARNING:
|
||||
case E_CORE_WARNING:
|
||||
case E_COMPILE_WARNING:
|
||||
case E_USER_WARNING:
|
||||
$type = 'warning';
|
||||
break;
|
||||
|
||||
case E_STRICT:
|
||||
$type = 'Strict error';
|
||||
break;
|
||||
|
||||
default:
|
||||
$type = 'error';
|
||||
break;
|
||||
}
|
||||
|
||||
$message = sprintf('PHP %s: %s%s on line %d', $type, $message, $filename ? ' in ' . $filename : '', $lineno);
|
||||
parent::__construct($message, $code, $severity, $filename, $lineno, $previous);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the raw (unformatted) message for this error.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRawMessage()
|
||||
{
|
||||
return $this->rawMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper for throwing an ErrorException.
|
||||
*
|
||||
* This allows us to:
|
||||
*
|
||||
* set_error_handler(array('Psy\Exception\ErrorException', 'throwException'));
|
||||
*
|
||||
* @throws ErrorException
|
||||
*
|
||||
* @param int $errno Error type
|
||||
* @param string $errstr Message
|
||||
* @param string $errfile Filename
|
||||
* @param int $errline Line number
|
||||
*/
|
||||
public static function throwException($errno, $errstr, $errfile, $errline)
|
||||
{
|
||||
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
|
||||
}
|
||||
}
|
||||
27
vendor/psy/psysh/src/Psy/Exception/Exception.php
vendored
27
vendor/psy/psysh/src/Psy/Exception/Exception.php
vendored
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Psy Shell
|
||||
*
|
||||
* (c) 2012-2014 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Psy\Exception;
|
||||
|
||||
/**
|
||||
* An interface for Psy Exceptions.
|
||||
*/
|
||||
interface Exception
|
||||
{
|
||||
/**
|
||||
* This is the only thing, really...
|
||||
*
|
||||
* Return a raw (unformatted) version of the message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRawMessage();
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Psy Shell
|
||||
*
|
||||
* (c) 2012-2014 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Psy\Exception;
|
||||
|
||||
/**
|
||||
* A "fatal error" Exception for Psy.
|
||||
*/
|
||||
class FatalErrorException extends \ErrorException implements Exception
|
||||
{
|
||||
private $rawMessage;
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a raw (unformatted) version of the error message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRawMessage()
|
||||
{
|
||||
return $this->rawMessage;
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Psy Shell
|
||||
*
|
||||
* (c) 2012-2014 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Psy\Exception;
|
||||
|
||||
/**
|
||||
* A "parse error" Exception for Psy.
|
||||
*/
|
||||
class ParseErrorException extends \PhpParser\Error implements Exception
|
||||
{
|
||||
/**
|
||||
* Constructor!
|
||||
*
|
||||
* @param string $message (default: "")
|
||||
* @param int $line (default: -1)
|
||||
*/
|
||||
public function __construct($message = "", $line = -1)
|
||||
{
|
||||
$message = sprintf('PHP Parse error: %s', $message);
|
||||
parent::__construct($message, $line);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a ParseErrorException from a PhpParser Error.
|
||||
*
|
||||
* @param \PhpParser\Error $e
|
||||
*
|
||||
* @return ParseErrorException
|
||||
*/
|
||||
public static function fromParseError(\PhpParser\Error $e)
|
||||
{
|
||||
return new self($e->getRawMessage(), $e->getRawLine());
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Psy Shell
|
||||
*
|
||||
* (c) 2012-2014 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Psy\Exception;
|
||||
|
||||
/**
|
||||
* A RuntimeException for Psy.
|
||||
*/
|
||||
class RuntimeException extends \RuntimeException implements Exception
|
||||
{
|
||||
private $rawMessage;
|
||||
|
||||
/**
|
||||
* Make this bad boy.
|
||||
*
|
||||
* @param string $message (default: "")
|
||||
* @param int $code (default: 0)
|
||||
* @param \Exception $previous (default: null)
|
||||
*/
|
||||
public function __construct($message = "", $code = 0, \Exception $previous = null)
|
||||
{
|
||||
$this->rawMessage = $message;
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a raw (unformatted) version of the error message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRawMessage()
|
||||
{
|
||||
return $this->rawMessage;
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Psy Shell
|
||||
*
|
||||
* (c) 2012-2014 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Psy\Exception;
|
||||
|
||||
/**
|
||||
* A throw-up exception, used for throwing an exception out of the Psy Shell.
|
||||
*/
|
||||
class ThrowUpException extends \Exception implements Exception
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(\Exception $exception)
|
||||
{
|
||||
$message = sprintf("Throwing %s with message '%s'", get_class($exception), $exception->getMessage());
|
||||
parent::__construct($message, $exception->getCode(), $exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a raw (unformatted) version of the error message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRawMessage()
|
||||
{
|
||||
return $this->getPrevious()->getMessage();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user