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.privateMethodoccurrences in core. - Regenerate
core/.phpstan-baseline.php. - Verify PHPStan passes in GitLab CI.
User interface changes
None.
API changes
None.
Data model changes
None.
| Comment | File | Size | Author |
|---|
Issue fork drupal-3642127
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
Comment #3
mallezieComment #4
mstrelan commentedThis 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::sendNoJsPlaceholdersentirely so is not affected by this.Comment #5
mallezieComment #6
needs-review-queue-bot commentedThe 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.