Rector: [Bug] ImportFullyQualifiedNamesRector does not fix all FQCNs

Created on 13 May 2019  路  10Comments  路  Source: rectorphp/rector

Because ImportFullyQualifiedNamesRector rector only checks files that have namespaced defined it it does not fix FQCNs in a procedural code like this.

<?php

function foo() {
    $baz = \Foo\Bar::Baz;
}
-----
<?php

use Foo\Bar;

function foo() {
    $baz = Bar::BAZ;
}

bug

All 10 comments

Indeed. Care to send PR?

Not sure yet about the best solution for this problem, do you have an idea how this could be fixed?

Do 1 path for namespace and one without (this already exists).

Here is the exactly same issue just for different rule: https://github.com/rectorphp/rector/issues/1422

This will be more complicated, since it's not easy to add nodes without namespace above them.

I'll investigate

Yeah, I bumped into to this problem before this was the reason why I asked your opinion about this :)

Sure :)

It will require adding new layer in Rector, that will work even with arrays of stmts, not just Node of type. I postponed this for a long time, because it's really not easy to solve.

It was a "bit" complicated, but it's done :rocket:

image

I've merged it to master. Could you test it on your code base?

Awesome! 馃憤 This was a busy week, I'll try to check it in the weekend or early next week.

Well, took more time as I expected... but now I am here. Testing it now :)

Was this page helpful?
0 / 5 - 0 ratings