foundry
foundry copied to clipboard
Throw when `createMany()` is called from an instance
This code should throw an exception:
SomeFactory::new()->createMany();
it was deprecated in Foundry 1.7, it is error prone (any state passed to new() will be ignored), and kinda hard to detect manually.
To detect if the call was made on an object, we can use debug_backtrace
After playing with this, it seems there is no easy way to do that 😞
when a static method is called in a non-static way, debug_backtrace says it has been called statically 🤷