Remove rule Drupal.Commenting.FunctionComment.InvalidReturnNotVoid

Created on 13 March 2024, about 1 year ago
Updated 27 April 2024, 12 months ago

Problem/Motivation

Drupal.Commenting.FunctionComment.InvalidReturnNotVoid is performing a task that PHPStan should perform on level 3. Additionally the PHPCS rule is not smart enough and gets confused by code like:

/**
 * Some array returning function.
 *
 * @return array
 *   Some array.
 */
function returnSomeArray(): array {
  do_something_with_a_callback(function () {
     if ($some_condition) {
       // Early return.
       return;
     }
     
     // Do work.
   });
   return [];
}

it'll throw an error on the early return, not understanding that it's not part of the outer function.

Steps to reproduce

Proposed resolution

Remove the rule, return type checking is not a coding style rule but a job for PHPStan.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

8.3

Component

Coder Sniffer

Created by

🇳🇱Netherlands kingdutch

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

Comments & Activities

Production build 0.71.5 2024