-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Autoloading hash files strategy #7942
Description
Original discussion in humbug/php-scoper#298.
The issue is occurring when you have two packages with the same name (but likely different versions) and both packages have a file included in the autoload section, e.g:
{
"autoload": {
"files": ["src/functions_include.php"]
}
}In this scenario, both files with end up with the same hash in the composer_real.php file:
array(1) {
["c964ee0ededf28c96ebd9db5099ef910"]=> string(99) "path/to/vendor/composer/../acme/foo/src/functions_include.php"
}
array(1) {
["c964ee0ededf28c96ebd9db5099ef910"]=> string(99) "path/to/vendor/composer/../acme/foo/src/functions_include.php"
}
Although the content might differ. As a result, only one of the file will be loaded, the other will appear as loaded although it has been not.
This peculiar edge case cannot occur with a traditional usage of Composer. It is however happening with PHP-Scoper since it's possible that a user is using a scoped package which might include for example (a scoped version of) guzzle and is using guzzle as well.
So I see two ways to fix it:
- (1): Change this Composer piece of code, for example by getting or appending a hash of the file content
- (2): Add a workaround in PHP-Scoper, e.g. changing the library names when scoping the project
(2) Could make more sense since it's an edge case created by PHP-Scoper. However since the solution looks really simple to deal with in Composer and fixing it there would avoid having to do more flimsy tweaking in PHP-Scoper, I would like to know if it's possible to do (1).