pestphp / pest

Pest is an elegant PHP testing Framework with a focus on simplicity, meticulously designed to bring back the joy of testing in PHP.
https://pestphp.com
MIT License
9.38k stars 334 forks source link

[Bug]: Could not bind closure #1202

Open idistack opened 1 month ago

idistack commented 1 month ago

What Happened

Accidently i received this error: image

How to Reproduce

i tried to access $this in beforeAll(), not object context, in Pest.php image

Sample Repository

No response

Pest Version

2.35.0

PHP Version

8.3.8

Operation System

Linux

Notes

No response

owenvoke commented 1 month ago

In Pest, beforeAll() is called before the test class is instantiated. Usage of $this can't be used there. This error may also happen if the test function is defined as static, which also isn't supported.