Convert use of array() syntax in sentences

Created on 12 June 2024, 6 months ago

Problem/Motivation

Followup from πŸ“Œ Fix Drupal.Commenting.DocCommentLongArraySyntax coding standard Needs work .

This is to fix usages of array() in comments that are in sentences and should not be using an @code/@endcode block. These are not discovered by the sniff. The sniff only detects array() in code and in side @code/@endcode blocks.

Instances can be found by applying the diff from πŸ“Œ Fix Drupal.Commenting.DocCommentLongArraySyntax coding standard Needs work and then using the following grep.

grep -r "\barray(" * | grep -F \* | grep -v "vendor" | grep -v "node_modules"

This will find more instances than are being fixed here. The ones not done here are in comments that should be converted to using an @code/@endcode block.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ“Œ Task
Status

Active

Version

11.0 πŸ”₯

Component
OtherΒ  β†’

Last updated about 1 hour ago

Created by

πŸ‡³πŸ‡ΏNew Zealand quietone

Live updates comments and jobs are added and updated live.
  • Coding standards

    It involves compliance with, or the content of coding standards. Requires broad community agreement.

Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @quietone
  • Merge request !8390Convert use of array() syntax in sentences β†’ (Open) created by quietone
  • Status changed to Needs review 6 months ago
  • πŸ‡³πŸ‡ΏNew Zealand quietone
  • Pipeline finished with Success
    6 months ago
    Total: 672s
    #197225
  • Status changed to RTBC 6 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    List is getting easier to review :)

    With the MR still applied from πŸ“Œ Fix Drupal.Commenting.DocCommentLongArraySyntax coding standard Needs work

    Ran grep -r "\barray(" * | grep -F \* | grep -v "vendor" | grep -v "node_modules"

    and got

    lib/Drupal/Core/Database/Database.php:   * array(
    lib/Drupal/Core/Database/Log.php:   * array(
    lib/Drupal/Core/Database/Log.php:   *   $logging_key = array(
    lib/Drupal/Core/Database/Log.php:   *     array('query' => '', 'args' => array(), 'caller' => '', 'target' => '', 'time' => 0, 'start' => 0),
    lib/Drupal/Core/Database/Log.php:   *     array('query' => '', 'args' => array(), 'caller' => '', 'target' => '', 'time' => 0, 'start' => 0),
    lib/Drupal/Core/Database/Query/Select.php:   * array(
    lib/Drupal/Core/Cache/UseCacheBackendTrait.php:   *   tags. For example, ['node' => array(123), 'user' => array(92)].
    lib/Drupal/Core/Datetime/DrupalDateTime.php: * DrupalDateTime::createFromArray( array('year' => 2010, 'month' => 9, 'day' => 28) )
    lib/Drupal/Component/Gettext/PoHeader.php:   *   array(
    lib/Drupal/Component/Gettext/PoHeader.php:   *   array(
    lib/Drupal/Component/Gettext/PoHeader.php:   *   array(
    modules/views_ui/admin.inc: *   array('dynamic_content', 'section') for this parameter.
    modules/system/tests/modules/common_test/common_test.module: * \Drupal::moduleHandler()->alter(array(TYPE1, TYPE2), ...) allows
    scripts/dump-database-d7.sh:  $result = db_query('SELECT * FROM {'. $table .'}', array(), array('fetch' => PDO::FETCH_ASSOC));
    

    All these appear to be blocks vs inline so assuming the last one will clean these up.

  • Status changed to Needs work 6 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Actually after applying the MR from πŸ“Œ Convert code blocks in comments using array() syntax to @code/@endcode Needs review and ran the grep again think this one missed a few

    lib/Drupal/Core/Cache/UseCacheBackendTrait.php:
    modules/views_ui/admin.inc:
    modules/system/tests/modules/common_test/common_test.module: (Could maybe go in the other one)

  • πŸ‡³πŸ‡ΏNew Zealand quietone

    @smustgrave, no worries. I was using the search in PHPStorm and was filtering on .php files. Though, that doesn't explain how I missed UseCacheBackendTrait.php.

    #5. Those were all in sentences so I added them here.

  • Status changed to Needs review 6 months ago
  • πŸ‡³πŸ‡ΏNew Zealand quietone
  • Status changed to RTBC 6 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Additional items appear to be addressed now. So believe with the combo of the 3 these are complete.

  • Status changed to Needs work 6 months ago
  • πŸ‡ΊπŸ‡ΈUnited States xjm

    Similarly to πŸ“Œ Convert code blocks in comments using array() syntax to @code/@endcode Needs review , we're missing an equivalent PHPCS rule to the one from πŸ“Œ Fix Drupal.Commenting.DocCommentLongArraySyntax coding standard Needs work for these. We need a followup for that in the appropriate queue.

    I'd be fine to treat the rule as either blocker or followup since the scope is really small, but we do need the rule.

  • Status changed to Needs review 2 months ago
  • πŸ‡³πŸ‡ΏNew Zealand quietone

    I prefer treating the rule as a followup. It is unlikely that more instances will creep in.

    πŸ“Œ Add a rule for detect long array syntax in sentences. Active

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave
  • πŸ‡«πŸ‡·France nod_ Lille

    There seem to be a couple missing (outside of @code/@endcode blocks):

                core\lib\Drupal\Core\Extension  (1 usage found)
                    ModuleHandler.php  (1 usage found)
                        405 // specific variants of it, as in the case of array('form', 'form_FORM_ID').
                core\lib\Drupal\Core\Form
                    FormState.php 
                        1288 // self::getValue(array('foo', 'bar')), which is the level where we
                core\lib\Drupal\Core\Theme  (1 usage found)
                    ThemeManager.php  (1 usage found)
                        427 // specific variants of it, as in the case of array('form', 'form_FORM_ID').
                core\modules\file\tests\src\Functional  (1 usage found)
                    FileFieldWidgetTest.php  (1 usage found)
                        163 // iteration, so array(1, 1, 0) means:
                core\modules\file\tests\src\FunctionalJavascript  (1 usage found)
                    FileFieldWidgetTest.php  (1 usage found)
                        96 // iteration, so array(1, 1, 0) means:
                core\modules\locale  (1 usage found)
                    locale.bulk.inc  (1 usage found)
                        208 // Update the seek and the number of items in the $options array().
                core\modules\node\src\Plugin\Search  (1 usage found)
                    NodeSearch.php  (1 usage found)
                        277 // array('type:page', 'term:27', 'term:13', 'langcode:en');
                core\modules\sqlite\src\Driver\Database\sqlite  (1 usage found)
                    Schema.php  (1 usage found)
                        659 // The key definition can be an array($field, $length).
                core\modules\system\tests\modules\common_test  (1 usage found)
                    common_test.module  (1 usage found)
                        96 // \Drupal::moduleHandler()->alter(array('drupal_alter', 'drupal_alter_foo'), ...),
                core\modules\taxonomy\src\Plugin\views\filter  (1 usage found)
                    TaxonomyIndexTid.php  (1 usage found)
                        252 // Due to #1464174 there is a chance that array('') was saved in the admin ui.
                core\modules\views_ui\tests\src\Functional  (1 usage found)
                core\tests\Drupal\KernelTests\Core\Entity  (1 usage found)
                    EntityFieldTest.php  (1 usage found)
                        252 // Test emptying a field by assigning an empty value. NULL and array()
                core\tests\Drupal\Tests\Component\ProxyBuilder  (3 usages found)
                    ProxyBuilderTest.php  (3 usages found)
                        127 // @todo Solve the silly linebreak for array()
                        152 // @todo Solve the silly linebreak for array()
                        177 // @todo Solve the silly linebreak for array()
                core\tests\Drupal\Tests\Component\Utility  (1 usage found)
                    ColorTest.php  (1 usage found)
                        166 // Input using indexed RGB array (e.g.: array(10, 10, 10)).
                core\tests\Drupal\Tests\Core\Batch  (1 usage found)
                    PercentagesTest.php  (1 usage found)
                        39 // array(total, current, expected).
                core\tests\Drupal\Tests\Core\ProxyBuilder  (1 usage found)
                    ProxyBuilderTest.php  (1 usage found)
                        42 // @todo Solve the silly linebreak for array()
    

    not sure how much is in scope but they don't get picked up by the cli

  • πŸ‡³πŸ‡ΏNew Zealand quietone

    Thanks nod. I did miss quite a few, sorry about that.

  • Pipeline finished with Failed
    about 1 month ago
    Total: 397s
    #315869
  • Pipeline finished with Success
    29 days ago
    Total: 1201s
    #329148
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    All I did was a simple rebase just FYI

    Tests appear to be green again, so previously were just random failures.

    Feedback appears to be addressed.

  • The Needs Review Queue Bot β†’ tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide β†’ to find step-by-step guides for working with issues.

  • πŸ‡³πŸ‡ΏNew Zealand quietone

    Rebase with a conflict in core/modules/views_ui/admin.inc because of all the hook changes.

  • Status changed to RTBC 8 days ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Rebase seems good still.

Production build 0.71.5 2024