Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Add @return values at comment docblocks for core/includes/* files where they are missing.
Comment | File | Size | Author |
---|---|---|---|
#25 | interdiff-2606268-21-25.txt | 435 bytes | ashhishhh |
#25 | 2606268-25.patch | 1.68 KB | ashhishhh |
#23 | 2606268-23.patch | 1.68 KB | Shreya Shetty |
#21 | interdiff-2606268-17-21.txt | 693 bytes | ashhishhh |
#21 | 2606268-21.patch | 1.67 KB | ashhishhh |
Comments
Comment #2
heykarthikwithuAdded a patch for this.
Comment #3
heykarthikwithuComment #4
jhodgdonHm. It seems like this may be a duplicate of another issue, but I'm not finding it at the moment.
Anyway, thanks! But...
If you are going to add an @return array line, you also need to add documentation to it.
This is not a valid type.
See
https://www.drupal.org/node/1354#types
Comment #5
heykarthikwithuComment #6
heykarthikwithuAdded the comment for
@return
and changed the@return
value.Comment #7
heykarthikwithuComment #8
heykarthikwithuComment #9
jhodgdonThanks! This needs some work though:
We do not normally start @return doc lines with "Return". Just say "The schema...".
Also it isn't any old module whose schema is returned, so "a" should be "the".
The @return type is incomplete here. It should probably be a specific type of object not generic "object" ? unsure... but it should also be |false according to the docs line.
Comment #10
heykarthikwithuworking on.
Comment #11
heykarthikwithu1. Changed to "The schema of the module.".
2. This returns a resource object or bool value false, So changed this to
Comment #12
jhodgdonThanks for the patch! Hmmm....
Um. Isn't it always an array? I don't think this function can ever return something other than an array.
What is "resource"? If it is a class, give the full namespace of the class. If it is an array, call it an array. If it's a generic PHP object, call it "object". But "resource" isn't something I recognize.
Comment #13
priya.chat CreditAttribution: priya.chat at Publicis Sapient for Publicis Sapient commentedComment #14
priya.chat CreditAttribution: priya.chat at Publicis Sapient for Publicis Sapient commentedHello, I have applied the last patch given by heykarthikwithu , thanks for the patch. Now I have added the changes that required.
Comment #15
priya.chat CreditAttribution: priya.chat at Publicis Sapient for Publicis Sapient commentedComment #16
jhodgdonPLEASE make an interdiff file when you create a new patch on an issue that had a previous patch. Do not put the changes into a comment. Make an interdiff file and attach it. Thanks!
So... mostly looks good! But this return line is still not right:
This is my fault -- I'm sorry about the previous review... I looked more carefully at the code this time. It turns out that this function is returning the output of the PHP xml_parser_create() function.
This is in fact a resource handle, not an xml object and not a generic object. See
http://php.net/manual/en/language.types.resource.php
So. It looks like we should actually say the return type is
resource|false
Also the docs line needs adjustment since this is not an "XML object" but a "resource handle for the XML parser".
I will add this to https://www.drupal.org/node/1354#types also because "resource" is a valid type to indicate.
Comment #17
heykarthikwithuChanges done as per #16.
Comment #18
jhodgdonThanks! This one looks right to me.
Comment #19
xjmThanks @jhodgdon for the explanation in #16 and the update to https://www.drupal.org/node/1354#types; those comments helped me review this patch.
For complex array structures, we should generally explain what the structure of the array is or where it is defined. Looking at the code, it should say something like, "The complete schema of the module as defined in
hook_schema()
, or the schema for $table for the module."(The complexity of the return value there suggests that really this should be two separate functions. But that's out of scope here; probably that refactor would be a part of moving these to the module handler service or a specific service for module schemata.)
I also noticed that the
$table
parameter is missing its(optional)
. I'd be okay with adding that small fix to the scope here since it's related to the return value that needs to be documented.The other two return values in the patch look correct to me. Since checking and correcting return values for individual functions requires reviewing each closely, I think the scope of this issue makes sense. (I.e., it would unnecessarily complicate things to expand the scope to include fixing @return values across core.) So let's just clarify that return value for drupal_get_module_schema(). Thanks!
Comment #20
ashhishhh CreditAttribution: ashhishhh at Valuebound commentedComment #21
ashhishhh CreditAttribution: ashhishhh at Valuebound commentedComment #22
jhodgdonThanks! For this review, I only looked at the interdiff file... It's mostly good but:
This needs "the" before "module's", which was there in the original before this patch. Please restore it. Thanks!
Comment #23
Shreya Shetty CreditAttribution: Shreya Shetty at Trigyn Technologies Ltd commentedHi jhodgdon,
Thanks for the review , improvements made as per your suggestion.
Comment #24
ashhishhh CreditAttribution: ashhishhh at Valuebound commentedComment #25
ashhishhh CreditAttribution: ashhishhh at Valuebound commented@Shreya, Interdiff file is important here.
As jhodgdon mentioned in #22. She reviewed only interdiff file.
I reworked on #22 and provided patch with interdiff file.
Comment #26
Shreya Shetty CreditAttribution: Shreya Shetty at Trigyn Technologies Ltd commentedthanks ashish for the interdiff next time will give a patch with interdiff.
Comment #27
jhodgdonOK, these 3 random doc block changes look fine to me now. Thanks!
Comment #28
alexpottHere we have a mix of new and changed documentation with a simple addition of type hints. Which is a mixing of scope.
This is out of scope as it is not about return values.
See #2608536-14: Some fixes for 'optional' parameter in core/include for a recent comment about scoping issues.
Comment #29
jhodgdonI think this issue just needs to be closed as Won't Fix for scope problems. See
https://www.drupal.org/core/scope