Ocramius / PackageVersions

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

Uniform version style for root package #51

Closed Jean85 closed 6 years ago

Jean85 commented 6 years ago

In https://github.com/Jean85/pretty-package-versions/issues/3 I was made aware of the fact that the root package version is dumped in a different, normalized style; this is due to the fact that the root package version is not retrieved from the lock file like the other deps, and in the lock file the versions are not normalized.

This PR uses the PackageInterface::getPrettyVersion() from Composer to obtain the not-normalized version for the root package, obtaining a more uniform result.

This is needed since my wrapper is used as a way to output the current version in PHARs (i.e. PHPStan), where the subject is the root package by design.

Jean85 commented 6 years ago

I've forced push the fix to avoid garbage in the Git history of the project. Now it should be good to go.

PS: I was thinking about adding a self key to the versions array as an alias for the root package, what do you think? Obviously I would do it in a separate PR...

Ocramius commented 6 years ago

@Jean85 seems like you'll need a rebase before I can merge this.

Jean85 commented 6 years ago

Yep, the funny thing is that I de-synced it myself with #50 :smile:

Ocramius commented 6 years ago

@Jean85 I see you merged master into this branch: please do rebase instead.

Jean85 commented 6 years ago

@Ocramius sorry, I just used the web interface "Update branch" button, and I wasn't sure what it would do.

Rebased :+1:

Jean85 commented 6 years ago

Ok, I've fixed the mocks as per my comment and also pushed a small refactoring of the mock for the root package in the tests.