From f573ef5163e31b4104df0850a6e762893bb6ab70 Mon Sep 17 00:00:00 2001 From: Greg Hargreaves Date: Fri, 14 Oct 2022 00:49:57 +0100 Subject: [PATCH 1/3] Correct return type of DateTimeImmutable sub method stub --- stubs/CoreImmutableClasses.phpstub | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/stubs/CoreImmutableClasses.phpstub b/stubs/CoreImmutableClasses.phpstub index 23eb77bdb77..820275da5bf 100644 --- a/stubs/CoreImmutableClasses.phpstub +++ b/stubs/CoreImmutableClasses.phpstub @@ -58,8 +58,7 @@ class DateTimeImmutable implements DateTimeInterface /** * @psalm-mutation-free - * @return static|false this method can fail in case an {@see DateInterval} with relative - * week days is passed in. + * @return static * * @see https://github.com/php/php-src/blob/534127d3b22b193ffb9511c4447584f0d2bd4e24/ext/date/php_date.c#L3157-L3160 */ From ef0d2256a6caf9b7464a69f8a750592910227b6d Mon Sep 17 00:00:00 2001 From: Greg Hargreaves Date: Fri, 14 Oct 2022 00:56:20 +0100 Subject: [PATCH 2/3] Remove link to php-src as was part of the documented reason for the return type false --- stubs/CoreImmutableClasses.phpstub | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/stubs/CoreImmutableClasses.phpstub b/stubs/CoreImmutableClasses.phpstub index 820275da5bf..91c0a41c69c 100644 --- a/stubs/CoreImmutableClasses.phpstub +++ b/stubs/CoreImmutableClasses.phpstub @@ -59,8 +59,7 @@ class DateTimeImmutable implements DateTimeInterface /** * @psalm-mutation-free * @return static - * - * @see https://github.com/php/php-src/blob/534127d3b22b193ffb9511c4447584f0d2bd4e24/ext/date/php_date.c#L3157-L3160 + */ public function sub(DateInterval $interval) {} From 8849e8ca3878cb35f3047cdedea36cac321058b3 Mon Sep 17 00:00:00 2001 From: Greg Hargreaves Date: Fri, 14 Oct 2022 00:59:54 +0100 Subject: [PATCH 3/3] Fix test for DateTimeImmutable sub method return type --- tests/MethodCallTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/MethodCallTest.php b/tests/MethodCallTest.php index cb3103fdeb8..377a3737805 100644 --- a/tests/MethodCallTest.php +++ b/tests/MethodCallTest.php @@ -271,7 +271,7 @@ final class MyDate extends DateTimeImmutable {} $b = (new DateTimeImmutable())->modify("+3 hours");', 'assertions' => [ - '$yesterday' => 'MyDate|false', + '$yesterday' => 'MyDate', '$b' => 'DateTimeImmutable', ], ],