Closed (won't fix)
Project:
Drupal core
Version:
8.0.x-dev
Component:
documentation
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
15 Nov 2012 at 00:08 UTC
Updated:
15 Apr 2015 at 10:18 UTC
Jump to comment: Most recent
Comments
Comment #1
jhodgdonHm.
I don't really see a problem with having use statements in the api.php files. Although they are just documentation, if we omit the use standards and have to use the fully-qualified namespaced class names in the doc there, it's very cumbersome. It seems to me that this is an excellent reason to have the use statements there, so that the hook docs can stay relatively clean and we know precisely which classes are being referred to. What's the problem?
Comment #2
xjmWell, we already agreed to use the fully-qualified namespaces anyway in #1487760: [policy, no patch] Decide on documentation standards for namespaced items.
Also, these 5 or so from the old entity patch are the only occurrence of use statements in *.api.php files. No other classes have use statements. I don't see any reason to include them unless
api.modulecan parse them and apply their namespace to typehints in hook definitions, or something.Comment #3
jhodgdon#2 is not quite accurate. We agreed to use fully-qualified namespaces only right after @param, @return, and other @tags, and we agreed to drop namespaces entirely and just use class names elsewhere in documentation. :)
API module doesn't yet do anything intelligent with namespaces. That's the Next Big Thing that needs to be done.
Comment #4
xjmMy thought is that if *.api.php did use namespaces, it could end up being zillions of
usestatements needed. At the least, there would be lots missing. They imply that a particular namespace is available in the scope of the file (which it isn't). I guess it only really applies to the typehints in the hook declarations, so maybe it would make sense to remove the few erroneous ones for now, and add them back universally if it turns out to be useful for api.d.o?Edit 2: The @param documents the typehint's class/namespace in any case.
Comment #5
jhodgdonThe API module will have to get smart about namespaces Real Soon Now (TM). :)
So I'm not sure what exactly you're proposing in #4.... here's a proposal of what I think would be useful to do:
****
If a piece of documentation prose (i.e., documentation apart from just after an @tag) or a code sample in a *.api.php file mentions or uses a namespaced class, a "use" statement should be put at the top of the file, along with a comment:
****
How about that? :)
Comment #6
kugta commentedDoesn't look like novice. Should be discussed by maintainers.
Comment #7
jhodgdonI'm going to close this as Won't Fix.
Our current policy is basically that we use namespaces in docs. However, api.php files also have code (function sample bodies), and it is not possible/appropriate to put namespaces in code everywhere.
So, the api.php files sometimes need use statements. It doesn't seem to be a problem.