Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[cs] remove unused doc blocks#24931

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
TomasVotruba wants to merge2 commits intosymfony:masterfromTomasVotruba:cs-remove-unused-docs
Closed

[cs] remove unused doc blocks#24931

TomasVotruba wants to merge2 commits intosymfony:masterfromTomasVotruba:cs-remove-unused-docs

Conversation

@TomasVotruba
Copy link
Contributor

QA
Branch?master
Bug fix?no
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
LicenseMIT

Follow-up to#24930

/**
* Classes used for testing createResourceForClass
*/
class ClassForResource
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

These docs were incorrectly interpretted by PHP CS Fixer as single line, thus fixing them to Doc Blocks

@javiereguiluz
Copy link
Member

Even if I'd love to remove all PHPdocs from all files ... I find it strange to keep some@param and remove others. This is confusing and it will make people submit PRs to add the missing@params in PHPdocs.

@TomasVotruba
Copy link
ContributorAuthor

Some have added value, some don't and only duplicate information.
What do you suggest then?

@javiereguiluz
Copy link
Member

What you did is correct, but let me explain the problem I see (using as an example the first change you did):

Original

/**  * Adds the stack logger for a connection.  *  * @param string     $name  * @param DebugStack $logger  */publicfunction addLogger($name,DebugStack$logger)

Proposed solution

/**  * Adds the stack logger for a connection.  *  * @param string $name  */publicfunction addLogger($name,DebugStack$logger)

Best solution

publicfunction addLogger(string$name,DebugStack$logger)

We can't make the best solution to avoid BC issues, but the problem I see with the proposed solution is that people will think we made a mistake and forgot to add the$logger argument in the PHPdocs, because the method has 2 arguments but PHPdoc has only 1.

gmponos reacted with thumbs up emoji

@stof
Copy link
Member

Yeah, I think partial phpdoc is confusing for users. We should keep an all-or-nothing approach for the parameter list IMO

gmponos reacted with thumbs up emoji

@TomasVotruba
Copy link
ContributorAuthor

TomasVotruba commentedNov 14, 2017
edited
Loading

I see what you mean. Is there any reason to have it such way apart historical reasons? I realize there were not such tools in the past, but today thanks to coding standard tools this is now easy to configure and improve.

It will make code mucheasier to read for users and easier modify in the future. Moving toBest solution as next step.

Merged Use Case

Similar PRswere merged tophp-ai/php-ml lately. Removing over 1700 useless lines.

See especially these cases:https://github.com/php-ai/php-ml/pull/145/files#diff-1359851beb8da185b9d9adae86ab2ff7

@nicolas-grekas
Copy link
Member

people will think we made a mistake and forgot to add the $logger argument in the PHPdocs

This will not happen if fabbot generates the patch, because then, it will become an enforced policy.
So IMHO, we should do this change, but only when fabbot is able to generate the patch.

TomasVotruba reacted with thumbs up emoji

@nicolas-grekasnicolas-grekas added this to the2.7 milestoneNov 27, 2017
* @param ObjectManager $manager
* @param mixed $queryBuilder
* @param string $class
* @param mixed $queryBuilder
Copy link
Member

Choose a reason for hiding this comment

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

mixed params could be removed as well asmixed does not give any useful information.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I'd rather keep this, sincemixed type is comming to PHP and it would make easier transition to scalar type, as instring,int etc. before

@fabpot
Copy link
Member

@TomasVotruba Can you also change the base to 2.7? Thanks.

Are you doing this by hand? Or with a tool? If you are using a tool/regexes/..., can you share it so that merging up to master will be easier?

@TomasVotruba
Copy link
ContributorAuthor

@fabpot Here is all you asked for:https://www.tomasvotruba.cz/blog/2017/12/17/new-in-symplify-3-doc-block-cleaner-fixer/

Shall I run this rule on 2.7 with current setup then?

@fabpot
Copy link
Member

