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
Require files in right order #1051
Require files in right order #1051
Conversation
$this->fs->ensureDirectoryExists($this->vendorDir . '/b/b'); | ||
file_put_contents($this->vendorDir . '/a/a/test.php', '<?php function testFilesAutoloadGeneration1() {}'); | ||
file_put_contents($this->vendorDir . '/b/b/test2.php', '<?php function testFilesAutoloadGeneration2() {}'); | ||
file_put_contents($this->workingDir . '/root.php', '<?php function testFilesAutoloadGenerationRoot() {}'); |
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.
Please revert these formatting changes
I've fixed the formating. |
// sort packages by dependencies | ||
usort($packages, function (PackageInterface $a, PackageInterface $b) { | ||
foreach (array_merge($a->getRequires(), $a->getDevRequires()) as $link) { | ||
if ($link->getTarget() === $b->getName()) { |
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 should rather be in_array($link->getTarget(), $b->getNames())
otherwise you don't take into account provide/replace. Same below obviously.
I've fixed it @Seldaek. |
|
||
foreach ($packages as $package) { | ||
if ($package instanceof AliasPackage) { | ||
continue; | ||
} elseif ($package === $mainPackage) { |
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.
simply use if
instead of elseif
as the previous if
leaves the execution of this iteration of the loop
Please, merge it already. It causes a lot of trouble. |
Well I guess I'll merge because it looks alright, but I'm not sure this is the best way compared to just taking the installation order. I'm not quite sure why this is needed at all, but if it helps alright, I'll see later when I have more time. |
Thank you @Seldaek! |
@Seldaek this fix results in incorrect behaviour in how I've been using the autoload. Let me explain. I am using the autoload section to allow a dev copy of my "library" repository to be loaded before the copy in the vendor folder. This means that I can edit the library files locally and they will be loaded before the version installed in The composer.json section is like this: {
"autoload": {
"psr-0": {
"": "src/",
"Acme": "acme-library/src/"
},
}
} Prior to this fix, my generated autoload file would look like this: <?php
return array(
'Acme' => array($baseDir . '/acme-library/src/', $vendorDir . '/acme/library/src/'),
); Now, the values in that array are reversed which means that
|
@jonathaningram can you open a new issue for this (and reference this one)? I think we can restore the old behavior for PSR0, and I agree the root package should have priority in PSR0 stuff at least. Just don't have time to look into it now. |
@jonathaningram I think you're looking for this #1017 |
@Seldaek will do - sorry been busy today. |
…ight-order Require files in right order
Fixes #956. Please review.
Builded phar: https://dl.dropbox.com/u/32120652/composer.phar