-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpKernel] add use statement for phpdoc #11802
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
Conversation
| Q | A | ------------- | --- | Fixed tickets | symfony#11801 | License | MIT
Better change the PHPDoc to a fully qualified name than add an (unused) use statement. |
@dunglas nope. Our coding standards are to use the short name in the phpdoc |
👍 note to maintainers: this should go in 2.3 |
👍 |
Thank you @Miliooo. |
This PR was submitted for the master branch but it was merged into the 2.3 branch instead (closes #11802). Discussion ---------- [HttpKernel] add use statement for phpdoc | Q | A | ------------- | --- | Fixed tickets | #11801 | License | MIT Added use statement for the Phpdoc Commits ------- 0010fba [HttpKernel] add use statement for phpdoc
@stof for my curiosity, do you have a link or an explanation of why to do that? Thanks. |
By the way, the PSR-5 draft (PHPDoc) recommends to always use the Fully Qualified Class Name in DocBlock: https://github.com/php-fig/fig-standards/pull/169/files#diff-9a10a11696dc38209c125ea9c57a565fR1891 |
@dunglas the section you link is not telling that. It is saying that tools processing the phpdoc should resolve relative names to FQCN as soon as possible to make the processing easier (i.e. not having to remember the context). There is no recommendation at all about the way to write the class names in the phpdoc here |
@stof yes I've misunderstood the statement. But why add a use statement just for the PHPDoc? Importing unused classes cannot have a bad impact on performances (I don't know, I just ask)? |
@dunglas it makes PHPdocs a lot easier to read (especially when having namespaces as long as Symfony has). |
@dunglas it cannot impact the performance if you use opcache. Use statements are resolved early in the compilation of the code, and this is done only once in prod when you can the opcodes |
@stof thanks for the explanation :) |
@dunglas that is wrong. Classes are not autoloaded before they are actually used. |
@apfelbox thanks for the link. |
@apfelbox I'm not talking about the autoloading, but about the resolution of the name. Names are resolved even if the class does not exist. |
@stof I know that, but @dunglas was talking about the autoloading. 😉 a.k.a. there is no performance impact, because there is no autoloading (exactly due to the reason you described: in PHP the direction is reversed: local class name -> FQN -> autoload instead of Java's import (= autoload) -> FQN -> local class name). |
Ah, okay, sorry - misunderstood. But since the only thing affecting runtime performance here would be autoloading (and it doesn't happen), we can conclude that there is no impact. Right? |
Added use statement for the Phpdoc