Skip to content

Fix Throwable::getCode() method return type #767

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions resources/functionMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2623,7 +2623,7 @@
'Exception::__clone' => ['void'],
'Exception::__construct' => ['void', 'message='=>'string', 'code='=>'int', 'previous='=>'(?Throwable)|(?Exception)'],
'Exception::__toString' => ['string'],
'Exception::getCode' => ['mixed'],
'Exception::getCode' => ['int|string'],
'Exception::getFile' => ['string'],
'Exception::getLine' => ['int'],
'Exception::getMessage' => ['string'],
Expand Down Expand Up @@ -12239,7 +12239,7 @@
'Threaded::synchronized' => ['mixed', 'block'=>'Closure', '...args='=>'mixed'],
'Threaded::wait' => ['bool', 'timeout='=>'int'],
'Throwable::__toString' => ['string'],
'Throwable::getCode' => ['mixed'],
'Throwable::getCode' => ['int|string'],
'Throwable::getFile' => ['string'],
'Throwable::getLine' => ['int'],
'Throwable::getMessage' => ['string'],
Expand Down
6 changes: 3 additions & 3 deletions stubs/Exception.stub
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface Throwable
public function getMessage();

/**
* @return mixed
* @return int|string
* @throws void
*/
public function getCode();
Expand Down Expand Up @@ -60,7 +60,7 @@ class Exception implements Throwable
final public function getMessage(): string {}

/**
* @return mixed
* @return int|string
* @throws void
*/
final public function getCode() {}
Expand Down Expand Up @@ -107,7 +107,7 @@ class Error implements Throwable
final public function getMessage(): string {}

/**
* @return mixed
* @return int|string
* @throws void
*/
final public function getCode() {}
Expand Down
2 changes: 1 addition & 1 deletion tests/PHPStan/Analyser/data/generics.php
Original file line number Diff line number Diff line change
Expand Up @@ -1400,7 +1400,7 @@ public function process($class): void {
}

function (\Throwable $e): void {
assertType('mixed', $e->getCode());
assertType('int|string', $e->getCode());
};

function (): void {
Expand Down