From a7affbe71636b5c7c54ca4049411eb9f51fae8c6 Mon Sep 17 00:00:00 2001 From: Niklas Keller Date: Sun, 22 Mar 2020 00:11:23 +0100 Subject: [PATCH] Add \Error stub (#3002) Otherwise, errors are generated if \Error is extended: https://psalm.dev/r/8169465beb --- .../Stubs/CoreImmutableClasses.phpstub | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/Psalm/Internal/Stubs/CoreImmutableClasses.phpstub b/src/Psalm/Internal/Stubs/CoreImmutableClasses.phpstub index d0b5324e6d2..6a43f952634 100644 --- a/src/Psalm/Internal/Stubs/CoreImmutableClasses.phpstub +++ b/src/Psalm/Internal/Stubs/CoreImmutableClasses.phpstub @@ -77,3 +77,57 @@ class Exception implements Throwable */ public final function getLine(){} } + +class Error implements Throwable +{ + /** + * @var string + */ + protected $message = ''; + + /** + * @var int + */ + protected $code = 0; + + /** + * @var string + */ + protected $file = ''; + + /** + * @var int + */ + protected $line = 0; + + /** + * @psalm-external-mutation-free + * @param string $message + * @param int $code + * @param Throwable $previous + */ + public function __construct($message = "", $code = 0, Throwable $previous = null) {} + + /** + * @psalm-mutation-free + */ + public final function getMessage() : string {} + + /** + * @psalm-mutation-free + * @return int|string + */ + public final function getCode(){} + + /** + * @psalm-mutation-free + * @return string + */ + public final function getFile(){} + + /** + * @psalm-mutation-free + * @return int + */ + public final function getLine(){} +}