thephpleague / factory-muffin

Enables the rapid creation of objects for testing
https://factory-muffin.thephpleague.com/
MIT License
532 stars 72 forks source link

Make setCallback() add to previous callbacks #473

Closed jesse-r-s-hines closed 3 years ago

jesse-r-s-hines commented 3 years ago

setCallback() replaces previous callbacks making you have to repeat any logic in the "base case' definition callback if you have a callback on one of the groups.

See issue #472

A better solution may be to add a addCallback method instead of modifying setCallback().

GrahamCampbell commented 3 years ago

Thanks for preparing this. This is certainly a breaking change, so can't be merged as is, and it is not obvious how we should implement addCallback along side setCallback in a way that makes sense.

jesse-r-s-hines commented 3 years ago

If we added an addCallback() function it would have to add a callback to the "chain", starting with any made with a prior setCallback() or prior addCallback()s. And calling setCallback() again would overwrite all the callbacks that have been accumulated. That would prevent it from being a breaking change.

jesse-r-s-hines commented 3 years ago

I'm going to close this and submit another pull request that implements addCallback() to maintain backwards compatibility.