From c5a384a18f9cb6aa6cee6c1dac71eeb52c343e60 Mon Sep 17 00:00:00 2001 From: Andreas Braun Date: Thu, 12 Sep 2024 09:46:05 +0200 Subject: [PATCH] Use conditional return type for getId method in CursorInterface classes (#1388) --- psalm-baseline.xml | 5 +---- src/ChangeStream.php | 5 ++++- src/Model/CodecCursor.php | 5 ++++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 8bd15f1cd..778bd91a1 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,5 @@ - + @@ -145,9 +145,6 @@ - - - diff --git a/src/ChangeStream.php b/src/ChangeStream.php index 9565adfb0..5a0a76924 100644 --- a/src/ChangeStream.php +++ b/src/ChangeStream.php @@ -110,7 +110,10 @@ public function current() return $this->codec->decode($value); } - /** @return CursorId|Int64 */ + /** + * @return CursorId|Int64 + * @psalm-return ($asInt64 is true ? Int64 : CursorId) + */ #[ReturnTypeWillChange] public function getCursorId(bool $asInt64 = false) { diff --git a/src/Model/CodecCursor.php b/src/Model/CodecCursor.php index 556f76c0f..c6f0cb099 100644 --- a/src/Model/CodecCursor.php +++ b/src/Model/CodecCursor.php @@ -76,7 +76,10 @@ public static function fromCursor(Cursor $cursor, DocumentCodec $codec): self return new self($cursor, $codec); } - /** @return CursorId|Int64 */ + /** + * @return CursorId|Int64 + * @psalm-return ($asInt64 is true ? Int64 : CursorId) + */ #[ReturnTypeWillChange] public function getId(bool $asInt64 = false) {