1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Simplified DateTimeImmutable::format(): always returns a string

Also:

 * a non-empty format string will always lead to `non-empty-string`
 * it seems that you can throw **everything** at `DateTimeInterface#format()`, even null bytes,
   and it will always produce a `string`
This commit is contained in:
Marco Pivetta 2022-08-05 13:21:28 +02:00
parent a1ed84f1ed
commit 68ffae097e
2 changed files with 3 additions and 3 deletions

View File

@ -15,7 +15,7 @@ class DateTimeImmutable implements DateTimeInterface
*
* @param string $format
*
* @return (\PHP_MAJOR_VERSION is int<0, 7> ? string|false : string)
* @return ($format is non-empty-string ? non-empty-string : string)
*/
public function format($format) {}

View File

@ -271,8 +271,8 @@ class MethodCallTest extends TestCase
$b = (new DateTimeImmutable())->modify("+3 hours");',
'assertions' => [
'$yesterday' => 'MyDate',
'$b' => 'DateTimeImmutable',
'$yesterday' => 'MyDate|false',
'$b' => 'DateTimeImmutable|false',
],
],
'magicCall' => [