safe icon indicating copy to clipboard operation
safe copied to clipboard

Mark pure function by Psalm

Open snapshotpl opened this issue 5 years ago • 6 comments

https://psalm.dev/articles/immutability-and-beyond#purity

snapshotpl avatar Sep 27 '19 22:09 snapshotpl

That would be a great idea. Of course, we don't want to do that manually. I guess Psalm has a list of pure PHP functions somewhere in the code. Would you happen to know where it is located?

moufmouf avatar Sep 30 '19 07:09 moufmouf

Just found in https://github.com/vimeo/psalm/tree/master/src/Psalm/Internal/Stubs

@muglug Am I right?

snapshotpl avatar Sep 30 '19 07:09 snapshotpl

Impure builtin functions are listed here: https://github.com/vimeo/psalm/blob/master/src/Psalm/Internal/Codebase/Functions.php#L280

All others are assumed pure

muglug avatar Sep 30 '19 16:09 muglug

Excellent! Thanks a lot!

moufmouf avatar Sep 30 '19 16:09 moufmouf

#172

Kharhamel avatar Dec 20 '19 09:12 Kharhamel

@muglug how do you test your function isCallMapFunctionPure() ? Do you use some selected example that you know are pure or impure, or do you have a more general approach?

Kharhamel avatar Jan 10 '20 13:01 Kharhamel