Problem/Motivation
This issue isolates components of its parent issue #2259979: Docblock fixes in database system, part I, which had become too large to effectively manage.
@param or @return incorrect or missing types is a bug.
Proposed resolution
Add @param and @return or fix types in @param and @return in the following files in core/lib/Drupal/Core/Database/.
- core/lib/Drupal/Core/Database/Database.php
- core/lib/Drupal/Core/Database/Log.php
- core/lib/Drupal/Core/Database/Schema.php
- core/lib/Drupal/Core/Database/Statement.php
- core/lib/Drupal/Core/Database/StatementInterface.php
- core/lib/Drupal/Core/Database/StatementPrefetch.php
This issues covers files immediately in this path, files in subdirectories will receive separate issues. While this issue welcomes improvements to other files in this directory, Connection.php already has a separate issue for this effort in #2342521: Docblock fixes for core/lib/Drupal/Core/Database/Connection.php. Also note, {@inheritdoc} additions aren't necessarily in the scope of this issue.
Remaining tasks
Task | Novice task? | Contributor instructions | Complete? |
---|---|---|---|
Create a patch | Instructions | ||
Review patch to ensure that it fixes the issue, stays within scope, is properly documented, and follows coding standards | Instructions |
User interface changes
No.
API changes
No.
Original report by @bburg
The attached, initial patch comes unaltered from donquixote's work in comment #23 of the parent issue (where it affects the mentioned files).
Comment | File | Size | Author |
---|---|---|---|
#37 | interdiff-35-37.txt | 1.74 KB | snehi |
#37 | add_param_and_return-2343099-37.patch | 17.76 KB | snehi |
#35 | interdiff-2343099-30-35.txt | 1.88 KB | bartvig |
#35 | add_param_and_return-2343099-35.patch | 17.75 KB | bartvig |
#31 | add_param_and_return-2343099-30.patch | 16.54 KB | bendev |
Comments
Comment #1
bburgNote the following suggestions from jhodgdon on these files in the parent issue:
Needs method one liner and param description
Missing @return description
Needs method one liner and param description
Needs method one liner and param description
Comment #3
bburgThis should apply.
Comment #4
smussbach CreditAttribution: smussbach commentedPatch applies and changes make sense to me.
One remark, in StatementPrefetch:setFetchMode() you added @param $a2 and @param $a3 without a type.
Comment #5
bburghmm... this seems like a moving target. StatementInterfance:setFetchMode() is commented out. Otherwise, I'd suggest using {@inheritdoc}.
Nonetheless. here is my latest attempt at this one.
Comment #6
YesCT CreditAttribution: YesCT commentedComment #7
jhodgdonI don't see how we can justify doing this issue during the Beta phase? It is documentation, but it seems like it would be disruptive to other patches. I think we should probably postpone until after 8.0.x is out? See https://www.drupal.org/contribute/core/beta-changes
Comment #8
donquixote CreditAttribution: donquixote commentedI don't think that "may conflict with other patches" counts as "disruptive".
Let us please stop unnecessarily holding this up.
Poorly documented code = unpleasant to review = the perfect hiding place for vulnerabilities.
Comment #9
jhodgdon@alexpott recently killed another attempt to make a big "fix a lot of documentation" as disruptive:
#2329703-84: [meta] Spellchecking Drupal
So, which is it?
Comment #10
donquixote CreditAttribution: donquixote commentedTo clarify, I am not an authority on this stuff :)
I am just quite impatient allergic to see this being held up, and I would say that the linked doc page does clearly not imply that docblock changes are disruptive.
I also don't think that the database system is being changed a lot. Maybe something is going on there currently (dunno), but I think it is one of the more stable (or boring) parts of Drupal core.
Comment #11
YesCT CreditAttribution: YesCT commentedThis is very different than spellchecking.
This is adding missing types or fixing incorrect types.
And, according to the beta handbook, it is allowed.
If it is not allowed, then the handbook page should change.
Comment #12
donquixote CreditAttribution: donquixote commentedYes, this is definitely more important than spellchecking.
(though I don't mind if spellchecking fixes are also committed)
Since this is going slow, I moved over to a single-file issue at #2342521: Docblock fixes for core/lib/Drupal/Core/Database/Connection.php. Maybe we can get this one committed?
I still think we should do more than one file per issue. But for a start, I don't mind a one-file issue.
Comment #13
socketwench CreditAttribution: socketwench commentedGoing to work on this with Eda.
Comment #14
Eda CreditAttribution: Eda commentedNeeds parameter description
Needs parameter description
Needs parameter description
Needs a return value description
Needs parameter description
Needs parameter description
Needs parameter description
Needs parameter description
Needs parameter description
Needs return description
Needs parameter description
Needs parameter description
Comment #15
rakhimandhania CreditAttribution: rakhimandhania commentedRe-rolled the patch and adding the updated patch.
Comment #16
disasm CreditAttribution: disasm at AppliedTrust commentedA few instances of missing punctuation on descriptions of params that should be quick to fix:
missing . at end of statement.
Comment #17
sumitmadan CreditAttribution: sumitmadan commentedRerolled after adding "." at end of statement.
Comment #18
XanoThanks a lot for working on this! Additional documentation is much-needed :)
Such descriptions must always be indented with two extra spaces (so three spaces between the asterisk and the description). This occurs multiple times.
Missing namespace.
@return array
is never acceptable documentation, because gives absolutely no indication of what the array contains.In this case the array items can be of mixed types, so the documentation should read
@return mixed[]
.__clone
cannot return anything.This entire docblock should be changed to
{@inheritdoc}
and the typehint should be added to the method definitions inPlaceholderInterface
.As before,
@return array
is not specific enough.Exactly! :)
Just like
@return array
is not specific enough,@param array
is not specific enough either.I don't know if these parameters can be arrays, but they can definitely (also) be
NULL
, as the default value proves.Comment #19
YesCT CreditAttribution: YesCT commentedI'm cleaning up some Novice tag duplicates. removing the combined "novice documentation" tag so I can delete it, since we should be able to make a search for the novice tag combined with the documentation tag https://www.drupal.org/project/issues/search?projects=&project_issue_fol... or maybe even better: the documentation component combined with the novice tag https://www.drupal.org/project/issues/search/drupal?project_issue_follow...
Comment #20
keopxComment #21
keopxReroll
Comment #24
bendev CreditAttribution: bendev commentedWe are going to reroll patch form #17 (old) because patch in #21 is intented for another issue
Comment #25
bendev CreditAttribution: bendev at WebstanZ commentedreroll of patch #17
Comment #26
bendev CreditAttribution: bendev at WebstanZ commentedremoving trailing spaces . reroll #25
Comment #27
bendev CreditAttribution: bendev at WebstanZ commentedAdditional documentation rerolled from #17 in log.php and database.php
Comment #28
bendev CreditAttribution: bendev at WebstanZ commentedadded improvements in documentation as suggested in #18
Comment #30
bendev CreditAttribution: bendev at WebstanZ commentedthis patchs gathers all modifications from #25,#26,#27,#28
Comment #31
bendev CreditAttribution: bendev at WebstanZ commentedthis patchs gathers all modifications from #25,#26,#27,#28
sorry for double post...
Comment #32
bartvig CreditAttribution: bartvig at Reload commentedI'm working on this issue at DrupalCon Barcelona.
Comment #33
bartvig CreditAttribution: bartvig at Reload commentedThe documentation for parameter $key in function openConnection in Database.php says that it defaults to 'default', because it's called from getConnection where the parameter is defaulted to 'default'.
But the parameter is not defaulted explicitly to 'default':
final public static function getConnection($target, $key = NULL) {
Wouldn't it be better to specify this explicitly to avoid any potential future problem? I.e.:
final public static function getConnection($target = 'default', $key = NULL) {
Comment #35
bartvig CreditAttribution: bartvig at Reload commentedReviewed @param and @return doc for Database.php and added a few.
Full patch with all modifications from #30 (#25,#26,#27,#28) and interdiff attached.
Comment #36
Mile23Thanks for the patch!
Here's the beginning of a review:
If you check the code of that method, you see that it returns either NULL or the return value of Log->get().
So if you look at *that,* you see that Log.php is missing quite a bit of docblock love itself.
Anyway, in this case, I'm pretty sure you'd say:
@return null|Log
...except with the fully-namespaced name of Log.
I'd wager there are other issues like this in the patch, but this is the first one I found.
Comment #37
snehi CreditAttribution: snehi as a volunteer and at Publicis Sapient for Publicis Sapient commentedDone as suggested in #36
Comment #38
jhodgdonSorry, this issue was forgotten, and it is improperly scoped so at this point I am closing it as Won't Fix.
https://www.drupal.org/core/scope