php-cs-fixer-config icon indicating copy to clipboard operation
php-cs-fixer-config copied to clipboard

Automatic version detection

Open uuf6429 opened this issue 1 year ago • 5 comments

This pull request adds a new ruleset, PhpAuto, that picks the right ruleset based on the minimum required PHP version defined in composer.json of the current working directory.

New dependencies added:

  1. ext-json (backword compatible, since it was already required by php-cs-fixer)
  2. composer/semver (supported since PHP 5.3, so it should also be fine)

Additional Changes:

  • project itself now uses the new ruleset (I figured it would be less maintenance + eating your own dog food)
  • updated the readme file with the same reasoning; most people would want to automate this

Design Notes:

  • at first I was going for a PHP version -> ruleset class (e.g. [53 => Php53::class]) map but then I thought it would be less work to just add an interface and build the class name dynamically

uuf6429 avatar Aug 24 '24 23:08 uuf6429