Skip to content

Commit

Permalink
Use conditional return type for getId method in CursorInterface class…
Browse files Browse the repository at this point in the history
…es (#1388)
  • Loading branch information
alcaeus committed Sep 12, 2024
1 parent aa2b904 commit c5a384a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
5 changes: 1 addition & 4 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.25.0@01a8eb06b9e9cc6cfb6a320bf9fb14331919d505">
<files psalm-version="5.26.1@d747f6500b38ac4f7dfc5edbcae6e4b637d7add0">
<file src="examples/atlas_search.php">
<MixedArgument>
<code><![CDATA[$document['name']]]></code>
Expand Down Expand Up @@ -145,9 +145,6 @@
</PossiblyNullArgument>
</file>
<file src="src/Model/CodecCursor.php">
<ImplementedReturnTypeMismatch>
<code><![CDATA[CursorId|Int64]]></code>
</ImplementedReturnTypeMismatch>
<TooManyArguments>
<code><![CDATA[getId]]></code>
</TooManyArguments>
Expand Down
5 changes: 4 additions & 1 deletion src/ChangeStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
5 changes: 4 additions & 1 deletion src/Model/CodecCursor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit c5a384a

Please sign in to comment.