@TomasVotruba Can you share you setup? Such PRs are complex to merge as merging it to newest branches is a mess. So, if you can share you setup, I will be able to run it on all branches, limiting the time it takes to merge the change up. Thanks.

@TomasVotruba
Copy link
ContributorAuthor

@fabpot
Copy link
Member

@TomasVotruba I've just tried by it fixes only 15 files.

@TomasVotruba
Copy link
ContributorAuthor

TomasVotruba commentedJan 19, 2018
edited
Loading

@fabpot I'm not aware of any major change that could cause this.
Could you share full install script and run command?

And version? Last is 3.1
On which branch?

@fabpot
Copy link
Member

I've tried on master and v3.2.2, which looks like the last one (from a git clonehttps://github.com/Symplify/EasyCodingStandard)

@TomasVotruba
Copy link
ContributorAuthor

@fabpot I meant 3.2, yes.
I'll check it then

@TomasVotruba
Copy link
ContributorAuthor

TomasVotruba commentedJan 19, 2018
edited
Loading

I tried it like this:

git clone github.com/symfony/symfonycd ../symplify# monorepo, with 3.2.3 version (I fixed one variadics bug and just released patch version)packages/EasyCodingStandard/bin/ecs check ../symfony/src/Symfony --clear-cache --config cleaning-symfony.neon

Wherecleaning-symfony.neon

# cleaning-symfony.neoncheckers:    -Symplify\CodingStandard\Fixer\Commenting\RemoveUselessDocBlockFixer

With this result:

result-1
files:

Then with--fix option I'll really get 200 changed files:

image

@fabpot
Copy link
Member

I think I forgot to pass the config file. Now it looks much better, but I get this error:

PHP Notice:  Undefined offset: 0 in /Users/fabien/Code/github/Symplify/EasyCodingStandard/vendor/symplify/better-reflection-docblock/src/Tag/TolerantParam.php on line 132Notice: Undefined offset: 0 in /Users/fabien/Code/github/Symplify/EasyCodingStandard/vendor/symplify/better-reflection-docblock/src/Tag/TolerantParam.php on line 132In FixerFileProcessor.php line 125:  Fixing of "src/Symfony/Component/Translation/Dumper/FileDumper.php" file by "Symplify\CodingStandard\Fixer\Commenting\RemoveUselessDocBlockFixer" failed: substr() expects parameter 1 to be string,  null given in file /Users/fabien/Code/github/Symplify/EasyCodingStandard/vendor/symplify/better-reflection-docblock/src/Tag/TolerantParam.php on line 132

Note that I got the config from your blog post.

@fabpot
Copy link
Member

fabpot commentedJan 20, 2018
edited
Loading

Also, I noticed that it removes the blank line between@params and@throws/@return, how can I disable this behavior?

@TomasVotruba
Copy link
ContributorAuthor

TomasVotruba commentedJan 20, 2018
edited
Loading

I think I forgot to pass the config file. Now it looks much better, but I get this error:

That's what I fixed. Do you have version 3.2.3?

Note that I got the config from your blog post.

Use the one provided here, just to be sure the main fixer works for you. The other 2 are just space fixers.

Also, I noticed that it removes the blank line between@params and @throws/@return, how can I disable this behavior?

I thinks so. Will create issue for that. It usesReflectionDocBlock which renders all docblock in one format.

@fabpot
Copy link
Member

Ok, I forgot to runcomposer up as the fix was in a dep apparently :)

@fabpotfabpot mentioned this pull requestJan 20, 2018
@fabpot
Copy link
Member

See#25859 for the current state.

@fabpotfabpot closed thisJan 20, 2018
@TomasVotrubaTomasVotruba deleted the cs-remove-unused-docs branchJanuary 20, 2018 16:10
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot requested changes

Assignees

No one assigned

Projects

None yet

Milestone

2.7

Development

Successfully merging this pull request may close these issues.

6 participants

@TomasVotruba@javiereguiluz@stof@nicolas-grekas@fabpot@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp