Skip to content

[PropertyInfo] Fix dock block lookup fallback loop #27837

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

Merged
merged 3 commits into from
Jul 7, 2018
Merged

[PropertyInfo] Fix dock block lookup fallback loop #27837

merged 3 commits into from
Jul 7, 2018

Conversation

DerManoMann
Copy link
Contributor

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

getDocBlock() in PhpDocExtractor implements a fallback loop when trying to lookup a dock block for a property (property, accessor method, mutator method). This relies on the individual lookups to return null.

Unfortunately, phpDocumentor will throw an InvalidArgumentException exception in case there is no dock block.

Currently the try/catch is wrapping the whole loop which means if the first lookup fails the loop is ended instead of moving on to the next one.

This PR moves the try/catch to each individual call of $this->docBlockFactory->create().

@nicolas-grekas nicolas-grekas changed the title Fix dock block lookup fallback loop [PropertyInfo] Fix dock block lookup fallback loop Jul 4, 2018
@nicolas-grekas
Copy link
Member

Thanks for the PR and the clear description. Could you add a test case please?

@nicolas-grekas nicolas-grekas added this to the 4.1 milestone Jul 4, 2018
@nicolas-grekas nicolas-grekas changed the base branch from master to 4.1 July 4, 2018 15:30
@DerManoMann
Copy link
Contributor Author

Ah, looks like i rebased on master, not 4.1 ... is there an easy fix for this or is it better to create a new PR, I wonder?

// No valid doc block
}

return null;
Copy link
Member

Choose a reason for hiding this comment

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

You can return in the catch (same below)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was wondering ... I guess that a personal preference thing for me. I always feel it looks weird to not have a return at the end if the return type is not void.

This PR was merged into the 3.4 branch.

Discussion
----------

Replaced AppBundle mentions with App

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

Removed some legacy non-test related mentions of AppBundle. Probably this should be done for 4.x only, not >=3.4.

Commits
-------

b455237 AppBundle->App.
@nicolas-grekas nicolas-grekas modified the milestones: 4.1, 3.4 Jul 7, 2018
@nicolas-grekas nicolas-grekas changed the base branch from 4.1 to 3.4 July 7, 2018 14:54
@nicolas-grekas
Copy link
Member

Thank you @DerManoMann.

@nicolas-grekas nicolas-grekas merged commit b1a6120 into symfony:3.4 Jul 7, 2018
nicolas-grekas added a commit that referenced this pull request Jul 7, 2018
…oMann)

This PR was submitted for the 4.1 branch but it was squashed and merged into the 3.4 branch instead (closes #27837).

Discussion
----------

[PropertyInfo] Fix dock block lookup fallback loop

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

`getDocBlock()` in `PhpDocExtractor` implements a fallback loop when trying to lookup a dock block for a property (property, accessor method, mutator method). This relies on the individual lookups to return `null`.

Unfortunately, phpDocumentor will throw an `InvalidArgumentException` exception in case there is no dock block.

Currently the try/catch is wrapping the whole loop which means if the first lookup fails the loop is ended instead of moving on to the next one.

This PR moves the try/catch to each individual call of `$this->docBlockFactory->create()`.

Commits
-------

b1a6120 [PropertyInfo] Fix dock block lookup fallback loop
@nicolas-grekas
Copy link
Member

Merged on branch 3.4 by the way.

This was referenced Jul 23, 2018
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.

6 participants