Skip to content
Luca Ubiali Web Developer

How to Contribute to Open Source - 5/13 - Script Driven Development

August 14th, 2024
Continuous Learning

Episode - https://laracasts.com/series/how-to-contribute-to-open-source/episodes/5


Let’s not worry about code structure, just build a solution.

Instead of creating new files, Luke creates the methods needed directly in the playground script. He does something similar:

1function steps() {
2 return new class {
3 public function add(Closure $step, Closure|false $revert = null) {
4 ...
5 }
6 }
7}

(I never considered before having a function returning an anonymous class.)

By running the playground script we keep getting errors until all the necessary methods are created (even if empty). This definitely looks like TDD.

Once all methods are implemented, that’s the time to create a new StepBuilder class and dump in there the anonymous class.