Postponed on #3112830: [policy, no patch] Allow static::methodName() and/or self::methodName() in @see comments when referring to the same class
On the database.api.php file the @see tags referring to class/interface names don't use a fully qualified class name, as the Drupal coding standards (API documentation and comment standards, classes) says.
Immediately after an @tag (@param, @return, @var, etc.), class and interface names must always include the fully-qualified namespace.
In that file, I found two comments that don't follow that standard.
/**
* Perform alterations to a structured query.
*
* Structured (aka dynamic) queries that have tags associated may be altered by any module
* before the query is executed.
*
* @param $query
* A Query object describing the composite parts of a SQL query.
*
* @see hook_query_TAG_alter()
* @see node_query_node_access_alter()
* @see AlterableInterface
* @see SelectInterface
*
* @ingroup database
*/
/**
* Perform alterations to a structured query for a given tag.
*
* Some common tags include:
* - 'entity_reference': For queries that return entities that may be referenced
* by an entity reference field.
* - ENTITY_TYPE . '_access': For queries of entities that will be displayed in
* a listing (e.g., from Views) and therefore require access control.
*
* @param $query
* An Query object describing the composite parts of a SQL query.
*
* @see hook_query_alter()
* @see node_query_node_access_alter()
* @see AlterableInterface
* @see SelectInterface
*
* @ingroup database
*/
The same issue is probably present in more files.
Comments
Comment #2
gnanagowthaman sankar commentedHi @kiamlaluno,
Here by i attached the patch. Please let me know for changes.
Thanks & Regards,
Gnanagowthaman sankar
Comment #3
gnanagowthaman sankar commentedPatch
Thanks & Regards,
Gnanagowthaman sankar
Comment #4
neel24 commentedPatch tested and applies cleanly.
Comment #5
avpadernoThe patch is not modifying any of the
@seetags, which was the reason of the report.The patch should also change all the content of the file, not just two comments.
Comment #6
hardik_patel_12 commentedFollow a new patch , and @kiamlaluno can you help us here to understand what do you mean by "The patch should also change all the content of the file, not just two comments." so we can help out more easily.
Thankyou
Comment #7
avpadernoI meant that every tag in that file should be changed to use a full-qualified class name, not just the comments I shown in the OP.
Comment #8
avpadernoThe patch changes all the tags that reference a class name.
Comment #9
pratik_kamble+1 RTBC.
Comment #11
avpadernoThe failing test isn't related to this patch.
Comment #12
hardik_patel_12 commentedThe failing test isn't related to #6 patch. So changing status.
Comment #13
hardik_patel_12 commentedComment #14
longwaveComment #15
hardik_patel_12 commentedKindly review a new patch which is collaborate with #3103803 : @see tags don't use fully qualified class/interface names
Comment #16
hardik_patel_12 commentedComment #17
hardik_patel_12 commentedComment #18
shimpyHi I have reviewed #16. Failed to apply patch for test file changes.
/core/modules/system/src/Tests/System/SystemConfigFormTestBase.php
Comment #19
shimpyComment #20
avpaderno@shimpy If the patch didn't apply, the automatic tests would report that, since they apply the patch before testing it. If it doesn't apply for your local copy, it means your local copy needs to be updated.
Comment #21
shimpyoh ok Thanks @kiamlaluno for reminding me to update my local copy. I will do and will test it again.
Comment #22
hash6 commentedComment #23
hash6 commentedThanks @Hardik_Patel_12 for the patch.Classname has been changed to appropriate namespace of @see tags.
Comment #24
hash6 commentedComment #25
longwaveGentle hint to anyone reviewing this, can you also look at #3100251: Several code comments have incorrect namespaces for classes or interfaces they reference which is similar?
Comment #26
dwwThanks for the contributions here, and trying to improve Drupal core!
Some issues with the latest patch in #16:
These comments now exceed 80 chars wide, trading one code standard "violation" for another. ;)
I think #3112830: [policy, no patch] Allow static::methodName() and/or self::methodName() in @see comments when referring to the same class is the better solution when referring to other methods in the same class.
Same here.
Right, you're doing it here... why not be consistent about it?
I thought we don't end with the period for @see comments. I believe this should be:
@see \Drupal\plugin_test\Plugin\MockBlockManager::_construct()static:: or self:: would be better.
And here.
Generally, is this issue trying to fix all @see references in all of core? I haven't grepped to verify if this fixes them all. The summary is only talking about a single file, but the patch is doing more than that. The summary should be updated to reflect the intention and scope of this change.
I'm strongly in favor of:
a) Postponing this until #3112830: [policy, no patch] Allow static::methodName() and/or self::methodName() in @see comments when referring to the same class is fixed and officially adopted as the standard (since core does it already, but it's not technically documented as our standard).
b) Then making sure this one issue fixes all lingering places that don't fully qualify the class in any @see comment, anywhere, in all of core (not separate issues for files, directories, subsystems, etc).
c) If @see is pointing to a constant or method in the same class, use
static::orself::(consistently). Otherwise, use the fully qualified class name.Thanks!
-Derek
Comment #27
avpadernoIs it correct to use a
@seetag in a sentence? I understood that it should just be followed by a class or method name; in the other cases, the sentence should start with See, the verb.Comment #28
dwwYeah, that, too. ;) I believe the standards (and IDE integration) expects @see only in docblocks at the start of functions, and that they're not supposed to be used in inline comments. I personally disagree with this, but it's obviously not up to me. ;)
Comment #29
rithesh bk commentedwe will work on VbContribution2020
Comment #30
prabha1997 commentedComment #31
prabha1997 commentedI did changes based on @dww suggestions. Kindly review patch
Comment #33
kishor_kolekar commentedI've re-rolled patch for 9.1
Comment #34
dwwFor the the updates and new patches, folks!
However, per #26.a, I'm going to formally postpone this issue on resolving #3112830: [policy, no patch] Allow static::methodName() and/or self::methodName() in @see comments when referring to the same class, first. Once that's fixed, we can proceed here. Until that happens, we're potentially wasting our time doing the wrong things.
Thanks,
-Derek
Comment #39
quietone commentedJust adding Coding Standards tag.
Comment #43
quietone commentedTurns out this is a duplicate of an earlier issue, #2662208: Fix @see documentation in core. However, this has a more discussion. So, I will close the older one in favor of this one and add credit. Coding standards issues are usually tasks, so changing category as well.