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

Added More Phpdoc Fixers #887

Merged
merged 2 commits into from Feb 18, 2015
Merged

Added More Phpdoc Fixers #887

merged 2 commits into from Feb 18, 2015

Conversation

GrahamCampbell
Copy link
Contributor

TODO:

  • Added phpdoc_seperation
  • Fix the behaviour with some annotations like the phpunit ones - introduced a tag class
  • Refactor the docblock classes to model the situation more clearly
  • Add tests for the Tag class
  • Add tests for the DocBlock class
  • Added phpdoc_order
  • Perform regression testing on league/flysystem
  • Based on results from testing, make improvements
  • Add phpdoc_var fixer
  • Perform regression testing on symfony/symfony
  • Based on results from testing, make improvements, add more test cases
  • Move the phpdoc_order fixer to contrib level
  • Add a phpdoc_trim fixer at symfony level, partly taken from phpdoc_separation
  • Added phpdoc_no_return_void
  • Review fixer orders
  • Perform regression testing on guzzle/guzzle
  • @see, @link, @deprecated, @since, @author, @copyright, and @license annotations should be kept together rather than forced apart by the separation fixer
  • Support annotations with descriptions including bank lines
  • Perform regression testing on doctrine/common
  • Perform regression testing on guzzle/guzzle and symfony/symfony again
  • Fix more bugs, and add more test cases
  • Perform regression testing on flysystem guzzle, doctrine, symfony again
  • Analyse current code coverage and cleanup code
  • Add tests for the TagComparator
  • Add missing DocBlock class tests
  • Add tests for the Line class
  • Add tests for the Annotation class
  • Test on dingo/api, factory-muffin, aws sdk v2 and v3
  • Discuss fixer names
  • Add fixers to change var to type and type to var
  • Add a fixer to ensure short descriptions end in a ., ?, or !
  • Review by @keradus
  • Cleanup the docblock classes
  • Add a fixer to remove package and subpackage annotations
  • Complete reviews and testing

I THINK WE'RE DONE! :)

*
* @return bool
*/
private function isAnnotation($content)
Copy link
Member

Choose a reason for hiding this comment

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

this looks like static

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@ceeram
Copy link
Contributor

ceeram commented Dec 17, 2014

phpdoc_group_tags_fixer as name perhaps? i think its more clear then phpdoc
separate, as that could mean separate phpdocs from code around it as well,
also it does not really separate tags, but its more correctly grouping tags

2014-12-17 1:29 GMT+01:00 Coveralls notifications@github.com:

[image: Coverage Status] https://coveralls.io/builds/1622212

Coverage increased (+0.49%) when pulling 4ca6c6c
4ca6c6c
on GrahamForks:1.5-phpdoc-separation
into 10a42d0
10a42d0
on FriendsOfPHP:1.5
.


Reply to this email directly or view it on GitHub
#887 (comment)
.

@GrahamCampbell GrahamCampbell changed the title Added PhpdocSeparationFixer [WIP] Added PhpdocSeparationFixer Dec 17, 2014
@GrahamCampbell GrahamCampbell changed the title [WIP] Added PhpdocSeparationFixer [WIP] Added Two More Phpdoc Fixers Dec 18, 2014
@GrahamCampbell
Copy link
Contributor Author

Flysystem regression testing: thephpleague/flysystem#351.

@GrahamCampbell
Copy link
Contributor Author

Running on symfony revealed a few issues:


  1. The order of the throws statements should not change, but the move of the returns annotation was correct.
    image

EDIT: FIXED


  1. The separation fixer should not totally remove docblocks. This was caused by the forward and backward passes we made to look for blank lines before the real docblock content. We need to be careful not to delete everything if there is no content.

Before:

    /**
     *
     */

After:

Also, note how the end result also has unwanted whitespace.

EDIT: FIXED


  1. Issues with deleted content. This happens when we're looking for the next annotation, but the description from the previous annotation has been separated. We need to improve how we detect the annotation description has finished. A blank line of docblock is not sufficient.
    image

EDIT: FIXED


  1. Ok, this is odd...
    image

EDIT: FIXED

@GrahamCampbell GrahamCampbell changed the title [WIP] Added Two More Phpdoc Fixers [WIP] Added More Phpdoc Fixers Dec 19, 2014
@keradus keradus mentioned this pull request Dec 19, 2014
@keradus
Copy link
Member

keradus commented Dec 19, 2014

Oh my... huge progress from last time I see this PR !

@GrahamCampbell
Copy link
Contributor Author

:)

@keradus
Copy link
Member

keradus commented Dec 19, 2014

Could you explain (in code ;) ) why the used fixers order are needed? What do we gain by it ?

@GrahamCampbell
Copy link
Contributor Author

I thought I had. Err, well. The trim fixer needs to run quite late because the return void fixer can leave behind blank docblock lines if someone has separated it from the param annotations for example.

* with this source code in the file LICENSE.
*/

namespace Symfony\CS\DocBlock;
Copy link
Member

Choose a reason for hiding this comment

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

