Fix PHP doc comments for functions

Created on 13 January 2020, about 5 years ago
Updated 22 December 2024, 4 months ago

The PHP doc comment syntax is incorrect, using @param variable Some Text and @return Some Text, when it should use @param type $variable Some Text and @return type Some Text (probably with new lines before "Some Text".

A specific example:

/**
 * ...
 *
 * @param custom_tabs. An array representing custom tab contents, which will be
 *  appended to the Quicktabs instance from the database, or if no existing instance
 *  is being used, the custom tabs will be the entire contents. An example custom_tabs
 *  array would be array(array('title' => 'custom', 'contents' => array('#markup' =>
 *  t('Some markup'), 'weight' => 5));
 *
 * @return A render array that can be used as block content in hook_block_view
 *  (see quicktabs_block_view()), but can also just be added to the page array
 *  during hook_page_alter, or output anywhere else where it's sure to get
 *  passed through drupal_render().
 */
function quicktabs_build_quicktabs($name, $settings = array(), $custom_tabs = array()) {

Should be:

/**
 * ...
 *
 * @param array $custom_tabs
 *   An array representing custom tab contents, which will be
 *  appended to the Quicktabs instance from the database, or if no existing instance
 *  is being used, the custom tabs will be the entire contents. An example custom_tabs
 *  array would be array(array('title' => 'custom', 'contents' => array('#markup' =>
 *  t('Some markup'), 'weight' => 5));
 *
 * @return array 
 *   A render array that can be used as block content in hook_block_view
 *  (see quicktabs_block_view()), but can also just be added to the page array
 *  during hook_page_alter, or output anywhere else where it's sure to get
 *  passed through drupal_render().
 */
function quicktabs_build_quicktabs($name, array $settings = array(), array $custom_tabs = array()) {

With the way it currently is, for the above example phpcs gives the following type error: Expected type 'array'. Found 'void'.

Other comments make it past phpcs fine, but the comments are highlighted weird because the variables are missing the dollar signs (so they are highlighted as if they are types).

📌 Task
Status

Postponed: needs info

Version

3.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States smustgrave

    With D7 EOL approaching in a month I'm starting to triage the D7 side of quicktabs queue.

    This something we want to consider? Seems like a big lift so leaning on no

  • 🇨🇦Canada joelpittet Vancouver

    Yes, we won’t focus on this as it would take a long time to review and wouldn’t fix any issues it’s more likely to cause rerolls on issues that do.

    I do however appreciate the effort it takes to do these kinds of clean up as it’s no small feat after the initial phpcbf run, thank you for trying to improve the quality of the code base!

Production build 0.71.5 2024