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

Introduction of SingleToMultiLinePhpdocFixer #3810

Open
wants to merge 9 commits into
base: master
from

Conversation

Projects
None yet
9 participants
@BackEndTea
Copy link
Contributor

BackEndTea commented Jun 3, 2018

Fixes: #2646

If preferred, i can target the changes to the Doc block class to the current LTS (2.2?), as its features are useful for a number of other fixers.

$ ./php-cs-fixer describe single_to_multi_line_phpdoc
Description of single_to_multi_line_phpdoc rule.
Changes doc blocks from single to multi line, or reversed.

Fixer is configurable using following options:
* const ('multi', 'single'): whether const blocks should be single or multi line; defaults to 'multi'
* property ('multi', 'single'): whether property doc blocks should be single or multi line; defaults to 'multi'
* method ('multi', 'single'): whether method doc blocks should be single or multi line; defaults to 'multi'

Fixing examples:

  • Example #1. Fixing with the default configuration.
    ---------- begin diff ----------
<?php
class Foo{
-    /** @var bool */
+    /**
+     * @var bool
+     */
    public $var;
}

----------- end diff -----------

  • Example #2. Fixing with configuration: ['property' => 'single'].
    ---------- begin diff ----------
<?php
class Foo{
-    /**
-    * @var bool
-    */
+    /** @var bool */
    public $var;
 }

----------- end diff -----------

@BackEndTea BackEndTea force-pushed the BackEndTea:featuer/single-or-multi-line-doc-block branch 3 times, most recently from 9d791e3 to 89fb6ec Jun 3, 2018

@SpacePossum

This comment has been minimized.

Copy link
Member

SpacePossum commented Jun 4, 2018

Nice work and 👍 for concept.
About priorities there is some stuff to check out I think, like when rules remove lines (phpdoc_no_useless_inheritdoc and others) or add lines (phpdoc_add_missing_param_annotation and possibly others), together with locking down the priority with phpdoc_to_comment

@julienfalque julienfalque added the feature label Jun 4, 2018

@BackEndTea BackEndTea force-pushed the BackEndTea:featuer/single-or-multi-line-doc-block branch from c2eea42 to 54e5e20 Jul 1, 2018

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

@hkdobrev

This comment has been minimized.

Copy link
Contributor

hkdobrev commented Aug 23, 2018

@BackEndTea Do you think that could be finalised for 2.14?

@BackEndTea

This comment has been minimized.

Copy link
Contributor Author

BackEndTea commented Aug 23, 2018

I won't have time until somewhere next week to work on this.

@TomasVotruba

This comment has been minimized.

Copy link

TomasVotruba commented Aug 31, 2018

@BackEndTea Thanks for your work, this is awesome feature 👍

@keradus

This comment has been minimized.

Copy link
Member

keradus commented Jan 1, 2019

I won't have time until somewhere next week to work on this.

@BackEndTea , feel free to ping us when you consider this ready.
in the meantime, i'm changing the milestone for this PR

@keradus keradus modified the milestones: 2.14.0, 2.12.5, 2.15.0 Jan 1, 2019

@BackEndTea

This comment has been minimized.

Copy link
Contributor Author

BackEndTea commented Jan 5, 2019

@keradus Sorry for the long delay on this, I kinda forgot about it.

Currently this only works for class methods, properties and constants, and i'm not 100% sure how to expand it to also work with functions, classes and other doc blocks.

@SpacePossum

This comment has been minimized.

Copy link
Member

SpacePossum commented Jan 5, 2019

I think that is a great set to start with (if that is somewhere in the description of the fixer 👍 ) as it would cover most common cases.

@jaikdean

This comment has been minimized.

Copy link

jaikdean commented Jan 18, 2019

I agree with SpacePossum, it would be great to see this released as it stands.

@BackEndTea BackEndTea force-pushed the BackEndTea:featuer/single-or-multi-line-doc-block branch from 812abaf to feb2d68 Feb 9, 2019

BackEndTea added some commits Feb 9, 2019

@BackEndTea BackEndTea force-pushed the BackEndTea:featuer/single-or-multi-line-doc-block branch from 151660f to 05d7f03 Feb 9, 2019

@BackEndTea BackEndTea force-pushed the BackEndTea:featuer/single-or-multi-line-doc-block branch from 3e7c6c1 to 6edbd79 Feb 9, 2019

@BackEndTea

This comment has been minimized.

Copy link
Contributor Author

BackEndTea commented Feb 9, 2019

@SpacePossum & @keradus Sorry for the long wait on this, but I have updated it, and it is ready for review.

I have rebased this and fixed a few remarks people had.
Current concerns are:

  • The fact that its 'incomplete' e.g. only class properties, constants and methods. But this should work as is.
  • Priorities with other fixes
  • The fact that this includes updates to the DocBlock class. This isn't a final class and could be extended by others.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment