Can a rule get current file name?

122 Views Asked by At

To debug / reporting purpose, before a refactor, we need to print the current file name in a rule refactor method.

Here we do a LOT of highly specific filtering, so I need to dump filenames where filter passes BEFORE doing any changes, so rector reporting will not output nothing.

Can a rector rule access current parsed file name?

1

There are 1 best solutions below

0
On BEST ANSWER

Found !

in the rule we can use

$this->file->getFilePath()

Also, in the refactor method we can also see line of current node

$node->getLine()