Pretty Package Versions 2.0

This is a republished tag announcement for jean85/pretty-package-versions. You can find the release here.

This new major release of this package was long awaited by me, since it’s a comeback of the 1.3 release, that was rolled back. Now, after more than 22 million downloads and the stable release of Composer 2, it’s time to use it!

The breaking changes are reduced to a minimum to allow a smoother upgrade path; if you use this package in a library, you’re encouraged to require it with a constraint of ^1.5 || ^2.0, to obtain all the functionalities without constraining your end users to upgrade immediately to Composer 2.

This release is aimed to become a bridge for native Composer 2 support. The BC breaks are minimal; if you’re using it in a library, you’re encouraged to require it with ^1.5 || ^2.0, so that your end users will not be constrained to use a specific Composer version.

Below the full changelog:

Added

  • Version methods added: getReference, getShortReference, getVersionWithShortReference (see table below)

Changed

  • Use Composer 2 API directly to retrieve versions
  • Version methods deprecated; this is a simple rename (commit to reference), to better reflect the meaning of Composer API data; the old methods are preserved but deprecated to reduce breaking changes:
New method Old, deprecated method
Version::getReference() Version::getCommitHash()
Version::getShortReference() Version::getShortCommitHash()
Version::getVersionWithShortReference() Version::getVersionWithShortCommit()

Removed

  • Drop PHP 7.0 support
  • Drop Composer 1 support
  • Drop dependencies
  • [BC BREAK] Constant PrettyVersions::SHORT_COMMIT_LENGTH removed
  • [BC BREAK] Constant Version::SHORT_COMMIT_LENGTH made private
  • [BC BREAK] Version constructor changed arguments: second argument string $version has been split into string $prettyVersion, string $reference