Skip to content

Commit

Permalink
Merge pull request #99 from greg0ire/conditional-types
Browse files Browse the repository at this point in the history
Leverage conditional types
  • Loading branch information
greg0ire authored Dec 12, 2022
2 parents 8275278 + 83417d6 commit 49e0c1c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
<file name="src/AbstractLexer.php" />
</errorLevel>
</MixedAssignment>
<MixedReturnStatement>
<errorLevel type="suppress">
<file name="src/Token.php" />
</errorLevel>
</MixedReturnStatement>
<RedundantConditionGivenDocblockType>
<errorLevel type="suppress">
<!-- that test checks non-obvious things guaranteed by static analysis, just in case -->
Expand Down
17 changes: 16 additions & 1 deletion src/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,24 @@ public function offsetExists($offset): bool
* @deprecated Use the value, type or position property instead
* {@inheritDoc}
*
* @param array-key $offset
* @param O $offset
*
* @return mixed
* @psalm-return (
* O is 'value'
* ? string|int
* : (
* O is 'type'
* ? T|null
* : (
* O is 'position'
* ? int
* : mixed
* )
* )
* )
*
* @template O of array-key
*/
#[ReturnTypeWillChange]
public function offsetGet($offset)
Expand Down

0 comments on commit 49e0c1c

Please sign in to comment.