please, create a testsuit in phpunit.xml.dist for DocBlock namespace

Copy link
Member

Choose a reason for hiding this comment

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

I, personally, would set "general" first and then all others alphabetically.
But for me it doesn't really matters...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done:

    <testsuites>
        <testsuite name="general">
            <directory>./Symfony/CS/Tests/</directory>
            <exclude>
                <directory>./Symfony/CS/Tests/Fixer/</directory>
                <directory>./Symfony/CS/Tests/Fixtures/</directory>
                <directory>./Symfony/CS/Tests/Tokenizer/</directory>
            </exclude>
        </testsuite>
        <testsuite name="fixer">
            <directory>./Symfony/CS/Tests/Fixer/</directory>
        </testsuite>
        <testsuite name="tokenizer">
            <directory>./Symfony/CS/Tests/Tokenizer/</directory>
        </testsuite>
        <testsuite name="docblock">
            <directory>./Symfony/CS/Tests/DocBlock/</directory>
        </testsuite>
    </testsuites>

@GrahamCampbell
Copy link
Contributor Author

There are loads of cases here - difficult to write them all down.

@keradus
Copy link
Member

keradus commented Dec 19, 2014

Somehow you decided about that and not other order. Just please, write it down. If not then somebody in future may don't understand it and remove it.

@GrahamCampbell
Copy link
Contributor Author

Somehow you decided about that and not other order. Just please, write it down. If not then somebody in future may don't understand it and remove it.

I'll add that to the todo as the order might change again after more testing on different repos.

@keradus
Copy link
Member

keradus commented Dec 19, 2014

great !

@GrahamCampbell
Copy link
Contributor Author

Second round of testing on symfony:

image

Note how these lines are missing a space after the *. That's causing us to process them incorrectly.

This also brings to my attention that the behaviour with that annotation is undefined anyway since I've got no tests for it. Need to sort this...

EDIT: FIXED

@GrahamCampbell
Copy link
Contributor Author

Symfony seems to like to keep @see and @author separated. I need to change the way I deal with this. Probably need a tag comparator class or something.

image

EDIT: FIXED

@GrahamCampbell
Copy link
Contributor Author

@keradus Alright - where I'm at now - This is essentially feature complete, and current code coverage is 100%. I've still got some more unit tests to write for the docblocks classes in isolation, but we should be nearing completion.

@GrahamCampbell
Copy link
Contributor Author

All the tests are done now. Now we need to discuss fixer names.

The following are new fixers introduced by this pull:

phpdoc_no_return_void

@return void and @return null annotations should be omitted from phpdocs.

phpdoc_separation

Annotations in phpdocs should be grouped together so that annotations of the same type immediately follow each other, and annotations of a different type are separated by a single blank line.

phpdoc_trim

Phpdocs should start and end with content, excluding the very fist and last line of the docblocks.

phpdoc_var

@var and @type annotations should not contain the variable name.

phpdoc_order

Annotations in phpdocs should be ordered so that param annotations come first, then throws annotations, then return annotations.

@keradus
Copy link
Member

keradus commented Dec 20, 2014

phpdoc_no_return_void
so no void? in descr I see null too. maybe phpdoc_no_empty_return ?

Other names are good for me

@keradus
Copy link
Member

keradus commented Dec 20, 2014

phpdoc_var
what about fixer that standardize @var vs @type
?

@GrahamCampbell
Copy link
Contributor Author

phpdoc_var currently removes the variable name from the annotation. If we were to add a fixer to change @type -> @var, then I guess they both need better names.

I've renamed that other fixer.

@GrahamCampbell
Copy link
Contributor Author

Renaming phpdoc_var to phpdoc_var_without_name.

@GrahamCampbell
Copy link
Contributor Author

Just added phpdoc_type_to_var and phpdoc_var_to_type.


public function testSingleLine()
{
$expected = <<<'EOF'
Copy link
Member

Choose a reason for hiding this comment

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

why a nowdoc instead of simply '<?php ...' ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@GrahamCampbell
Copy link
Contributor Author

@keradus Is there any chance you could finish this off for me. I don't think I'll be able to do anything here in the next 24 hours. Sorry.

@keradus
Copy link
Member

keradus commented Feb 6, 2015

@GrahamCampbell you know that when I could help I do it, I send PRs into yours few times, event into this one.
The problem here is that you set some priorities that I don't understand. And without answering my questions about them I simply can't help, even when I want to.
The questions are collected in my comment.
When you will answer the questions about priority then I could help it in one or another way. Not before :(

@GrahamCampbell
Copy link
Contributor Author

Just rebased.

@keradus
Copy link
Member

keradus commented Feb 10, 2015

ping @GrahamCampbell

@GrahamCampbell
Copy link
Contributor Author

I'll rebase again, look into the failing tests, then address those remaining issues.

@keradus
Copy link
Member

keradus commented Feb 10, 2015

cool, any chances to see you on gitter ?

@keradus
Copy link
Member

keradus commented Feb 12, 2015

ping @GrahamCampbell

@keradus
Copy link
Member

keradus commented Feb 17, 2015

@GrahamCampbell
Copy link
Contributor Author

Awesome @keradus. :)

@keradus
Copy link
Member

keradus commented Feb 17, 2015

Please rebaser to get rid of that merge commit and squash your commits into one, there should be one commit per one author.

@keradus
Copy link
Member

keradus commented Feb 18, 2015

ping @GrahamCampbell

@GrahamCampbell
Copy link
Contributor Author

@keradus Will do very shortly. :)

