rector php static reflection

Rector PHP have just fixed side effects of autoloading your code with composer with static reflections. It required 30 hours of huge refactoring to allow load your project without running it ! The issue is that Rector PHP now autoloads all the code that analyses. That means all your projects has to be loaded with composer, custom autoload or included. The only way to avoid this was to use static reflections

The code below will produce a fatal error in Rector as it will try to connect to mysql :

// in Rector
include __DIR__ . '/some_file.php';
// some_file.php
mysql_connect('...');
rector php static reflection

Static reflection in Rector PHP

So now your code is parsed, so Rector knows about mysql_connect function call, but it is not included and does not produce side effects. This work have been done by Tomas Votruba with the mentoring of Ondřej Mirtes author of PHPStan.

More about refactoring in Rector PHP could be found here https://github.com/rectorphp/rector/pull/5665

LEAVE A REPLY

Please enter your comment!
Please enter your name here