Skip to content

[PropertyInfo] throw exception if docblock factory does not exist #26265

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 1 commit into from
Feb 22, 2018

Conversation

xabbuh
Copy link
Member

@xabbuh xabbuh commented Feb 22, 2018

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

@@ -53,6 +53,10 @@ class PhpDocExtractor implements PropertyDescriptionExtractorInterface, Property
*/
public function __construct(DocBlockFactoryInterface $docBlockFactory = null, array $mutatorPrefixes = null, array $accessorPrefixes = null, array $arrayMutatorPrefixes = null)
{
if (!class_exists(DocBlockFactoryInterface::class)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be interface_exists?

http://php.net/manual/en/function.interface-exists.php

Copy link
Member Author

Choose a reason for hiding this comment

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

good catch, in fact I wanted to use the DocBlockFactory class here as that's what is used below

@hkdobrev
Copy link
Contributor

@xabbuh 👍 I guess this is indeed not a BC break, but this doesn't solve the side effect I've described in #26259 (comment)

When you have the phpDocumentor installed locally, because of another dependency like PHPUnit, this would not throw an exception locally or in testing, but it would throw an exception on production without #26260.

@xabbuh
Copy link
Member Author

xabbuh commented Feb 22, 2018

That's true, but I don't think we can cover that in Symfony itself.

@hkdobrev
Copy link
Contributor

hkdobrev commented Feb 22, 2018

@xabbuh OK. What's your understanding of how that should be handled in the projects using the component? You should require a library noted in the docs even though you're not using its code directly, but it's used from your dependency?

Shouldn't the PhpDocExtractor be extracted into a separate package and then that package would have the phpDocumentor in its require block? Then if you use the PhpDocExtractor class you need to install its package and it would work without knowing what are its dependencies. Easier to document as well.

@@ -53,6 +53,10 @@ class PhpDocExtractor implements PropertyDescriptionExtractorInterface, Property
*/
public function __construct(DocBlockFactoryInterface $docBlockFactory = null, array $mutatorPrefixes = null, array $accessorPrefixes = null, array $arrayMutatorPrefixes = null)
{
if (!class_exists(DocBlockFactory::class)) {
throw new \RuntimeException(sprintf('Unable to use the %s class as the phpdocumentor/reflection-docblock package is not installed.', __CLASS__));
Copy link
Member

Choose a reason for hiding this comment

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

missing double quotes

@hkdobrev
Copy link
Contributor

This looks as a good improvement to me, but keen on hearing your thoughts on the above suggestion/question! Thanks!

@nicolas-grekas
Copy link
Member

Thank you @xabbuh.

@nicolas-grekas nicolas-grekas merged commit 5cfceed into symfony:3.4 Feb 22, 2018
nicolas-grekas added a commit that referenced this pull request Feb 22, 2018
…t exist (xabbuh)

This PR was merged into the 3.4 branch.

Discussion
----------

[PropertyInfo] throw exception if docblock factory does not exist

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

Commits
-------

5cfceed throw exception if docblock factory does not exist
@xabbuh xabbuh deleted the issue-26259 branch February 22, 2018 12:09
This was referenced Mar 1, 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