-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add PhpdocFullyQualifiedTypesFixer #3644
Conversation
3276 was about changing FQCN to short CN, why doing the reverse ? |
The topic reports the Expected VS Actual diff of the test, nothing to reverse here. |
@Slamdunk : that could indeed be a new feature. Currently I did not touch any docblocks. Personally, I am removing these kind of hard to maintain |
Heh, if only we could...
I pinged you because #3276 seems a complex work and maybe you faces some issue I need to know before building this new feature. |
Didn't face any issues regarding to the doblocks. You could add a The way I think it should work:
|
I treated your opening post as feature request definition, not as output of failing test :D little 👍 for the feature, but indeed, it's better to move it to prototype if possible, but that would be harder, so probably it's worth to do easier feature first. |
You are right, it was misleading. I do so for bug reports, but it is wrong for new feature .
I don't understand what you mean |
This should be different fixer, in Phpdoc namespace - to have better ability to deal with priority conflicts. FullyQualifiedStrictTypesFixer is wrong name for such a thing. |
👍 for this. I'm fine if the current fixer also deals with PHPDocs rather than creating a new fixer. |
For others looking for this, there is Symplify\CodingStandard\Fixer\Import\ImportNamespacedNameFixer, which does this and additionally imports the statement if it wasn't imported yet |
8f8055c
to
1553a3f
Compare
public function getPriority() | ||
{ | ||
/* | ||
* Should be run before all other docblock fixers apart from the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this a copy-paste-comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes , I've started from PhpdocScalarFixer
and it seemed to me a good idea to retain part of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, than we should back up this comments claim with priority test fixtures so we no longer need this comment 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I've added all the priority tests that I've could imaging, and then had to delete most of them except two cause of a test allowing only meaningful priority tests 😃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is my concern 😃 so a lot PHPDoc fixer claim that they must run before a whole bunch of other fixers, yet creating a priority test to prove it seems not possible.
return $type; | ||
} | ||
|
||
return (new TypeShortNameResolver())->resolve($tokens, $type); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there nice way to prevent creating a new instance of new TypeShortNameResolver()
for each candidate? (maybe private property of the fixer)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TypeShortNameResolver
is a stateless class, and I've read few times @julienfalque to prefer not saving anything privately due to performance reason.
Moreover, FullyQualifiedStrictTypesFixer
do the same:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is no longer true
d82119e
to
2f8ca5a
Compare
Could someone please fix the PR label to |
use Foo\Bar; | ||
|
||
/** | ||
* @return null|int|Bar |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add some more complex phpdoc types like nested type, generic, array shape, conditional type
} | ||
|
||
// Dummy start and end indexes, we only need isReservedType result | ||
if ((new TypeAnalysis(substr($type, 1), 1, 2))->isReservedType()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/pull/7188/files#diff-9eb8d1884736f293d0a3ea5127a6713fea7a744e293f41b48b263e910297a4bdR66 the 1, 2
dummy values are not needed
Reference: #3276
What about fixing PHPDoc too?
Ping @veewee