-
Notifications
You must be signed in to change notification settings - Fork 384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Composer plugin to correctly autoload PHP CSS Parser dependency #6464
Conversation
$package_locker = $event->getComposer()->getLocker(); | ||
$local_repository = $event->getComposer()->getRepositoryManager()->getLocalRepository(); | ||
|
||
self::patchComposerLockFile( $package_locker ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There may be an event earlier than this that we could hook into so that we only would have to update the package instance once and have Composer generate the correct composer.lock
but I didn't spend much time seeing if that was possible.
Plugin builds for 51b85ba are ready 🛎️!
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can the issue that this PR fixes be reproduced? I tried running composer update
on develop
and it seemed to work.
Codecov Report
@@ Coverage Diff @@
## develop #6464 +/- ##
=============================================
+ Coverage 75.12% 75.46% +0.33%
Complexity 5908 5908
=============================================
Files 188 237 +49
Lines 17769 17887 +118
=============================================
+ Hits 13349 13498 +149
+ Misses 4420 4389 -31
Flags with carried forward coverage won't be shown. Click here to find out more.
|
If you were to run diff --git a/composer.lock b/composer.lock
--- a/composer.lock (revision c6d7c8ab38f51066f7585b20567bc8c2537baa3c)
+++ b/composer.lock (date 1626819370118)
@@ -196,18 +196,22 @@
"reference": "bfdd976",
"shasum": ""
},
- "require": {
- "php": ">=5.3.2"
- },
+ "require": {
+ "ext-iconv": "*",
+ "php": ">=5.6.20"
+ },
"require-dev": {
"codacy/coverage": "^1.4",
- "phpunit/phpunit": "~4.8"
- },
+ "phpunit/phpunit": "^4.8.36"
+ },
+ "suggest": {
+ "ext-mbstring": "for parsing UTF-8 CSS"
+ },
"default-branch": true,
"type": "library",
"autoload": {
"psr-4": {
- "Sabberworm\\CSS\\": "lib/Sabberworm/CSS/"
+ "Sabberworm\\CSS\\": "src/"
}
}, Amongst the changes, the one that we're most concerned with is the update to the |
# Conflicts: # composer.lock
I tried switching to this branch and I get an error when I run
|
Hmm that's weird, I'm using composer v2.1.3 to test the plugin. I think b347c39 should solve the error you're getting. |
Co-authored-by: Weston Ruter <westonruter@google.com>
Yes, I don't get any error now. And |
I'm using Composer v2.1.3 also, by the way. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is way beyond my knowledge of Composer's inner-workings, but LGTM!
Summary
The PHP CSS Parser dependency currently will not autoload due to Composer using the
psr-4
namespace path specified in themaster
branch of that repository. Possible ways of resolving the issue include forking the repository to update thepsr-4
namespace, or waiting for the package maintainer to release an update with the updated namespace.This PR provides an alternative way to solve the issue, which I think would be easiest to use and maintain in the short term. By making use of a Composer plugin, we can programmatically update the
psr-4
namespace of the package in thecomposer.lock
file and the instance of the package Composer uses just before the autoload files are generated.Checklist