Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
There are many coding standards problems in core/lib/Drupal/Core/Database/Schema.php
Proposed resolution
Fix the code according to the coding standards
Remaining tasks
Fix the followings errors:
----------------------------------------------------------------------
FOUND 6 ERRORS AFFECTING 5 LINES
----------------------------------------------------------------------
468 | ERROR | Parameter tags must be grouped together in a doc
| | comment
468 | ERROR | Tags must be grouped together in a doc comment
482 | ERROR | Tags must be grouped together in a doc comment
498 | ERROR | Tags must be grouped together in a doc comment
551 | ERROR | Tags must be grouped together in a doc comment
556 | ERROR | Tags must be grouped together in a doc comment
User interface changes
None.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#7 | interdiff.txt | 4.78 KB | empesan |
#7 | coding_standards_problems_in_schema-2863877-7.patch | 16.92 KB | empesan |
#2 | coding_standards_problems_in_schema-2863877-2.patch | 18.19 KB | adriancid |
|
Comments
Comment #2
adriancidComment #4
daffie CreditAttribution: daffie commentedIf you change the methods parameter definition, you must do the same to all method from the classes that inherit from this class. So the MySQL, PostgreSQL and SQLite versions of Schema. If you do that then you can also add inherit docblocks where needed. ;-)
Comment #5
daffie CreditAttribution: daffie commentedForget about the inherit docblock. You have created #2863750: Add inheritdoc function doc comment to schema classes for that.
Comment #6
daffie CreditAttribution: daffie commentedI think that it is better to remove the parameter type hints, they are a BC-break. We can do them in Drupal 9.0. Feel free to make a new issue for that. You can have the parameter type hints in the docblocks. Conclusion: remove the parameter type hints in the methods and not the docblocks and the patch will be RTBC.
Comment #7
empesan CreditAttribution: empesan commentedI've added a patch based on @adriancid patch adding the changes suggested by @daffie
Comment #8
cilefen CreditAttribution: cilefen commentedThank you for your work on cleaning up Drupal core's code style!
In order to fix core coding standards in a maintainable way, all our coding standards issues should be done on a per-rule basis across all of core, rather than fixing standards in individual modules or files. We should also separate fixes where we need to write new documentation from fixes where we need to correct existing standards. This all should be done as part of #2571965: [meta] Fix PHP coding standards in core. A good place to start is the child issues of #2572645: [Meta] Fix 'Drupal.Commenting.FunctionComment' coding standard.
For background information on why we usually will not commit coding standards fixes that aren't scoped in that way, see the core issue scope guidelines, especially the note about coding standards cleanups. That document also includes numerous suggestions for scoping issues including documentation coding standards cleanups.
Contributing to the overall plan above will help ensure that your fixes for core's coding standards remain in core the long term.
Comment #9
hgunicamp CreditAttribution: hgunicamp at CI&T commentedAfter applying the 'coding_standards_problems_in_schema-2863877-7.patch' patch and running phpcs again, I still found some mistakes.
phpcs --standard=Drupal core/lib/Drupal/Core/Database/Schema.php
FILE: ...ogestag/temp/drupal/core/lib/Drupal/Core/Database/Schema.php
----------------------------------------------------------------------
FOUND 13 ERRORS AFFECTING 11 LINES
----------------------------------------------------------------------
53 | ERROR | Type hint "\Drupal\Core\Database\Connection" missing
| | for $connection
406 | ERROR | Type hint "array" missing for $fields
435 | ERROR | Type hint "array" missing for $fields
468 | ERROR | Parameter tags must be grouped together in a doc
| | comment
468 | ERROR | Tags must be grouped together in a doc comment
482 | ERROR | Tags must be grouped together in a doc comment
498 | ERROR | Tags must be grouped together in a doc comment
513 | ERROR | Type hint "array" missing for $fields
551 | ERROR | Tags must be grouped together in a doc comment
556 | ERROR | Tags must be grouped together in a doc comment
596 | ERROR | Type hint "array" missing for $spec
596 | ERROR | Type hint "array" missing for $keys_new
631 | ERROR | Type hint "array" missing for $fields
----------------------------------------------------------------------
Time: 170ms; Memory: 11.5Mb
Comment #10
hgunicamp CreditAttribution: hgunicamp at CI&T commentedSorry. I tested the patch before reading cilefen comment.
Comment #16
quietone CreditAttribution: quietone as a volunteer commentedThis work is now being done by sniff. The work here is now in #3207949: Fix Drupal.Commenting.FunctionComment.MissingParamType so closing this as a duplicate. I've identified credit to add over there, let me know if I got it wrong.