Php-cs-fixer: Remove useless method comment

Created on 6 Feb 2017  路  11Comments  路  Source: FriendsOfPHP/PHP-CS-Fixer

It would be cool to have fixer like this:

Before

    /**
     * Constructor.
     *
     * @param CurrencyDataTransformer $currencyTransformer
     */
    public function __construct(CurrencyDataTransformer $currencyTransformer)
    {
        $this->currencyTransformer = $currencyTransformer;
    }

After

    /**
     * @param CurrencyDataTransformer $currencyTransformer
     */
    public function __construct(CurrencyDataTransformer $currencyTransformer)
    {
        $this->currencyTransformer = $currencyTransformer;
    }

because Constructor. is useless imo, or is this still possible?

Best regards and thank you,
Oskar

kinfeature request

Most helpful comment

Manual work is not helping us in any way. About willingness to follow the rule by some community - we already accepted the idea of this rule and we are willing to have PR for it opened, especially by the community that need it. So... go ahead @OskarStark ! We will help by reviewing ;)

All 11 comments

I would say your sample PHPDoc is overcomplete as a whole ;)

Anyway removing 'Constructor' (with or without trailing dot) as PHPDoc summary from constructors is fine by me :)
Removing @return annotations from constructors as well would be nice, but might be out-of-scope of the PR, although having a NoUselessStuffInAPHPDocOfConstructorsFixer could contain both ;)

not only constructor is a case.

/**
 * Class Foo.
 */
final class Foo
{
    /**
     * Constructor
     */
    public function __construct() {}

    /**
     * Destructor
     */
    public function __destruct() {}
}

@OskarStark , could you send a PR with proposal ?

Is there a fixer which could be used as an example to start working on a PR?

I would go for;
https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/2.0/src/Fixer/Phpdoc/PhpdocAddMissingParamAnnotationFixer.php

that fixer

  • searches for PHPDocs
  • check if the doc belong to a function (new one should be methods only)
  • check some things about the function (new one needs to check the name of the method only (case insensitive))
  • it checks and parses the PHPDoc (new needs to do that as well)
  • fixes the PHPDoc if needed

so I think most parts that you need are in there, however there is also a lot of stuff in there you can ignore as it is unrelated to the what the new fixer needs.

@OskarStark , could you send a PR with proposal ?

I checked the example, but to be honest, I currently don't have enough time to dive into it

not only constructor is a case.

you are right, with the Destructor and the * Class .... stuff, another thing could be:

/**
 * Foo <- without the 'Class' prefix
 */
class Foo {
    // ...
}

Sadly, I don't see how. Please provide more details.
Perhaps, you did that PR with using custom fixer you did already wrote and you want to share it with community ? :)

Sadly, I don't see how. Please provide more details.

it seems to be needed by the community :)

Perhaps, you did that PR with using custom fixer you did already wrote and you want to share it with community ? :)

No, this was just a sed replace and some manual adjustements

Manual work is not helping us in any way. About willingness to follow the rule by some community - we already accepted the idea of this rule and we are willing to have PR for it opened, especially by the community that need it. So... go ahead @OskarStark ! We will help by reviewing ;)

This would be fantastic!

If even comments like this could be removed:

// Do foo
$this->foo();

that would be amazing. I've seen other tools do this but I had no luck finding them again.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vitek-rostislav picture vitek-rostislav  路  3Comments

OskarStark picture OskarStark  路  3Comments

amitbisht511 picture amitbisht511  路  3Comments

UksusoFF picture UksusoFF  路  3Comments

aidantwoods picture aidantwoods  路  3Comments