Open TysonAndre opened 5 years ago
A separate tag would be useful for indicating that properties and methods are pure (results should be used and don't modify internal or external state)
- e.g. for
x-pure
, an analyzer would additionally warn about setting instance properties on objects of these classes.
cc @muglug - what do you think about @x-pure
on class docblock tags (Alternate name idea: @pure-class
)
psalm-immutable(already exists):
Used to annotate a class where every property is treated by consumers as
@psalm-readonly
and every instance method is treated as@psalm-mutation-free
.
psalm-pure/x-pure (suggestion for extending that to classes)
Used to annotate a class where every property is treated by consumers as
@psalm-readonly
and every instance method is treated as@psalm-pure
.
Related to #4
This is useful when there's an entire class where the methods should be treated as free of side effects (e.g. it'd be an error not to use the return values)
Benefits:
Open questions:
@x-must-use-methods
or@x-side-effect-free
would be my preference for a name- There's a lot of open questions and future standardization might use a slightly different meaning.A separate tag would be useful for indicating that properties and methods are pure (results should be used and don't modify internal or external state)
x-pure
, an analyzer would additionally warn about setting instance properties on objects of these classes.