You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for spotting this, and you're right that the current annotation is too strict. As written though, @return R overshoots in the other direction: None::foldLeft() returns the initial value at runtime, so the true return type is S|R, and PHPStan flags None itself under this change. I've put up #82 which types the base methods as S|R with exact overrides on Some and None, so closing this in favour of that.
The current @return S on the folds is indeed too strict, but changing it to @return R isn't right either: Some returns the callback result, while None just hands back the initial value, so the honest return type is the union of the two. Annotating R alone would have PHPStan bless code that blows up on the None path, and it fails the library's own analysis run. I've fixed this in #82 by returning S|R on the base class with exact overrides on Some and None. Thanks for spotting the problem and the nudge in the right direction.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The following code is valid, but not allowed by template types currently. This PR fixes that.