Problem/Motivation
Several Twig template docblocks in core use the @see annotation without a space before the referenced class.
@see\Drupal\Core\Form\FormPreprocess::preprocessInput()
According to standard PHPDoc formatting (followed by Drupal coding standards), there should be a space between the annotation and its value.
@see \Drupal\Core\Form\FormPreprocess::preprocessInput()
While this does not affect runtime behavior, without the space @see tags are not correctly parsed by the API module.
Steps to reproduce
Run the following command from the Drupal root:
grep -rni '@see\\Drupal' core/modules
This will return multiple occurrences in Twig template files, for example:
core/modules/system/templates/input.html.twig:10: * @see\Drupal\Core\Form\FormPreprocess::preprocessInput()
core/modules/system/templates/form-element-label.html.twig:12: * @see\Drupal\Core\Form\FormPreprocess::preprocessFormElementLabel()
core/modules/system/templates/vertical-tabs.html.twig:10: * @see\Drupal\Core\Form\FormPreprocess::preprocessVerticalTabs()
core/modules/system/templates/fieldset.html.twig:26: * @see\Drupal\Core\Form\FormPreprocess::preprocessFieldset()
core/modules/system/templates/form.html.twig:10: * @see\Drupal\Core\Form\FormPreprocess::preprocessForm()
core/modules/system/templates/checkboxes.html.twig:10: * @see\Drupal\Core\Form\FormPreprocess::preprocessCheckboxes()
core/modules/system/templates/textarea.html.twig:13: * @see\Drupal\Core\Form\FormPreprocess::preprocessTextarea()
core/modules/system/templates/details.html.twig:15: * @see\Drupal\Core\Form\FormPreprocess::preprocessDetails()
core/modules/system/templates/select.html.twig:10: * @see\Drupal\Core\Form\FormPreprocess::preprocessSelect()
core/modules/system/templates/form-element.html.twig:44: * @see\Drupal\Core\Form\FormPreprocess::preprocessFormElement()
core/modules/system/templates/radios.html.twig:10: * @see\Drupal\Core\Form\FormPreprocess::preprocessRadios()
core/modules/field_ui/templates/form-element--new-storage-type.html.twig:16: * @see\Drupal\Core\Form\FormPreprocess::preprocessFormElement()
core/modules/views/tests/themes/views_test_theme/templates/input--submit.html.twig:10: * @see\Drupal\Core\Form\FormPreprocess::preprocessInput()
grep -rni '@see\\Drupal' core/themes
core/themes/stable9/templates/form/input.html.twig:10: * @see\Drupal\Core\Form\FormPreprocess::preprocessInput()
core/themes/stable9/templates/form/form-element-label.html.twig:12: * @see\Drupal\Core\Form\FormPreprocess::preprocessFormElementLabel()
core/themes/stable9/templates/form/fieldset.html.twig:26: * @see\Drupal\Core\Form\FormPreprocess::preprocessFieldset()
core/themes/stable9/templates/form/form.html.twig:10: * @see\Drupal\Core\Form\FormPreprocess::preprocessForm()
core/themes/stable9/templates/form/checkboxes.html.twig:10: * @see\Drupal\Core\Form\FormPreprocess::preprocessCheckboxes()
core/themes/stable9/templates/form/textarea.html.twig:13: * @see\Drupal\Core\Form\FormPreprocess::preprocessTextarea()
core/themes/stable9/templates/form/details.html.twig:15: * @see\Drupal\Core\Form\FormPreprocess::preprocessDetails()
core/themes/stable9/templates/form/select.html.twig:10: * @see\Drupal\Core\Form\FormPreprocess::preprocessSelect()
core/themes/stable9/templates/form/form-element.html.twig:44: * @see\Drupal\Core\Form\FormPreprocess::preprocessFormElement()
core/themes/stable9/templates/form/radios.html.twig:10: * @see\Drupal\Core\Form\FormPreprocess::preprocessRadios()
core/themes/stable9/templates/admin/form-element--new-storage-type.html.twig:16: * @see\Drupal\Core\Form\FormPreprocess::preprocessFormElement()
core/themes/stable9/templates/navigation/vertical-tabs.html.twig:10: * @see\Drupal\Core\Form\FormPreprocess::preprocessVerticalTabs()
core/themes/claro/templates/form/input.html.twig:10: * @see\Drupal\Core\Form\FormPreprocess::preprocessInput()
core/themes/claro/templates/form/checkboxes.html.twig:10: * @see\Drupal\Core\Form\FormPreprocess::preprocessCheckboxes()
core/themes/claro/templates/form/textarea.html.twig:13: * @see\Drupal\Core\Form\FormPreprocess::preprocessTextarea()
core/themes/claro/templates/form/radios.html.twig:10: * @see\Drupal\Core\Form\FormPreprocess::preprocessRadios()
core/themes/claro/templates/form-element-label.html.twig:12: * @see\Drupal\Core\Form\FormPreprocess::preprocessFormElementLabel()
core/themes/claro/templates/datetime-wrapper.html.twig:6: * @see\Drupal\Core\Form\FormPreprocess::preprocessFormElement()
core/themes/claro/templates/fieldset.html.twig:25: * @see\Drupal\Core\Form\FormPreprocess::preprocessFieldset()
core/themes/claro/templates/navigation/details--vertical-tabs.html.twig:19: * @see\Drupal\Core\Form\FormPreprocess::preprocessDetails()
core/themes/claro/templates/media-library/fieldset--media-library-widget.html.twig:9: * @see\Drupal\Core\Form\FormPreprocess::preprocessFieldset()
core/themes/claro/templates/media-library/details--media-library-add-form-selected-media.html.twig:8: * @see\Drupal\Core\Form\FormPreprocess::preprocessDetails()
core/themes/claro/templates/details.html.twig:18: * @see\Drupal\Core\Form\FormPreprocess::preprocessDetails()
core/themes/claro/templates/form-element.html.twig:6: * @see\Drupal\Core\Form\FormPreprocess::preprocessFormElement()
core/themes/default_admin/templates/form/input.html.twig:10: * @see\Drupal\Core\Form\FormPreprocess::preprocessInput()
core/themes/default_admin/templates/form/form-element-label.html.twig:12: * @see\Drupal\Core\Form\FormPreprocess::preprocessFormElementLabel()
core/themes/default_admin/templates/form/textarea.html.twig:13: * @see\Drupal\Core\Form\FormPreprocess::preprocessTextarea()
core/themes/default_admin/templates/form/radios.html.twig:10: * @see\Drupal\Core\Form\FormPreprocess::preprocessRadios()
core/themes/default_admin/templates/navigation/details--vertical-tabs.html.twig:19: * @see\Drupal\Core\Form\FormPreprocess::preprocessDetails()
core/themes/default_admin/templates/media-library/fieldset--media-library-widget.html.twig:9: * @see\Drupal\Core\Form\FormPreprocess::preprocessFieldset()
core/themes/default_admin/templates/media-library/details--media-library-add-form-selected-media.html.twig:8: * @see\Drupal\Core\Form\FormPreprocess::preprocessDetails()
core/themes/starterkit_theme/templates/form/input.html.twig:10: * @see\Drupal\Core\Form\FormPreprocess::preprocessInput()
core/themes/starterkit_theme/templates/form/form-element-label.html.twig:12: * @see\Drupal\Core\Form\FormPreprocess::preprocessFormElementLabel()
core/themes/starterkit_theme/templates/form/fieldset.html.twig:26: * @see\Drupal\Core\Form\FormPreprocess::preprocessFieldset()
core/themes/starterkit_theme/templates/form/form.html.twig:10: * @see\Drupal\Core\Form\FormPreprocess::preprocessForm()
core/themes/starterkit_theme/templates/form/checkboxes.html.twig:10: * @see\Drupal\Core\Form\FormPreprocess::preprocessCheckboxes()
core/themes/starterkit_theme/templates/form/textarea.html.twig:13: * @see\Drupal\Core\Form\FormPreprocess::preprocessTextarea()
core/themes/starterkit_theme/templates/form/details.html.twig:15: * @see\Drupal\Core\Form\FormPreprocess::preprocessDetails()
core/themes/starterkit_theme/templates/form/select.html.twig:10: * @see\Drupal\Core\Form\FormPreprocess::preprocessSelect()
core/themes/starterkit_theme/templates/form/form-element.html.twig:44: * @see\Drupal\Core\Form\FormPreprocess::preprocessFormElement()
core/themes/starterkit_theme/templates/form/radios.html.twig:10: * @see\Drupal\Core\Form\FormPreprocess::preprocessRadios()
core/themes/starterkit_theme/templates/navigation/vertical-tabs.html.twig:10: * @see\Drupal\Core\Form\FormPreprocess::preprocessVerticalTabs()
core/themes/olivero/templates/form/fieldset.html.twig:28: * @see\Drupal\Core\Form\FormPreprocess::preprocessFieldset()
core/themes/olivero/templates/form/input--submit--header-search.html.twig:10: * @see\Drupal\Core\Form\FormPreprocess::preprocessInput()
core/themes/olivero/templates/form/details.html.twig:15: * @see\Drupal\Core\Form\FormPreprocess::preprocessDetails()
core/themes/olivero/templates/datetime-wrapper.html.twig:6: * @see\Drupal\Core\Form\FormPreprocess::preprocessFormElement()
core/themes/olivero/templates/form--search-block-form.html.twig:10: * @see\Drupal\Core\Form\FormPreprocess::preprocessForm()
Proposed resolution
Update all occurrences of @see\Drupal to include a space after @see:
- * @see\Drupal\Core\Form\FormPreprocess::preprocessInput()
+ * @see \Drupal\Core\Form\FormPreprocess::preprocessInput()
This aligns the docblocks with PHPDoc standards and Drupal coding conventions.
Remaining tasks
- Identify all occurrences in core Twig templates
- Add a space after
@see, if there are no spaces after that tag
Issue fork drupal-3578091
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
avpadernoComment #5
avpadernoComment #6
avpaderno(I should remember not to use any @ in the branch name.)
Comment #7
avpadernoI apologize: I found more instances to fix. I will update the issue summary and the MR.
Comment #8
sivaji_ganesh_jojodae commentedComment #9
sivaji_ganesh_jojodae commentedFixed docblocks by adding a space after @see across Twig templates to comply with coding standards.
Any suggestions on updating phpcs rules to prevent this from getting added in the future?
Comment #10
smustgrave commentedI believe this issue should be postponed until we get a coder rule in place or more will creep in.
I don't even see one attach so we probably need a follow up to get a ticket started over there.
Comment #11
smustgrave commentedWent ahead and add a stub ticket.
Comment #12
smustgrave commentedNow if a rule exists then it should turned on with the fix here. So we can see all instances are captured.
Comment #13
quietone commentedChanges such as this are better made after core implements linting for twig files so that we don't get regressions. And we do have an issue to add a dependency for linting twig files. That needs an issue summary update so it can be reviewed, #3284817: Adopt vincentlanglet/twig-cs-fixer for Twig coding standards. It would help if someone here would do that so we can start linting twig files. Thanks.
I wouldn't be surprised if these are copy/paste errors and I think the chance of regressions are small. So, I am returning the status to needs review.
Comment #14
dcam commentedThere are six additional templates with this problem in the Umami profile's theme.
Comment #15
sivaji_ganesh_jojodae commentedI've updated the MR to include the files in #14.
Comment #16
dcam commentedPer #13 we're moving this forward despite not having a linting rule for it yet.
There's nothing to say about the MR. It's just adding a bunch of spaces.
I didn't find any other instances of
@seeannotations that need to be fixed. Personally, I used a slightly different command to check:grep -rni "@see\S" core.Looks good to me.
Comment #17
avpadernoComment #21
godotislateCommitted and pushed e3a5fd9 to main and 12b80f3 to 11.x. Thanks!