You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.
The InstallComposerDevDependencyTaskExecutor has a temporal coupling problem with the arePrerequisitesMet and execute methods. Namely, if you call execute without calling arePrerequisitesMet first, the tool will blow up because the class property composerProject is not set yet.
Although this is not a big problem because the class is only called in a fixed manner from outside, it would be nice to rid of this temporal coupling by somehow preventing execute from running if arePrerequisitesMet hasn't run yet, and maybe also when arePrerequisitesMet did run but the prerequisites were not met.
A relatively easy way to do this would be something like
private$arePrerequisitesMet = false;
publicfunctionarePrerequisitesMet(...)
{
// some checking here$this->arePrerequisitesMet = true;
}
publicfunctionexecute()
{
if (!$this->arePrerequisitesMet) {
thrownewRuntimeException(
sprintf(
'Either the prerequisites for "%s" have not been checked, or they have not been met.',
get_class($this)
)
);
}
// execute code
}
The text was updated successfully, but these errors were encountered:
I must note that it's currently by design; consumers of the Executor API must take this temporal coupling into account. This design was put in place to keep Executors simple and it wasn't a conscious decision to incur technical debt to further the project. Not sure I like putting the suggested checks in place in all Executors. I'm still open to being convinced otherwise or to other solutions, though 😉
Originally submitted by @rpkamp:
The
InstallComposerDevDependencyTaskExecutor
has a temporal coupling problem with thearePrerequisitesMet
andexecute
methods. Namely, if you callexecute
without callingarePrerequisitesMet
first, the tool will blow up because the class propertycomposerProject
is not set yet.Although this is not a big problem because the class is only called in a fixed manner from outside, it would be nice to rid of this temporal coupling by somehow preventing
execute
from running ifarePrerequisitesMet
hasn't run yet, and maybe also whenarePrerequisitesMet
did run but the prerequisites were not met.A relatively easy way to do this would be something like
The text was updated successfully, but these errors were encountered: