Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With around 150k downloads per day (according to Packagist), Inflector 1.x is a very popular package, with some large Open-Source projects depending on it. While we are working on 2.0, releasing it into the wild can cause a load of problems for our users: as soon as one library updates to Inflector 2.0, users may end up in dependency hell because it forces other libraries to update as well.
To ease the transition to the new API of Inflector 2.0, this PR adds a backward compatibility layer to provide the 1.x API in 2.0. This allows for a staggered upgrade, where libraries first upgrade their composer dependency constraint to
"doctrine/inflector": "^1.3.0 || ^2.0"
while keeping the old API. Once enough of the large libraries have migrated (e.g.doctrine/common
,doctrine/orm
, laravel/framework, symfony/maker-bundle, they can start dropping support for 1.x and make use of the new API.This allows users the choice of using the 2.0 API in their projects without having to wait for other libraries to upgrade to Inflector 2.0.
The BC layer is excluded from PHPStan and phpcs analysis to allow for easier merging up of the 1.x branches. This helps to make sure that all bug fixes made in 1.3.x were also ported to 2.0.
The old API is marked as
@deprecated
via PHPDoc comments, with all methods triggeringE_USER_DEPRECATED
errors to allow tracing their origin with the Symfony PHPUnit Bridge.Note that support for custom rules is not part of the BC layer as it still needs to be implemented in 2.0 (see #100). The BC layer can be updated once custom rulesets are supported.