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 PHPDoc blocks to AbstractMigration #1052

Open
wants to merge 1 commit into
base: 3.0.x
Choose a base branch
from

Conversation

koninka
Copy link

@koninka koninka commented Aug 31, 2020

Q A
Type improvement
BC Break no
Fixed issues

Summary

Add PHPDoc blocks to AbstractMigration methods. This could be useful for those who use @inheritdocannotation (like me:)).

@koninka koninka force-pushed the add-phpdoc-for-getdescription-method branch from cfbd10f to b45758d Compare August 31, 2020 06:30
@greg0ire
Copy link
Member

Why would it be useful?

@koninka
Copy link
Author

koninka commented Aug 31, 2020

@greg0ire

Hey,

  1. It's good practice to document your code.
  2. Having a description for the methods makes it easy to understand what they do. For example, the write and warnIf methods are not immediately obvious without additional code reading (not only in the AbstractMigration class).
  3. My case. I always document my code and use @inheritdoc for overridden vendor methods (e.g. getDescription). And if I use @inheritdoc and parent method has no phpdocs, then this is at least strange (also PHPStorm reports warning).

You have a description of the methods on the site, why not place the documentation in the code to save programmers from the need to google or research the code in depth to understand its work?

@greg0ire
Copy link
Member

  1. It is, but documentation has to bring value, otherwise you risk people not reading useful comment because most comments in your project are just noise. I'd argue that's the case of most comments in this PR.
  2. That's the part of the PR that might bring some value. If I were to merge anything here, that would be it.
  3. That's really personal, sorry but we are not going to pollute the code with tautological comments. If you want to add comments, they should bring value.

You have a description of the methods on the site, why not place the documentation in the code to save programmers from the need to google or research the code in depth to understand its work?

That's a good point, maybe there is valuable information here that could be fit in the comments. Description of this migration is not valuable information IMO. So is information already contained in type declarations.

@koninka
Copy link
Author

koninka commented Aug 31, 2020

@greg0ire

I got it. So, do I understand correctly, if I add a more useful description for the getDescription, then you will merge pr? Do I need to add a more detailed description to other methods?

P.S. I took a description of all methods from the official site (for method getDescription too).

@@ -60,11 +60,22 @@ public function isTransactional() : bool
return true;
}

/**
* Description of this migration.
Copy link
Member

Choose a reason for hiding this comment

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

Tautological, either improve or remove

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

Comment on lines 65 to 66
*
* @return string
Copy link
Member

Choose a reason for hiding this comment

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

Nothing new here, let's remove it

Suggested change
*
* @return string

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

Comment on lines 75 to 77
*
* @param bool $condition
* @param string $message
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
*
* @param bool $condition
* @param string $message

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

public function getDescription() : string
{
return '';
}

/**
* Warn with a message if some condition is met.
Copy link
Member

Choose a reason for hiding this comment

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

That's made fairly clear just by reading the signature (you don't have to read the code inside the method)

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

@@ -155,6 +166,11 @@ public function getSql() : array
return $this->plannedSql;
}

/**
* Write some debug information to the console.
Copy link
Member

Choose a reason for hiding this comment

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

debug information is written with debug(), this is a notice.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

Comment on lines 171 to 172
*
* @param string $message
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
*
* @param string $message

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

phpcs.xml.dist Outdated
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint.UselessAnnotation">
<exclude-pattern>lib/Doctrine/Migrations/AbstractMigration.php</exclude-pattern>
</rule>

Copy link
Member

Choose a reason for hiding this comment

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

Please revert this.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

@greg0ire
Copy link
Member

So, do I understand correctly, if I add a more useful description for the getDescription, then you will merge pr?

It's the opposite actually, if we merge the PR, then it means you will have added a more useful description for that method, but that will probably not be enough, since other methods need a better description too.

@koninka koninka force-pushed the add-phpdoc-for-getdescription-method branch from b45758d to 62f6570 Compare September 4, 2020 03:41
Comment on lines +63 to +67
/**
* Description of this migration.
*
* Describe what this migration does in simple terms. This information is displayed when you view the list of migrations.
*/
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/**
* Description of this migration.
*
* Describe what this migration does in simple terms. This information is displayed when you view the list of migrations.
*/
/**
* Describe what this migration does in simple terms. This information is displayed when you view the list of migrations.
*/

/**
* Write some debug information to the console.
*
* Debug information is written with debug().
Copy link
Member

Choose a reason for hiding this comment

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

🤔 I mean it should, but it's actually written with notice(), so that comment is just misleading

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

Successfully merging this pull request may close these issues.

2 participants