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.
This patch is a complete rewrite, while retaining the same functionality for end users of the command (albeit with different invocation).
First, it extracts a class,
Composer
, for operations around reading and parsing thecomposer.json
file, adding and removing autoloading rules, writing changes to the file, and dumping autoload rules. The class uses several collaborators to do its work:FileReaderInterface
performs the operation of reading thecomposer.json
file.FileWriterInterface
performs the operation of writing changes bacck to thecomposer.json
file.AutoloadDumpInterface
performs the operation of callingcomposer dump-autoload
.Each has exactly one implementation:
FileReaderViaFileGetContents
FileWriterViaFilePutContents
AutoloadDumpViaSystemProcess
This approach makes testing the functionality far easier, as no actual filesystem operations need to be performed while testing.
The
Command\Enable
andCommand\Disable
classes were rewritten toCommand\EnableCommand
andCommand\DisableCommand
, respectively, and now inherit from a common symfony/consoleCommand
class extension,AbstractCommand
. TheAbstractCommand
includes setup of common input options, input validation, and the logic for autodiscovery of the autoloader type to use.The
EnableCommand
has an additional collaborator,MoveModuleClassFileInterface
, which has the responsibility of movingModule.php
files in the root of a module directory into its source subdirectory. This interface, like the others, has exactly one implementation,MoveModMoveModuleClassFileViaFileOperations
.A
ConfigProvider
andModule
class allow exposing the commands via laminas-cli to MVC and Mezzio applications.Fixes #4