Skip to content

Skip "static::class" in "ForbiddenStaticClassConstFetchRule" #352

Closed

Description

@kevin-emo

ForbiddenStaticClassConstFetchRule is designed to :

Avoid static access of constants, as they can change value.

However, static::class is a special PHP construct that is determined by late static binding, and it does not behave like an overridable class constant.

Therefore, I think static::class should be excluded from this rule.

This is particularly useful in traits, where static::class can be used to obtain the current class name at runtime.

Activity

  1. TomasVotruba commented on Oct 12, 2026

    @TomasVotruba
    Member

    Please send failing test case with fixture 👍

  2. TomasVotruba commented on Oct 16, 2026

    @TomasVotruba
    Member

    Fixed in #376

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