Skip to content

Commit

Permalink
Mark toArray as pure and force psalm to accept it
Browse files Browse the repository at this point in the history
Lie to Psalm and tell it that toArray is immmutable. This seems tolerable (despite how bad a practice overriding the typechecker is) because the mutation is entirely memoization. If PHP were a lazy language, no caching would be necessary in the first place.
  • Loading branch information
jarstelfox committed Feb 11, 2020
1 parent f24ac13 commit caee04b
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/Enum.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public function getKey()

/**
* @psalm-pure
* @psalm-suppress InvalidCast
* @return string
*/
public function __toString()
Expand Down

0 comments on commit caee04b

Please sign in to comment.