Aggiornato Composer
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2022 Justin Hileman
|
||||
* (c) 2012-2023 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -21,7 +21,7 @@ class BreakException extends \Exception implements Exception
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct($message = '', $code = 0, \Exception $previous = null)
|
||||
public function __construct($message = '', $code = 0, ?\Throwable $previous = null)
|
||||
{
|
||||
$this->rawMessage = $message;
|
||||
parent::__construct(\sprintf('Exit: %s', $message), $code, $previous);
|
||||
@@ -29,8 +29,6 @@ class BreakException extends \Exception implements Exception
|
||||
|
||||
/**
|
||||
* Return a raw (unformatted) version of the error message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRawMessage(): string
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2022 Justin Hileman
|
||||
* (c) 2012-2023 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2022 Justin Hileman
|
||||
* (c) 2012-2023 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -21,14 +21,14 @@ class ErrorException extends \ErrorException implements Exception
|
||||
/**
|
||||
* Construct a Psy ErrorException.
|
||||
*
|
||||
* @param string $message (default: "")
|
||||
* @param int $code (default: 0)
|
||||
* @param int $severity (default: 1)
|
||||
* @param string|null $filename (default: null)
|
||||
* @param int|null $lineno (default: null)
|
||||
* @param Exception|null $previous (default: null)
|
||||
* @param string $message (default: "")
|
||||
* @param int $code (default: 0)
|
||||
* @param int $severity (default: 1)
|
||||
* @param string|null $filename (default: null)
|
||||
* @param int|null $lineno (default: null)
|
||||
* @param \Throwable|null $previous (default: null)
|
||||
*/
|
||||
public function __construct($message = '', $code = 0, $severity = 1, $filename = null, $lineno = null, $previous = null)
|
||||
public function __construct($message = '', $code = 0, $severity = 1, $filename = null, $lineno = null, ?\Throwable $previous = null)
|
||||
{
|
||||
$this->rawMessage = $message;
|
||||
|
||||
@@ -73,8 +73,6 @@ class ErrorException extends \ErrorException implements Exception
|
||||
|
||||
/**
|
||||
* Get the raw (unformatted) message for this error.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRawMessage(): string
|
||||
{
|
||||
@@ -103,12 +101,12 @@ class ErrorException extends \ErrorException implements Exception
|
||||
/**
|
||||
* Create an ErrorException from an Error.
|
||||
*
|
||||
* @param \Error $e
|
||||
* @deprecated PsySH no longer wraps Errors
|
||||
*
|
||||
* @return self
|
||||
* @param \Error $e
|
||||
*/
|
||||
public static function fromError(\Error $e): self
|
||||
public static function fromError(\Error $e)
|
||||
{
|
||||
return new self($e->getMessage(), $e->getCode(), 1, $e->getFile(), $e->getLine(), $e);
|
||||
@\trigger_error('PsySH no longer wraps Errors', \E_USER_DEPRECATED);
|
||||
}
|
||||
}
|
||||
|
||||
2
vendor/psy/psysh/src/Exception/Exception.php
vendored
2
vendor/psy/psysh/src/Exception/Exception.php
vendored
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2022 Justin Hileman
|
||||
* (c) 2012-2023 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2022 Justin Hileman
|
||||
* (c) 2012-2023 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -26,9 +26,9 @@ class FatalErrorException extends \ErrorException implements Exception
|
||||
* @param int $severity (default: 1)
|
||||
* @param string|null $filename (default: null)
|
||||
* @param int|null $lineno (default: null)
|
||||
* @param \Exception|null $previous (default: null)
|
||||
* @param \Throwable|null $previous (default: null)
|
||||
*/
|
||||
public function __construct($message = '', $code = 0, $severity = 1, $filename = null, $lineno = null, $previous = null)
|
||||
public function __construct($message = '', $code = 0, $severity = 1, $filename = null, $lineno = null, ?\Throwable $previous = null)
|
||||
{
|
||||
// Since these are basically always PHP Parser Node line numbers, treat -1 as null.
|
||||
if ($lineno === -1) {
|
||||
@@ -42,8 +42,6 @@ class FatalErrorException extends \ErrorException implements Exception
|
||||
|
||||
/**
|
||||
* Return a raw (unformatted) version of the error message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRawMessage(): string
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2022 Justin Hileman
|
||||
* (c) 2012-2023 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -19,24 +19,28 @@ class ParseErrorException extends \PhpParser\Error implements Exception
|
||||
/**
|
||||
* Constructor!
|
||||
*
|
||||
* @param string $message (default: "")
|
||||
* @param int $line (default: -1)
|
||||
* @param string $message (default: '')
|
||||
* @param array|int $attributes Attributes of node/token where error occurred
|
||||
* (or start line of error -- deprecated)
|
||||
*/
|
||||
public function __construct(string $message = '', int $line = -1)
|
||||
public function __construct(string $message = '', $attributes = [])
|
||||
{
|
||||
$message = \sprintf('PHP Parse error: %s', $message);
|
||||
parent::__construct($message, $line);
|
||||
|
||||
if (!\is_array($attributes)) {
|
||||
$attributes = ['startLine' => $attributes];
|
||||
}
|
||||
|
||||
parent::__construct($message, $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a ParseErrorException from a PhpParser Error.
|
||||
*
|
||||
* @param \PhpParser\Error $e
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function fromParseError(\PhpParser\Error $e): self
|
||||
{
|
||||
return new self($e->getRawMessage(), $e->getStartLine());
|
||||
return new self($e->getRawMessage(), $e->getAttributes());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2022 Justin Hileman
|
||||
* (c) 2012-2023 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -23,9 +23,9 @@ class RuntimeException extends \RuntimeException implements Exception
|
||||
*
|
||||
* @param string $message (default: "")
|
||||
* @param int $code (default: 0)
|
||||
* @param \Exception|null $previous (default: null)
|
||||
* @param \Throwable|null $previous (default: null)
|
||||
*/
|
||||
public function __construct(string $message = '', int $code = 0, \Exception $previous = null)
|
||||
public function __construct(string $message = '', int $code = 0, ?\Throwable $previous = null)
|
||||
{
|
||||
$this->rawMessage = $message;
|
||||
parent::__construct($message, $code, $previous);
|
||||
@@ -33,8 +33,6 @@ class RuntimeException extends \RuntimeException implements Exception
|
||||
|
||||
/**
|
||||
* Return a raw (unformatted) version of the error message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRawMessage(): string
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2022 Justin Hileman
|
||||
* (c) 2012-2023 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -19,16 +19,14 @@ class ThrowUpException extends \Exception implements Exception
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(\Exception $exception)
|
||||
public function __construct(\Throwable $throwable)
|
||||
{
|
||||
$message = \sprintf("Throwing %s with message '%s'", \get_class($exception), $exception->getMessage());
|
||||
parent::__construct($message, $exception->getCode(), $exception);
|
||||
$message = \sprintf("Throwing %s with message '%s'", \get_class($throwable), $throwable->getMessage());
|
||||
parent::__construct($message, $throwable->getCode(), $throwable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a raw (unformatted) version of the error message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRawMessage(): string
|
||||
{
|
||||
@@ -38,20 +36,12 @@ class ThrowUpException extends \Exception implements Exception
|
||||
/**
|
||||
* Create a ThrowUpException from a Throwable.
|
||||
*
|
||||
* @param \Throwable $throwable
|
||||
* @deprecated PsySH no longer wraps Throwables
|
||||
*
|
||||
* @return self
|
||||
* @param \Throwable $throwable
|
||||
*/
|
||||
public static function fromThrowable($throwable): self
|
||||
public static function fromThrowable($throwable)
|
||||
{
|
||||
if ($throwable instanceof \Error) {
|
||||
$throwable = ErrorException::fromError($throwable);
|
||||
}
|
||||
|
||||
if (!$throwable instanceof \Exception) {
|
||||
throw new \InvalidArgumentException('throw-up can only throw Exceptions and Errors');
|
||||
}
|
||||
|
||||
return new self($throwable);
|
||||
@\trigger_error('PsySH no longer wraps Throwables', \E_USER_DEPRECATED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2022 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 "type error" Exception for Psy.
|
||||
*/
|
||||
class TypeErrorException extends \Exception implements Exception
|
||||
{
|
||||
private $rawMessage;
|
||||
|
||||
/**
|
||||
* Constructor!
|
||||
*
|
||||
* @param string $message (default: "")
|
||||
* @param int $code (default: 0)
|
||||
*/
|
||||
public function __construct(string $message = '', int $code = 0)
|
||||
{
|
||||
$this->rawMessage = $message;
|
||||
$message = \preg_replace('/, called in .*?: eval\\(\\)\'d code/', '', $message);
|
||||
parent::__construct(\sprintf('TypeError: %s', $message), $code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the raw (unformatted) message for this error.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRawMessage(): string
|
||||
{
|
||||
return $this->rawMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a TypeErrorException from a TypeError.
|
||||
*
|
||||
* @param \TypeError $e
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function fromTypeError(\TypeError $e): self
|
||||
{
|
||||
return new self($e->getMessage(), $e->getCode());
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2022 Justin Hileman
|
||||
* (c) 2012-2023 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -19,9 +19,9 @@ class UnexpectedTargetException extends RuntimeException
|
||||
* @param mixed $target
|
||||
* @param string $message (default: "")
|
||||
* @param int $code (default: 0)
|
||||
* @param \Exception|null $previous (default: null)
|
||||
* @param \Throwable|null $previous (default: null)
|
||||
*/
|
||||
public function __construct($target, string $message = '', int $code = 0, \Exception $previous = null)
|
||||
public function __construct($target, string $message = '', int $code = 0, ?\Throwable $previous = null)
|
||||
{
|
||||
$this->target = $target;
|
||||
parent::__construct($message, $code, $previous);
|
||||
|
||||
Reference in New Issue
Block a user