This is a sub-issue of #1800046: [META] Add missing type hinting to core docblocks, fix Drupal.Commenting.FunctionComment.Missing* focused on correctly adding @param and @return type hinting to the Dblog module.

Documentation patches that include type hinting are time consuming to both review and commit because one must dig into the actual code to confirm that the type hints are both correct and complete. Hence, please be patient and try to limit type hint patches to covering only a limited number of docblocks (20-25 as a guess).

How To Review This Issue

  1. Attempt to apply the patch to see if it needs a reroll.
  2. Use the phpcs one-liner to evaluate whether all the relevant standards errors have been resolved: https://gist.github.com/paul-m/227822ac7723b0e90647
  3. Look at each change and determine whether the type hint is correct.

Related sprint issues:

Sprint Topic Sub Issue
#1518116: [meta] Make Core pass Coder Review #1533228: Make dblog module pass Coder Review
#1310084: [meta] API documentation cleanup sprint #1326600: Clean up API docs for dblog module
#500866: [META] remove t() from assert message #1797242: Remove t() from assertion messages in dblog module tests

Comments

lars toomre’s picture

Issue summary: View changes

Updated issue summary.

mile23’s picture

Issue summary: View changes
mile23’s picture

Katiemouse’s picture

Status: Active » Needs review
Issue tags: +CatalystAcademy
StatusFileSize
new1.29 KB

Hi I am in high school and very new to drupal. I have attempted a patch and have attached it :)

jhodgdon’s picture

Status: Needs review » Needs work

Thanks for the patch and welcome to Drupal!

This looks pretty good. I'm not sure if it fixes all the problems in dblog, but someone else can check it.

One problem: In text, "id" is a Freudian term (ego, superego, id), so it shouldn't be used in documentation. "ID" is what you want to use in Drupal docs (means "identifier" or "identification").

+   * @param int $id
+   *   The id of the watchdog log entry.
+   *

So even though the parameter name is $id (which is right), the text should say "The ID of the ...".

mile23’s picture

Actually it *does* get all the type hinting errors, according to phpcs. :-)

So all it needs is the change from #4, and it's RTBC.

Katiemouse’s picture

Status: Needs work » Needs review
StatusFileSize
new1.29 KB
new631 bytes

Hi all, thanks for the help and advice. I think I've managed to fix that last bit :)

Katiemouse’s picture

Hi all, thanks for the help and advice. I think I've managed to fix that last bit :)

mile23’s picture

Status: Needs review » Needs work

Oh I spoke too soon... There's this, in DbLogController:

  /**
   * Formats a database log message.
   *
   * @param stdClass $row
   *   The record from the watchdog table. The object properties are: wid, uid,
   *   severity, type, timestamp, message, variables, link, name.
   *
   * @return string|false
   *   The formatted log message or FALSE if the message or variables properties
   *   are not set.
   */
  public function formatMessage($row) {

Should be object instead of stdclass, but really should be whatever interface of object is actually expected.

I think just substituting object will be good, because it documents the behavior of the method, but if you find some documentation for a more specific type by all means add that.

Thanks.

Katiemouse’s picture

Status: Needs work » Needs review
StatusFileSize
new136.44 KB
new590 bytes

Hi, I changed that last part to object as you suggested :)

mile23’s picture

Status: Needs review » Reviewed & tested by the community

That catches the last one. Thanks for sticking with it!

jhodgdon’s picture

Status: Reviewed & tested by the community » Needs work

The patch has unrelated stuff in it.

Katiemouse’s picture

Hi, sorry what was the unrelated part of the patch?

jhodgdon’s picture

Click on the file link above. https://www.drupal.org/files/issues/1811242-9-stdclass-object-corrected....

It has a bunch of stuff that is completely unrelated to adding DBLog module doc blocks in it. Looks like maybe it is the patch for a different issue?

mrjmd’s picture

Status: Needs work » Needs review
StatusFileSize
new1.86 KB

Here's a roll of the fix from #9 without the unrelated stuff in it.

mile23’s picture

Issue summary: View changes
jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

The latest patch looks fine. I haven't checked to see if it contains all needed param/return fixes in dblog.module, but it is certainly fine to commit as it is. Thanks!

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 1abfba4 and pushed to 8.0.x. Thanks!

  • alexpott committed 1abfba4 on 8.0.x
    Issue #1811242 by Katiemouse, mrjmd: Add missing type hinting to Dblog...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.