tomzx / php-semver-checker

Compares two source sets and determines the appropriate semantic versioning to apply.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow using composer config to guess settings

nochso opened this issue · comments

I'd like to suggest a new option to parse a projects composer.json:

--composer [optional path to file]

  • All paths from the autoload section will be automatically included in a search.
  • autoload-dev could be used to exclude, as this usually points to tests and not a public API.
  • If the path is not specified, look for a composer.json in source-before/after folders.

This should help with #69 Adding/Removing a class supertype:
Instead of starting to scan all files, take the fully qualified name of the supertype and map it using the autoload mapping. I've already written such a mapper and I'd be happy to share it: given a composer.json and a FQN it will return the filepath (supports PSR-0 and PSR-4).
That way you can keep parsing only relevant files.

Also makes setup easier for a lot of users, as composer is everywhere :)

It is true that by assuming a PSR-0/4 compliant code it may be easier to determine the parent classes in a hierarchy.

I do agree that using composer.json to tell us about the known namespaces might allow us to "ease" the duplication of information that might be in php-semver-checker configuration file.

I'll give this a try next so we can begin solving #69.