Skip to content

memoizeMethodCallResults: Why is the default false? #8964

Closed Answered by weirdan
jarstelfox asked this question in Q&A
Discussion options

You must be logged in to vote

There are no guarantees that a method will return the same value every time, yet memoizeMethodCallResults="true" implies just that, for all methods. Therefore this setting is risky at best, and should not be enabled by default. Perhaps we should deprecate it and remove it in the next major version.

In this case, the right thing to do is annotate the method as mutation-free: https://psalm.dev/r/189bf1c362. This way Psalm will actually validate that the method does not change any state.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@jarstelfox
Comment options

@jarstelfox
Comment options

Answer selected by jarstelfox

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants