Skip to content

Scaffolding: integrate requiring Stateful interface into implementation capability

Daniel Kurowski requested to merge scaffolding-with-interface into master

In this code, implementedInterface(Stateful::class) is redundant as when stateful is implementated, interface should be in class' implements as well. Therefore, it should be incorporated into statefulImplementation():

->with(
  implementedInterface(Stateful::class),
  statefulImplementation(),
)
// 👇
->with(statefulImplementation())

This is good for most situations, however, there are cases when the Stateful interface is already extended in ancestor interface so you don't want to implement it again. For such cases, parameter is introduced with defaults to current behavior not to introduce BC:

// function statefulImplementation(bool $withInterface = false)
->with(statefulImplementation(withInterface: true)) // optionally enable implementing

But it makes more sense to make implementing the interface default behavior, so in future major release, the paramter should be changed to statefulImplementation(bool $noInterface = false).

Edited by Daniel Kurowski

Merge request reports

Loading