Problem/Motivation
As reported in #3116405: Warnings generated when using an optimized autoload file with Composer 1.10 / Composer 2
Coder needs to fix composer classmap somehow for newer versions of composer
Deprecation Notice: Class DrupalPractice\Sniffs\CodeAnalysis\VariableAnalysisSniff located in ./vendor/drupal/coder/coder_sniffer/DrupalPractice/Sniffs/CodeAnalysis/VariableAnalysisSniff.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///home/andypost/www/core8/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:185
Release notes said
https://github.com/composer/composer/releases/tag/1.10.0
https://github.com/composer/composer/releases/tag/1.10.0-RC
Deprecated: Added a warning when class names are being loaded by a PSR-4 or PSR-0 rule only due to classmap optimization, but would not otherwise be autoloadable. Composer 2.0 will stop autoloading these classes so make sure you fix your autoload configs.
Proposed resolution
To find out
Remaining tasks
tbd
User interface changes
no
API changes
no
Data model changes
no
Release notes snippet
tbd
Comments
Comment #2
andypostComment #3
Arkener CreditAttribution: Arkener at INDICIA commentedThis issue seems to have been fixed here on the development branch. Switching to psr-4 autoloading will result in 2 deprecation warnings:
These files are only used to test sniffs and don't have to be autoloaded.
Comment #4
andypostThe change is https://github.com/composer/composer/pull/8397
Comment #5
klausiA potential fix would be to move the test cases into a dedicated tests folder outside of coder_sniffer. PHPCS has moved their tests for example https://github.com/squizlabs/PHP_CodeSniffer/tree/master/tests
Comment #6
andyposthttps://github.com/composer/composer/releases/tag/1.10.0 is out
Comment #7
joelpittetI saw a wall of "Deprecation Notice" today in composer, a good chunk of it was this project but not the only one. date_recur and drush are also in the orange wall.
I'll be keen to see what the solution is here to see if I can help those other projects fix it as well.
Comment #8
andypostNew release https://github.com/composer/composer/releases/tag/1.10.1
Btw I also recall issue with theme info files from tests
Comment #9
fgmBeyond coder_sniffer, some core and contrib classes have the same issue:
Comment #10
Dane Powell CreditAttribution: Dane Powell at Acquia commentedNote that Composer 2 will be released in a few weeks, at which point these won't just be deprecation warnings any more, they will be full errors. I think that warrants a higher priority.
Comment #11
klausiStarted moving the tests outside the autoload directory at https://github.com/pfrenssen/coder/pull/107
Comment #12
klausiComment #13
Arkener CreditAttribution: Arkener as a volunteer commentedChecked and left a comment on https://github.com/pfrenssen/coder/pull/107, everything seems to be good to go!
Comment #15
klausiThanks a lot for reviewing Arkener, merged that!
Tested this on a Drupal 8 client project where I installed the most recent Coder dev branch commit and the 2 yellow Composer warnings for Coder are gone.
Downgrading this to normal since these are only Composer warning messages. It does not matter to us if Composer 2 will not autoload Coder test files that should never be autoloaded anyway.
I want to wait for a couple more weeks before I make the next Coder release. Let me know if there is any urgent reason to make a release earlier.