wyrihaximus/phpstan-react
PHPStan extension for ReactPHP projects that flags blocking PHP functions such as file_get_contents, fopen, and fclose, and points to async ReactPHP replacements from react/filesystem and react/socket. Install via Composer; rules auto-load with phpstan/extension-installer or include extension.neon.
Version 3.0 is a major step for this PHPStan extension: it goes well beyond flagging blocking calls and starts encoding how ReactPHP code is usually meant to be written.
The release adds a full set of event-loop rules that treat the loop as a global concern you reach through Loop::…, not something you inject, pass around, or keep on objects. PHPStan now nudges you toward static loop APIs, away from Loop::get() indirection and from calling methods on values typed as LoopInterface, and it catches promoted properties and traits that would hold a loop reference in your domain model. Together, those checks reflect the direction the ReactPHP ecosystem has been taking: fewer foot-guns around loop lifetime and clearer separation between application code and the runtime.
On the react/async side, 3.0 brings static analysis for fiber-style await usage. A parser visitor tracks which closures are wrapped in async, and a call-graph collector follows the stack when await might be reached indirectly. You get feedback when await appears outside an async closure, and when a plain closure can still reach await through callees—the cases that are easy to miss in review but painful at runtime.
Everything remains on by default, but you can tune the extension under parameters.wyrihaximus.reactphp.rules, so teams can adopt event-loop or async rules gradually or silence a category without dropping the whole package. Documentation and installation notes were refreshed (including the correct extension.neon include and guidance around PHPStan’s extension installer), and the project runs on current PHP and QA tooling so the new rules sit on a maintained foundation.
Loop to be proxy calls like Loop::futureTick() thanks to @WyriHaximusLoop:: calls are allowed thanks to @WyriHaximusInclude the rules file from the root of this package to have PHPStan check your code for blocking functions:
includes:
- vendor/wyrihaximus/phpstan-react/phpstan-reactphp-rules.neon
How can I help you explore Laravel packages today?