Skip to content
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

Merged

Conversation

fprochazka
Copy link
Contributor

Fixes #956. Please review.

Builded phar: https://dl.dropbox.com/u/32120652/composer.phar

@travisbot
Copy link

This pull request passes (merged 71e2edd1 into a04591b).

@travisbot
Copy link

This pull request passes (merged 195e0501 into a04591b).

@Vrtak-CZ
Copy link

Vrtak-CZ commented Sep 1, 2012

This pull fix my issue #956 thx @hosiplan

$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() {}');
Copy link
Contributor

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

@travisbot
Copy link

This pull request passes (merged 39bfc28a into a04591b).

@fprochazka
Copy link
Contributor Author

I've fixed the formating.

@travisbot
Copy link

This pull request passes (merged 5972631d into a04591b).

@travisbot
Copy link

This pull request passes (merged 186e0e1b into a04591b).

// 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()) {
Copy link
Member

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.

@fprochazka
Copy link
Contributor Author

I've fixed it @Seldaek.


foreach ($packages as $package) {
if ($package instanceof AliasPackage) {
continue;
} elseif ($package === $mainPackage) {
Copy link
Contributor

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

@fprochazka
Copy link
Contributor Author

Please, merge it already. It causes a lot of trouble.

@Seldaek
Copy link
Member

Seldaek commented Sep 7, 2012

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.

Seldaek added a commit that referenced this pull request Sep 7, 2012
@Seldaek Seldaek merged commit 2034752 into composer:master Sep 7, 2012
@fprochazka
Copy link
Contributor Author

Thank you @Seldaek!

@jonathaningram
Copy link
Contributor

@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 vendor.

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 $vendorDir . '/acme/library/src/' is loaded first and thus my locally changed library files do not get included.

  1. I am guessing I was using this in an "undocumented" way, so if this PR fixed a bug, then I guess it takes priority over my case?
  2. Is there any way around it to make my use case work?

@Seldaek
Copy link
Member

Seldaek commented Sep 11, 2012

@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.

@fprochazka
Copy link
Contributor Author

@jonathaningram I think you're looking for this #1017

@jonathaningram
Copy link
Contributor

@Seldaek will do - sorry been busy today.

digitalkaoz pushed a commit to digitalkaoz/composer that referenced this pull request Nov 22, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Autoload files - load vendors first
6 participants