Ocramius / PackageVersions

:package: Composer addon to efficiently get installed packages' version numbers
MIT License
3.22k stars 67 forks source link

Fix incompatibility with --classmap-authoritative #27

Closed enumag closed 8 years ago

enumag commented 8 years ago

I tried to replace --optimize-autoloader with --classmap-authoritative for my CI and got this exception:

  Fatal error: Class 'PackageVersions\Versions' not found 

It seems that the Versions class was generated but is missing in the composer autoloading classmap because when I added the file manually in composer.json it works fine:

    "autoload": {
        //...
        "files": [
            "vendor/ocramius/package-versions/src/PackageVersions/Versions.php"
        ]
    },
Ocramius commented 8 years ago

Any test case/scenario that can be used to automate this failure and verify its correctness?

enumag commented 8 years ago

@Ocramius I tried to add --classmap-authoritative to .travis.install.sh (and removed the fix). It caused the build to fail with:

1) PackageVersionsTest\VersionsTest::testValidVersions
Error: Class 'PackageVersions\Versions' not found

Which is the error we wanted to test. So I'll just commit the fix along with the .travis.installer.sh change and that should be it.

Ocramius commented 8 years ago

The test should be an additional one, not a replacement for current installation...

enumag commented 8 years ago

I don't think it's necessary in this case (if something works with --classmap-authoritative I'm sure it will work without it as well). But alright, have it your way. It has to be a separate travis build though.

Ocramius commented 8 years ago

I don't think it's necessary

Well, people usually run it without --classmap-authoritative, so we have to test with a separate flag for this particular scenario :-)

Anyway, I will have to take a closer look at this patch, since I might be able to also fix #18 in a similar way.

Ocramius commented 8 years ago

Manually rebased and merged, thanks!

stof commented 8 years ago

btw, due to the change done in #33, it is useless, as the classmap generator will contain the class due to the fallback class

Ocramius commented 8 years ago

Yeah, can be reverted...

Ocramius commented 8 years ago

https://github.com/Ocramius/PackageVersions/commit/86f2636f7c5e7b56fa035fa3826d5fcf80b6dc72

stof commented 8 years ago

The proper way to ensure the class made it in the classmap (forgetting #33 which creates the file all the time) would have been to generate the file on the ScriptEvents::PRE_AUTOLOAD_DUMP instead

itscaro commented 5 years ago

Hello,

With 1.5.1 and --classmap-authoritative, I encounter this issue, is there any fix? Thank you

Ocramius commented 5 years ago

@itscaro please write a test case reproducing the failure first