Issue summary generated with the help of an LLM.

Problem/Motivation

PHPStan currently flags several staticClassAccess.privateMethod errors across Drupal core where a private method is called through static:: in a non-final class.

The static:: keyword resolves at runtime to the actual class, which may be a child class. Since private methods are not inherited by child classes, calling a private method through static:: can cause a fatal error if the method is invoked from a child class context.

Those are candidates for easy fixes, and also remove some related issues from the baseline automatically.

Proposed resolution

Use self:: instead of static:: for private method calls or make the class final, or make the method protected or public.
Marking classes final can be a BC break, so we should avoid that. Making the method protected or public can expand or BC surface, so is not the best option either.

Remaining tasks

  • Fix all staticClassAccess.privateMethod occurrences in core.
  • Regenerate core/.phpstan-baseline.php.
  • Verify PHPStan passes in GitLab CI.

User interface changes

None.

API changes

None.

Data model changes

None.

Issue fork drupal-3642127

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mallezie created an issue. See original summary.

mallezie’s picture

Status: Active » Needs review
mstrelan’s picture

Status: Needs review » Reviewed & tested by the community

This is straightforward and a nice cleanup. The explanation makes sense. I checked all of these methods in contrib with https://search.tresbien.tech/ and only found webprofiler subclassing any of these. It overrides BigPipe::sendNoJsPlaceholders entirely so is not affected by this.

mallezie’s picture

needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new98 bytes

The Needs Review Queue Bot tested this issue. The merge request has merge conflicts and cannot be merged. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.