Skip to content

[Console] Review Application docblocks #20813

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

Closed
wants to merge 2 commits into from
Closed

[Console] Review Application docblocks #20813

wants to merge 2 commits into from

Conversation

ogizanagi
Copy link
Contributor

@ogizanagi ogizanagi commented Dec 7, 2016

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

I know there must be a lot of other places in the core where there is some repeated or useless informations in docblocks, but everytime I dig into the Application class, I see this, and I don't want to repeat things for consistency when adding new methods 😅 (for instance in #20808, the setCatchThrowables / areThrowablesCaught methods do not need a docblock description IMHO).

This PR adapts docblocks where:

  • A docblock description is not required, as everything can be expressed in the @return / @param argument (the case mentioned above)
  • Information is redundant between description and tags, and the context does not have to be reminded again:
    /**
     * Adds an array of command objects.
     *
     * If a Command is not enabled it will not be added.
     *
-     * @param Command[] $commands An array of commands
+     * @param Command[] $commands
     */
    public function addCommands(array $commands)
    {
        foreach ($commands as $command) {
            $this->add($command);
        }
    }

@fabpot
Copy link
Member

fabpot commented Dec 7, 2016

I'm 👎 on these changes. In theory, I agree with them, but as it makes merging more complex, and makes diffs between version non-readable, I think leaving them as is is the best thing to do. For new phpdocs, we should stick with the new "rules".

@nicolas-grekas nicolas-grekas modified the milestone: 2.7 Dec 7, 2016
@ogizanagi
Copy link
Contributor Author

Of course, I understand and expected your comment 😅 .
If those changes are actually rejected, maybe we can at least keep the ones about adding the @throws Throwable and associated descriptions for PHP 7?

@fabpot
Copy link
Member

fabpot commented Dec 7, 2016

Fixes on current docblocks are indeed acceptable :)

@@ -103,7 +101,8 @@ public function setDispatcher(EventDispatcherInterface $dispatcher)
*
* @return int 0 if everything went fine, or an error code
*
* @throws \Exception When doRun returns Exception
* @throws \Exception When doRun threw an exception and catchExceptions is false
* @throws \Throwable When doRun threw a throwable
Copy link
Member

Choose a reason for hiding this comment

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

Should be merged with the previous line \Exception|\Throwable

Copy link
Contributor Author

@ogizanagi ogizanagi Dec 7, 2016

Choose a reason for hiding this comment

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

Can be, but the aim was to point the fact all throwables are not caught by the application (yet), and thus not handled nicely, whereas as this can be configured for exceptions by setting catchExceptions to true.

#20808 replicates this behavior for throwables by adding a new catchThrowables property.

Copy link
Member

Choose a reason for hiding this comment

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

this should be removed entirely actually. It does not make any sense to document that it throws an exception when the inner code threw an exception. PHP does not require each class to document exceptions thrown in called codes (unlike Java)

@nicolas-grekas
Copy link
Member

This looks wrong to me. We don't document "rethrowing"

@ogizanagi
Copy link
Contributor Author

ogizanagi commented Dec 8, 2016

this should be removed entirely actually. It does not make any sense to document that it throws an exception when the inner code threw an exception. PHP does not require each class to document exceptions thrown in called codes (unlike Java)

This looks wrong to me. We don't document "rethrowing"

My opinion on this is that it matters only when it has value for the end user.
Application is an entrypoint. It may be useful to know if it handles gracefully or not exceptions for you, especially if it is conditional (the catchExceptions flag).

@ogizanagi
Copy link
Contributor Author

ogizanagi commented Dec 13, 2016

So, I'm not trying to be stubborn here, but simply explaining my thoughts on this in order to get yours 😃

What should be done here now?

  1. Merge as is: Adds the Throwable type and document under what conditions it's thrown, because it has a value for the end user, as Application is an entrypoint.
  2. Remove @throw tags from Application::run(), because we don't document rethrowing at all
  3. Something else?
  4. Close this PR

@fabpot
Copy link
Member

fabpot commented Dec 13, 2016

I would vote for 2

@ogizanagi
Copy link
Contributor Author

Done. Thanks for the answers. :)

@@ -832,7 +830,7 @@ protected function configureIO(InputInterface $input, OutputInterface $output)
*
* @return int 0 if everything went fine, or an error code
*
* @throws \Exception when the command being run threw an exception
* @throws \Throwable|\Exception when the command being run threw a throwable
Copy link
Member

Choose a reason for hiding this comment

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

should be removed too here, as this is also documenting a rethrowing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed. 👍

@fabpot
Copy link
Member

fabpot commented Dec 13, 2016

Thank you @ogizanagi.

fabpot added a commit that referenced this pull request Dec 13, 2016
This PR was squashed before being merged into the 2.7 branch (closes #20813).

Discussion
----------

[Console] Review Application docblocks

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

~I know there must be a lot of other places in the core where there is some repeated or useless informations in docblocks, but everytime I dig into the `Application` class, I see this, and I don't want to repeat things for consistency when adding new methods 😅  (for instance in #20808, the `setCatchThrowables / areThrowablesCaught ` methods do not need a docblock description IMHO).~

~This PR adapts docblocks where:~

- ~A docblock description is not required, as everything can be expressed in the `@return / @param` argument (the case mentioned above)~
- ~Information is redundant between description and tags, and the context does not have to be reminded again:~

```diff

    /**
     * Adds an array of command objects.
     *
     * If a Command is not enabled it will not be added.
     *
-     * @param Command[] $commands An array of commands
+     * @param Command[] $commands
     */
    public function addCommands(array $commands)
    {
        foreach ($commands as $command) {
            $this->add($command);
        }
    }
```

Commits
-------

d8c18cc [Console] Review Application docblocks
@fabpot fabpot closed this Dec 13, 2016
@ogizanagi ogizanagi deleted the console/docblocks branch December 13, 2016 15:38
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.

5 participants