Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
There is a proposal to relax the @file standard for autoloaded files ie classes, traits and interfaces. See #2304909: Relax requirement for @file when using OO Class or Interface per file
Proposed resolution
Change the FileCommentSniff to handle this.
Remaining tasks
Comment | File | Size | Author |
---|---|---|---|
#5 | 2665744.5.patch | 6.52 KB | alexpott |
#5 | 4-5-interdiff.txt | 3.88 KB | alexpott |
#4 | 2665744.4.patch | 2.63 KB | alexpott |
#4 | 2-4-interdiff.txt | 1.42 KB | alexpott |
#2 | 2665744.2.patch | 2.54 KB | alexpott |
Comments
Comment #2
alexpottComment #3
alexpottOne issue here is that apart from working out if the file is a class, interface or trait - how can we know if it is autoloadable? This sniff and fixer change will work great for Drupal 8 but previous versions of Drupal it won't work so good.
Comment #4
alexpottAh of course - we can check for a namespace. This means core/lib/Drupal.php won't be caught be this though... so maybe we can just add something explicit for this because it is the only non namespaced autoloadable file in D8.
Comment #5
alexpottHere's tests
Comment #6
klausiLooks good, but tests are failing. ClassDeclarationUnitTest is one of the weird edge cases where we should not delete any comments with the fixer. It mixes different namespaces, so an @file docblock is totally relevant in such a case and should not trigger an error.
Comment #8
klausiCommitted an updated version of the patch and fixed the test fails. This should be a good first step, please test the fixer with core. Let's open new issues for the problems that come up with it.
Comment #9
xjmI tested the new sniff and it seems to be working well. I posted one followup issue:
#2676540: Fixer should not delete elaborate @file doc comments
@klausi, can you clarify about the test failures? Is that resolved or?
Comment #10
klausiyes, as posted above I have fixed the phpunit test fails with the commit.
Thanks for the follow-up!
Comment #12
jhedstromWas the intention here to not require these, or to not allow them? The behavior seems to be the later, which is a heck of a thing to introduce in a point release. See https://travis-ci.org/jhedstrom/DrupalDriver/jobs/121744938#L360
Comment #13
jhedstromDisregard #12, I'm fully in agreement with the change, and it's a simple enough fix. I just freaked out when I saw the wall of failures :)