1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Prevent false-positive for Exception::__toString overriding

This commit is contained in:
Brown 2020-07-02 14:09:56 -04:00
parent 0c582e9993
commit cb94764d22
2 changed files with 25 additions and 3 deletions

View File

@ -60,9 +60,10 @@ interface Throwable
public function getTraceAsString() : string; public function getTraceAsString() : string;
/** /**
* @return string
* @psalm-taint-source input * @psalm-taint-source input
*/ */
public function __toString() : string; public function __toString();
} }
/** /**
@ -137,9 +138,10 @@ class Exception implements Throwable
public final function getTraceAsString() : string {} public final function getTraceAsString() : string {}
/** /**
* @return string
* @psalm-taint-source input * @psalm-taint-source input
*/ */
public function __toString() : string {} public function __toString() {}
} }
/** /**
@ -212,7 +214,8 @@ class Error implements Throwable
public final function getTraceAsString() : string {} public final function getTraceAsString() : string {}
/** /**
* @return string
* @psalm-taint-source input * @psalm-taint-source input
*/ */
public function __toString() : string {} public function __toString() {}
} }

View File

@ -791,6 +791,25 @@ class MethodSignatureTest extends TestCase
public function getPrevious(): ?\Throwable; public function getPrevious(): ?\Throwable;
public function getTraceAsString(): string; public function getTraceAsString(): string;
}' }'
],
'allowExecptionToStringWithNoType' => [
'<?php
class E extends Exception {
public function __toString() {
return "hello";
}
}'
],
'allowExecptionToStringIn71' => [
'<?php
class E extends Exception {
public function __toString() : string {
return "hello";
}
}',
[],
[],
'7.1'
] ]
]; ];
} }