Skip to content
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 PhpdocVarAnnotationCorrectOrderFixer #3881

Merged
merged 1 commit into from Jan 1, 2019
Merged

Add PhpdocVarAnnotationCorrectOrderFixer #3881

merged 1 commit into from Jan 1, 2019

Conversation

kubawerlos
Copy link
Contributor

@kubawerlos kubawerlos commented Jul 5, 2018

Closes #2159

Copy link
Contributor

@dmvdbrugge dmvdbrugge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 things:

  1. This needs to ensure priority before PhpdocVarWithoutNameFixer.
  2. This should also fix @type

@dmvdbrugge
Copy link
Contributor

What is the reasoning behind not fixing @param?

@kubawerlos
Copy link
Contributor Author

@dmvdbrugge the alternative for 2 is not a acceptable as we cannot assume some will use PhpdocNoAliasTagFixer.

@param is not fixed as the idea is to fix @var cases - I've never seen @param with variable name before type and @param more often has description than @var.

I'm not sure now, maybe we can aim to have PhpdocCorrectOrderOfTypeAndNameFixer to handle all Phpdoc types that have type and name the same, yet I prefer to add mixed when type is missing instead of getting first word of string behind the name as it can do more harm like:

 /**
- * @param $foo This is foo
+ * @param This $foo us foo
  */

@dmvdbrugge
Copy link
Contributor

the alternative for 2 is not a acceptable as we cannot assume some will use PhpdocNoAliasTagFixer.

Was thinking that as well, removed the suggestion.

As for the @param, makes sense. So only those 2 points for me.

@kubawerlos
Copy link
Contributor Author

@dmvdbrugge @type added, yet I cannot find valid case for priority integration test with PhpdocVarWithoutNameFixer - it handles well name with both orders:

 <?php
 /**
- * @var FooInterface $foo
+ * @var FooInterface
  */
 $foo;
 
 /**
- * @var $bar BarInterface
+ * @var BarInterface
  */
 $bar;

@@ -40,7 +40,7 @@ public function provideFixCases()
$cases = [];

foreach (['internalSet', 'imapSet'] as $setStaticAttributeName) {
/** @var $aliases string[] */
/** @var string[] $aliases */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So nice that it immediately adds value to the project itself 🎉

@keradus keradus added this to the 2.14.0 milestone Aug 22, 2018
@keradus
Copy link
Member

keradus commented Jan 1, 2019

Thank you @kubawerlos.

@keradus keradus merged commit 8e031b2 into PHP-CS-Fixer:master Jan 1, 2019
keradus added a commit that referenced this pull request Jan 1, 2019
This PR was merged into the 2.14-dev branch.

Discussion
----------

Add PhpdocVarAnnotationCorrectOrderFixer

Closes #2159

Commits
-------

8e031b2 Add PhpdocVarAnnotationCorrectOrderFixer
@kubawerlos kubawerlos deleted the feature/add-var-order branch January 1, 2019 19:06
@SpacePossum
Copy link
Contributor

thanks @kubawerlos , very nice to have this one! : D

@phansys
Copy link
Contributor

phansys commented Jan 10, 2019

Thank you @kubawerlos! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants