Add PHPStan\Rules\Classes\AccessPrivateConstantThroughStaticRule to PHPStan rules

Created on 22 June 2025, 1 day ago

Problem/Motivation

We added PHPStan\Rules\Classes\AccessPrivateConstantThroughStaticRule to rules in 11.x - we could add this to 10.6.x too.

Proposed resolution

See https://git.drupalcode.org/project/drupal/-/commit/403d53b26d5fc13f43e0b...

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

πŸ“Œ Task
Status

Active

Version

10.6 ✨

Component

other

Created by

πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

Live updates comments and jobs are added and updated live.
  • Novice

    It would make a good project for someone who is new to the Drupal contribution process. It's preferred over Newbie.

Sign in to follow issues

Comments & Activities

  • Issue created by @alexpott
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    I think this would prevent hitting the linked issue, but I think this is addressing the symptom not the cause.

    I still think the root cause is using private in the first place.

  • πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

    @nicxvan I disagree. The root cause is using stattic:: to get a private const - which this detects. Private constants in an of themselves are not the root cause. We have the same issue with a private static method... that should never be called using static:: either - it would cause the same problems.

  • πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

    And for that matter any private static variable - they should be never be accessed with static:: unless the class is final...

Production build 0.71.5 2024