- Issue created by @quietone
- First commit to issue fork.
- ๐ฎ๐ณIndia immaculatexavier
I've updated Step 2: Prepare the new signature in the documentation as part of this change. Specifically, I replaced the broad phpcs:disable Drupal.Commenting with targeted phpcs:ignore annotations for:
Drupal.Commenting.DocComment.TagGroupSpacing
Drupal.Commenting.FunctionComment.ParamNameNoMatch
This ensures that we only suppress the necessary sniffs and maintain all other coding standards. The change is in line with the recommendations discussed in #3531685 Proposed Resolution
https://www.drupal.org/about/core/policies/core-change-policies/how-to-d... โ
- ๐บ๐ธUnited States xjm
I've actually gone further in ๐ Fix PHPStan arguments.count error Active and proposed that we change the standard to move the
@todo
and@see
to the correct part of the docblock. This achieves several things:- It has better readability.
- It follows our existing documentation standards.
- It allows us to remove an entire
phpcs:ignore
from every single parameter and typehint addition of this sort. - It allows for the possibility of multiple parameters being added to a method, and for listing them clearly for the developer.
Here's an example from that issue:
/** * Gets sorted plugin definitions. * * @param array[]|null $definitions * (optional) The plugin definitions to sort. If omitted, all plugin * definitions are used. * phpcs:ignore Drupal.Commenting.FunctionComment.ParamNameNoMatch * @param string $label_key * (optional) The key to be used as a label for sorting. * * @return array[] * An array of plugin definitions, sorted by category and label. * * @see https://www.drupal.org/project/drupal/issues/3354672 * * @todo Uncomment the new $label_key method parameter before drupal:12.0.0. */ public function getSortedDefinitions(?array $definitions = NULL /*, string $label_key = 'label' */);
- ๐บ๐ธUnited States xjm
The current MR appears empty, so no credit is granted for @immaculatexavier.
- ๐บ๐ธUnited States xjm
A sample for the documentation page might be something like:
/** * Returns sample data. * * phpcs:ignore Drupal.Commenting.FunctionComment.ParamNameNoMatch * @param string $added_parameter * The new parameter being added. * * @return array[] * The sample data. * * @see https://www.drupal.org/project/drupal/issues/3354672 * * @todo Uncomment the new $added_parameter method parameter before drupal:12.0.0. */ public function getSampleData(/* string $added_parameter = '' */);
- ๐ณ๐ฟNew Zealand quietone
The proposal in #8 looks better. I have updated the 'how to' doc with that example as well as the issue summary. I think everything is done here.
Setting to RTBC for a check that the doc updates are correct.
- ๐บ๐ธUnited States dww
Super nit for the sample code, not related to whatโs being fixedโฆ
@return array[]
Kinda weird. Probably we want either just:
@return array
Or perhaps something like:
@return string[]
or whatever. Not that we donโt have functions in Drupal that return nested arrays. ๐ but weโre trying to move away from ArrayPI.
- ๐ณ๐ฟNew Zealand quietone
@dww, thanks, I did miss that last night.
I changed it to
@return string[]
.