Composer: Newly added type option to RepositoryInterface::search() breaks BC

Created on 22 Jun 2016  ·  3Comments  ·  Source: composer/composer

Here is the breaking change: https://github.com/composer/composer/commit/6a557e45b8295007db61e786736f04018fe5fe90#commitcomment-17966162
and the issue caused by it: francoispluchino/composer-asset-plugin#230

the changes have been introduced by #5454 which also caused another break, which is reported in #5456.

Error message after updating composer:

Fatal error: Declaration of Fxp\Composer\AssetPlugin\Repository\AbstractAssetsRepository::search()
must be compatible with Composer\Repository\RepositoryInterface::search($query, $mode = 0, $type = NULL)
in /code/vendor/fxp/composer-asset-plugin/Repository/AbstractAssetsRepository.php on line 334

see francoispluchino/composer-asset-plugin#230 for more details.

Bug

Most helpful comment

IMO this isn't breaking per-se, it only breaks old plugins with the new version, but if the plugin adjusts to the new version, it should be compatible with old composer versions as per https://3v4l.org/7OfIR (adding params to an interface you implement is fine, but having less isn't).

We could just remove the param from the interface which should not break any functionality and lets the old plugins work fine though. It could then be added in 2.0. That would be a more strictly BC approach.

All 3 comments

The problem is not easily remedied though. These changes were applied on the master branch, where BC breaks are acceptable. However, since plugins cannot depend on a specific version, but rather are limited to running against whichever version you, the user, chooses to run, things can break unexpectedly if you decide to use the latest snapshot instead of a stable version.

I am totally aware that master can break, it's fine. I reported this so that it will not be shipped in a release without making neccessary changes.

IMO this isn't breaking per-se, it only breaks old plugins with the new version, but if the plugin adjusts to the new version, it should be compatible with old composer versions as per https://3v4l.org/7OfIR (adding params to an interface you implement is fine, but having less isn't).

We could just remove the param from the interface which should not break any functionality and lets the old plugins work fine though. It could then be added in 2.0. That would be a more strictly BC approach.

Was this page helpful?
0 / 5 - 0 ratings