Skip to content

Choose a common tag to suggest that the result of a function/closure/method should be used #4

Description

@TysonAndre

Psalm has psalm-pure/psalm-external-mutation-free/psalm-internal-mutation-free. https://github.com/vimeo/psalm/blob/master/docs/annotating_code/supported_annotations.md#psalm-mutation-free

Phan has @phan-side-effect-free, which isn't as strict - it allows functions that aren't deterministic such as rand(), file_get_contents(), microtime(), etc.

It would be useful to have a common annotation for at least one of the following options:

  1. The return value of this function must be used (e.g. opening a resource)

    @must-use (haven't put much thought into the name)

  2. The return value of this function must be used, and this (should be treated as if) there are no side effects internally or externally (e.g. computing the Nth prime)

    Ideas: @[effectively-]side-effect-free, @x-pure, etc.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions