Skip to content

Implement support for #[\NoDiscard] #13009

Closed

Description

@staabm

Feature request

since I have use-cases in my code-base for the PHP 8.5+ #[\NoDiscard] attribute, I want to suggest implementing support for it in PHPStan (even for PHP7/8), so we can use it already today, even before 8.5 is released

see https://wiki.php.net/rfc/marking_return_value_as_important

wdyt?

Did PHPStan help you today? Did it make you happy in any way?

No response

Activity

  1. changed the title [-]Implement support for PHP 8.4 `#[\NoDiscard]`[/-] [+]Implement support for `#[\NoDiscard]`[/+] on May 14, 2025
  2. ondrejmirtes commented on May 14, 2025

    @ondrejmirtes
    Member

    Please do not open issues for not-yet released and not-yet supported PHP versions.

    Usually after feature-freeze I go through the PHP UPGRADING document and dutifully create all the required todos for myself so the already-opened issues just complicate my workflow :)

  3. ondrejmirtes commented on May 14, 2025

    @ondrejmirtes
    Member

    I understand your motivation but the #[\NoDiscard] has meaning and exists only on PHP 8.5+ so PHPStan will not report any error before that.

    If you have a use for such attribute you can check out #[MustUseResult] in https://github.com/DaveLiddament/php-language-extensions.

  4. github-actions commented on Jun 15, 2025

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  5. locked as resolved and limited conversation to collaborators on Jun 15, 2025
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