composer-stager
composer-stager copied to clipboard
Add incremental output getters to `API\Process\Service\OutputCallbackInterface`?
API\Process\Service\OutputCallbackInterface::getOutput()
and ::getErrorOutput()
are cumulative. In other words, if you pass a callback into one process run it and then pass it into another process and call that, the callback will contain the output from both processes. This can lead to unexpected results, including making functions that should be idempotent non-idempotent. That can be avoided by called ::clearOutput()
and ::clearErrorOutput()
between runs, but that may not be obvious and it's easy to forget anyway.
Maybe we should follow the example of Symfony Process, which also provides ::getIncrementalOutput()
and ::getIncrementalErrorOutput()
. In that case, it might be wise to rename ::getOutput()
(and ::getErrorOutput()
, accordingly) to ::getAllOutput()
or ::getCumulitiveOutput()
in order to force a user to make an explicit choice of behavior.