@GrahamCampbell
Copy link
Contributor Author

@keradus Done!

@keradus keradus removed the WIP label Feb 18, 2015
@keradus
Copy link
Member

keradus commented Feb 18, 2015

Thank you @GrahamCampbell. Great work here! ;)

@keradus keradus merged commit 0006059 into PHP-CS-Fixer:1.5 Feb 18, 2015
keradus added a commit that referenced this pull request Feb 18, 2015
This PR was merged into the 1.5 branch.

Discussion
----------

Added More Phpdoc Fixers

TODO:
* [x] Added phpdoc_seperation
* [x] Fix the behaviour with some annotations like the phpunit ones - introduced a tag class
* [x] Refactor the docblock classes to model the situation more clearly
* [x] Add tests for the `Tag` class
* [x] Add tests for the `DocBlock` class
* [x] Added phpdoc_order
* [x] Perform regression testing on league/flysystem
* [x] Based on results from testing, make improvements
* [x] Add phpdoc_var fixer
* [x] Perform regression testing on symfony/symfony
* [x] Based on results from testing, make improvements, add more test cases
* [x] Move the phpdoc_order fixer to contrib level
* [x] Add a phpdoc_trim fixer at symfony level, partly taken from phpdoc_separation
* [x] Added phpdoc_no_return_void
* [x] Review fixer orders
* [x] Perform regression testing on guzzle/guzzle
* [x] `@see`, `@link`, `@deprecated`, `@since`, `@author`, `@copyright`, and `@license` annotations should be kept together rather than forced apart by the separation fixer
* [x] Support annotations with descriptions including bank lines
* [x] Perform regression testing on doctrine/common
* [x] Perform regression testing on guzzle/guzzle and symfony/symfony again
* [x] Fix more bugs, and add more test cases
* [x] Perform regression testing on flysystem guzzle, doctrine, symfony again
* [x] Analyse current code coverage and cleanup code
* [x] Add tests for the `TagComparator`
* [x] Add missing `DocBlock` class tests
* [x] Add tests for the `Line` class
* [x] Add tests for the `Annotation` class
* [x] Test on dingo/api, factory-muffin, aws sdk v2 and v3
* [x] Discuss fixer names
* [x] Add fixers to change var to type and type to var
* [x] Add a fixer to ensure short descriptions end in a `.`, `?`, or `!`
* [x] Review by @keradus
* [x] Cleanup the docblock classes
* [x] Add a fixer to remove package and subpackage annotations
* [x] Complete reviews and testing

I THINK WE'RE DONE! :)

Commits
-------

0006059 Enhance tests of order of phpdoc fixers
9f3aab8 Added more phpdoc fixers
@GrahamCampbell GrahamCampbell deleted the 1.5-phpdoc-separation branch February 18, 2015 18:04
@GrahamCampbell
Copy link
Contributor Author

Pleasure. :)

@keradus
Copy link
Member

keradus commented Feb 18, 2015

Merging for over 30 minutes but merged into 2.0 as well.
Almost 5.2k assertions on it ;)

@GrahamCampbell
Copy link
Contributor Author

Wow. :)

@GrahamCampbell
Copy link
Contributor Author

What's the timescale on the 1.5 release btw?

@keradus
Copy link
Member

keradus commented Feb 18, 2015

You know this was the last one PR into 1.5.
Next steps as always:

  • merge into next major to see if all new things are compatible [done]
  • prepare changelog [working on it]
  • release ;)

@GrahamCampbell
Copy link
Contributor Author

Sweet!

@keradus
Copy link
Member

keradus commented Feb 18, 2015

Ow, and one more step, actually first step at all..
regression on Symfony 2.3 and ZF2.

But I have done it for 1.5 this morning merging everything locally ;) Even 2 PR were sent ;)

joshtrichards pushed a commit to joshtrichards/symfony-finder that referenced this pull request Apr 26, 2024
This PR was squashed before being merged into the 2.3 branch (closes #13066).

Discussion
----------

[2.3] CS And DocBlock Fixes

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | N/A
| License       | MIT
| Doc PR        | N/A

##### This pull request provides some cs and docblock fixes.

@fabpot The second commit of the two applies the docblock fixes you wanted, using PHP-CS-Fixer/PHP-CS-Fixer#887. I made 3 or 4 minor manual changes because people had put bulleted lists in the "short description" which is not allowed, so we were ending up with colons followed by full stops. I've moved those lists to be part of a "long description".

// cc @keradus

Commits
-------

081dd99 [2.3] CS And DocBlock Fixes
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

5 participants