Question
I have been playing with this nice library: good job by the way 👏
Trying to create my own custom rule that adds a namespace to a class if non is set.. But I couldn't figure it out sofar...
The file I have:
<?php
class MyClass extends SecureControllerAction {
...
}
The results I expect:
<?php
namespace App\Controller;
class MyClass extends SecureControllerAction {
...
}
My current rule
/**
* @return string[]
*/
public function getNodeTypes(): array
{
return [
Name::class,
Class_::class,
Namespace_::class,
];
}
/**
* @param Class_ $node
*/
public function refactor(Node $node): ?Node
{
// Here I'am stuck as the file itself doesn't have a namespace node!
}
Any help would be appreciated 🙏
Question
I have been playing with this nice library: good job by the way 👏
Trying to create my own custom rule that adds a
namespaceto a class if non is set.. But I couldn't figure it out sofar...The file I have:
The results I expect:
My current rule
Any help would be appreciated 🙏