Hi, composer-dev list!
In order to move some existing PHP projects to Composer, I made a small script
that automatically parses PHP files of each project, collects and lists
their declared used imports. That greatly simplifies adding Composer requirement to these projects,
at least for my basic need. Could such a simple idea be useful for other users?
And in this case, could it be implemented as a new Composer subcommand,
e.g. ``composer list-imports``?
Here's the current script:https://gist.github.com/anonymous/624aeacd85e38254ee9307c5e71ec466
I'm sorry it's in Python 3 so far...
but I'm pretty sure it could easily be translated in PHP ;-)
Call to software is done through command-line:
$ python3 php_imports.py MODULE_PATH
where `MODULE_PATH` is a placeholder for either a PHP filepath,
or a PHP project directory.
The script prints to standard output the list of collected declared namespaces,
without checking if their are actually used or not
(for this case, PHP linters are better tools).
What do you think about that?
-- Vincent Férotin