When writing a test which contains no $this keyword, it would be awesome if we could define them as static.
it('can contain work', static function () {
expect(Str::containsWord('test & word', 'test'))->toBeTrue();
});
What would be the benefit from it?
Micro-op? 馃 PhpStorm always is complaining to me about this.
Yeah so the reason is basically that static functions are faster, which means static analysis would always recommend you to write it as a static function when possible.
With the usage of expect and so on we are actually not depending on $this, so it can be static 馃憤
Realistically, how much faster are they (genuinely interested if there's a good blog)? 馃檪
@owenvoke Read about it awhile ago, so can't remember the blog I found about it 馃檪
However I don't think the performance difference is of any significance. This is mostly about satisfying static analysis, else all of the static analysis tools have to get a condition in for not checking for static functions in pest tests
Sounds good. 馃憤馃徎 Thanks for the info.
I've no plans on working on this. Feel free to submit a pull request.