Improve the method signature of Option::fromValue to better understand nullable/optional value #78
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.
When using Option::fromValue($something), psalm decoded it was Option<string | null> because
$something
is of typestring | null.
This is the psalm error I got in my codebase:
![image](https://private-user-images.githubusercontent.com/4995501/383012661-fa3ec34a-94c9-4a98-a546-a872b375a6a4.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzNDYwNzMsIm5iZiI6MTczOTM0NTc3MywicGF0aCI6Ii80OTk1NTAxLzM4MzAxMjY2MS1mYTNlYzM0YS05NGM5LTRhOTgtYTU0Ni1hODcyYjM3NWE2YTQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTJUMDczNjEzWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YjgwNWQ1NDkzZmUzNWFiNWViZDBiYTM2MWZiMTE3YTJmY2M2NjI2NDdhN2Q4MWU0Y2Q4Y2JkMjgxMDI3OWI0ZiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.zhFNO8DGLBIVjfRhMyofCZniKX4M5PIWW6RCAPFe2W0)
However, I want to let psalm know that even if I pass something like null to
Option::fromValue
,the output is actually onlyOption<string>
instead ofOption<string | null>
.