Skip to content

Commit 0dbc395

Browse files
authored
refactor(DisallowLongArraySyntax): Use upstream sniff directly (#3554286)
1 parent 7c268d0 commit 0dbc395

25 files changed

+260
-424
lines changed

coder_sniffer/Drupal/Sniffs/Arrays/DisallowLongArraySyntaxSniff.php

Lines changed: 0 additions & 49 deletions
This file was deleted.

coder_sniffer/Drupal/ruleset.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
</rule>
4646

4747
<!-- Generic sniffs -->
48+
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
4849
<rule ref="Generic.CodeAnalysis.EmptyPHPStatement"/>
4950
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
5051
<rule ref="Generic.Files.ByteOrderMark"/>

tests/Drupal/Arrays/ArrayUnitTest.inc.fixed

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -24,41 +24,41 @@ $array = [
2424
],
2525
];
2626

27-
$array = array(
27+
$array = [
2828
'data' => 'my-data',
2929
'animal' => 'squirrel',
30-
'inline' => array(),
31-
'inline3' => array('one', 'two', 'three'),
32-
'inline_long_ok' => array('one', 'two', 'three', 'four', 'five'),
33-
'inline_long_nok' => array('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve'),
34-
'nested' => array(),
35-
'nested2' => array(
30+
'inline' => [],
31+
'inline3' => ['one', 'two', 'three'],
32+
'inline_long_ok' => ['one', 'two', 'three', 'four', 'five'],
33+
'inline_long_nok' => ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve'],
34+
'nested' => [],
35+
'nested2' => [
3636
'a',
37-
),
38-
'nested3' => array(
37+
],
38+
'nested3' => [
3939
'a' => 'a',
40-
'b' => array(
40+
'b' => [
4141
'c',
42-
),
43-
),
44-
);
42+
],
43+
],
44+
];
4545

46-
$derivatives["entity:$entity_type_id"] = array(
47-
'label' => t('Create @entity_type path alias', array('@entity_type' => $entity_type->getLowercaseLabel())),
46+
$derivatives["entity:$entity_type_id"] = [
47+
'label' => t('Create @entity_type path alias', ['@entity_type' => $entity_type->getLowercaseLabel()]),
4848
'category' => t('Path'),
4949
'entity_type_id' => $entity_type_id,
50-
'context' => array(
50+
'context' => [
5151
'entity' => ContextDefinition::create("entity:$entity_type_id")
5252
->setLabel($entity_type->getLabel())
5353
->setRequired(TRUE)
54-
->setDescription(t('The @entity_type for which to create a path alias.', array('@entity_type' => $entity_type->getLowercaseLabel()))),
54+
->setDescription(t('The @entity_type for which to create a path alias.', ['@entity_type' => $entity_type->getLowercaseLabel()])),
5555
'alias' => ContextDefinition::create('string')
5656
->setLabel(t('Path alias'))
5757
->setRequired(TRUE)
5858
->setDescription(t("Specify an alternative path by which the content can be accessed. For example, 'about' for an about page. Use a relative path and do not add a trailing slash.")),
59-
),
60-
'provides' => array(),
61-
) + $base_plugin_definition;
59+
],
60+
'provides' => [],
61+
] + $base_plugin_definition;
6262

6363
$derivatives["entity:$entity_type_id"] = [
6464
'label' => t('Create @entity_type path alias', ['@entity_type' => $entity_type->getLowercaseLabel()]),
@@ -77,31 +77,31 @@ $derivatives["entity:$entity_type_id"] = [
7777
'provides' => [],
7878
] + $base_plugin_definition;
7979

80-
$a = array('1', '2', array(
80+
$a = ['1', '2', [
8181
'3',
82-
),
83-
);
82+
],
83+
];
8484

8585
$a = ['1', '2', [
8686
'3',
8787
],
8888
];
8989

90-
$a = array(
90+
$a = [
9191
'x' => 'y',
92-
);
92+
];
9393

9494
$backend->expects($this->exactly(1))
9595
->method('get')
9696
->will($this->onConsecutiveCalls(
97-
(object) array(
98-
'data' => array(
99-
'hook' => array(
100-
'module_handler_test' => array(),
101-
'module_handler_test_missing' => array(),
102-
),
103-
),
104-
)
97+
(object) [
98+
'data' => [
99+
'hook' => [
100+
'module_handler_test' => [],
101+
'module_handler_test_missing' => [],
102+
],
103+
],
104+
]
105105
));
106106

107107
$backend->expects($this->exactly(1))
@@ -121,14 +121,14 @@ $backend->expects($this->exactly(1))
121121
* Nested closure in an array should not throw errors.
122122
*/
123123
function mymodule_libraries_info() {
124-
$libraries['some-library'] = array(
124+
$libraries['some-library'] = [
125125
'xautoload' => function ($adapter) {
126126
/** @var \Drupal\xautoload\Adapter\LocalDirectoryAdapter $adapter */
127127
// Scan sites/all/libraries/some-library/composer.json to look for
128128
// autoload information.
129129
$adapter->composerJson('composer.json');
130130
},
131-
);
131+
];
132132
return $libraries;
133133
}
134134

tests/Drupal/Arrays/DisallowLongArraySyntaxUnitTest.php

Lines changed: 0 additions & 68 deletions
This file was deleted.

tests/Drupal/Arrays/disallow_long_array_d7/DisallowLongArraySyntaxUnitTest.1.inc

Lines changed: 0 additions & 13 deletions
This file was deleted.

tests/Drupal/Arrays/disallow_long_array_d7/disallow_long_array_d7.info

Lines changed: 0 additions & 3 deletions
This file was deleted.

tests/Drupal/Arrays/disallow_long_array_d8/DisallowLongArraySyntaxUnitTest.2.inc

Lines changed: 0 additions & 13 deletions
This file was deleted.

tests/Drupal/Arrays/disallow_long_array_d8/DisallowLongArraySyntaxUnitTest.2.inc.fixed

Lines changed: 0 additions & 13 deletions
This file was deleted.

tests/Drupal/Arrays/disallow_long_array_d8/disallow_long_array_d8.info.yml

Lines changed: 0 additions & 4 deletions
This file was deleted.

tests/Drupal/Commenting/InlineCommentUnitTest.inc.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ test();
5454
*/
5555
function example_custom_block_view($delta = '') {
5656
// This example is adapted from node.module.
57-
$block = array();
57+
$block = [];
5858

5959
switch ($delta) {
6060
case 'my_block':

0 commit comments

Comments
 (0)