Add an option to skip importing root namespace classes (like \DateTime)#2077
Conversation
|
Great pick! Definitely start with a test with optional parameter to be on |
|
Test added. But some help to get the condition And I'm not sure I'll manage to get the DocBlock right either, as the code is quite complex in there ( (and I don't mean that as a way of saying : "please do it all". I'd love to get to learn some of these internals, but some initial guidance might be welcome to find my way around) |
From top of my head, I'd detect $name = $this->getName($node);
if (Strings::startsWith($name, '\\')) {
if (substr_count($name, '\\') === 1) {
// skip
return null;
}
}As for docblock, I'm sure there will be another trick, let's deal with them later. |
|
Here's a working implementation. I've not handled DocBlock though, so the test is still failing. Shall you take over from here? :) (I've invited you as a collaborator on my fork, so you can work from there directly if you'd like) |
|
As for doblocks, this might be place to add very same check: The parameter should be passed via |
… bulletproof (one example of root namespace class, one example of non root namespace class).
|
I've finished the implementation. 👍 Would there be some documentation to write for this new option ? |
|
Feature looks ready, good job 👍
The documentation is generated from code samples, so adding one |
Feel free to send that in next PR. I'm merging this, since feature is complete |
|
Not sure how I can describe the new parameter within |
|
|
|
Sorry, I should have read more attentively! 🙄 |
|
No troubles 👍 |
|
Note : this option was changed into |
|
Could you add that to README as well? |
|
@TomasVotruba I documented it |
rectorphp/rector-src@8be11db [Naming] Skip used by trait on RenamePropertyToMatchTypeRector (#2077)
Trying to fix #1911 (comment)
I still need to prevent changing DocBlock annotations like
@var \DateTime... which seems way harder, looking at the code.