Skip to content

Commit ced988c

Browse files
authored
Merge pull request #568 from jhedstrom/567-phpcs
Fix phpcs issues
2 parents 341c877 + 90ea831 commit ced988c

File tree

17 files changed

+135
-132
lines changed

17 files changed

+135
-132
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"require-dev": {
3636
"phpspec/phpspec": "~2.0 || ~4.0",
3737
"jakub-onderka/php-parallel-lint": "^0.9.2",
38-
"drupal/coder": "~8.2.12"
38+
"drupal/coder": "^8.3"
3939
},
4040
"scripts": {
4141
"test": [

phpcs-ruleset.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,7 @@
2020
<exclude name="Generic.Files.LineLength.TooLong" />
2121
</rule>
2222

23+
<rule ref="Generic.Arrays.DisallowLongArraySyntax" />
24+
<rule ref="Generic.Arrays.ArrayIndent" />
25+
2326
</ruleset>

src/Drupal/DrupalDriverManager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class DrupalDriverManager implements DrupalDriverManagerInterface
2828
*
2929
* @var \Drupal\Driver\DriverInterface[]
3030
*/
31-
private $drivers = array();
31+
private $drivers = [];
3232

3333
/**
3434
* Behat environment.
@@ -43,7 +43,7 @@ class DrupalDriverManager implements DrupalDriverManagerInterface
4343
* @param \Drupal\Driver\DriverInterface[] $drivers
4444
* An array of drivers to register.
4545
*/
46-
public function __construct(array $drivers = array())
46+
public function __construct(array $drivers = [])
4747
{
4848
foreach ($drivers as $name => $driver) {
4949
$this->registerDriver($name, $driver);

src/Drupal/DrupalExtension/Compiler/DriverPass.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function process(ContainerBuilder $container)
2626
if (isset($attribute['alias']) && $name = $attribute['alias']) {
2727
$drupalDefinition->addMethodCall(
2828
'registerDriver',
29-
array($name, new Reference($id))
29+
[$name, new Reference($id)]
3030
);
3131
}
3232
}
@@ -35,7 +35,7 @@ public function process(ContainerBuilder $container)
3535
// instantiated as well.
3636
if ('drupal.driver.drupal' === $id) {
3737
$drupalDriverDefinition = $container->getDefinition($id);
38-
$availableCores = array();
38+
$availableCores = [];
3939
foreach ($container->findTaggedServiceIds('drupal.core') as $coreId => $coreAttributes) {
4040
foreach ($coreAttributes as $attribute) {
4141
if (isset($attribute['alias']) && $name = $attribute['alias']) {
@@ -45,14 +45,14 @@ public function process(ContainerBuilder $container)
4545
}
4646
$drupalDriverDefinition->addMethodCall(
4747
'setCore',
48-
array($availableCores)
48+
[$availableCores]
4949
);
5050
}
5151
}
5252

5353
$drupalDefinition->addMethodCall(
5454
'setDefaultDriverName',
55-
array($container->getParameter('drupal.drupal.default_driver'))
55+
[$container->getParameter('drupal.drupal.default_driver')]
5656
);
5757
}
5858
}

src/Drupal/DrupalExtension/Compiler/EventSubscriberPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function process(ContainerBuilder $container)
2828
$priority = isset($attribute['priority']) ? intval($attribute['priority']) : 0;
2929
$dispatcherDefinition->addMethodCall(
3030
'addSubscriber',
31-
array(new Reference($id), $priority)
31+
[new Reference($id), $priority]
3232
);
3333
}
3434
}

src/Drupal/DrupalExtension/Context/Annotation/Reader.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ class Reader implements AnnotationReader
2222
/**
2323
* @var string[]
2424
*/
25-
private static $classes = array(
26-
'afternodecreate' => 'Drupal\DrupalExtension\Hook\Call\AfterNodeCreate',
27-
'aftertermcreate' => 'Drupal\DrupalExtension\Hook\Call\AfterTermCreate',
28-
'afterusercreate' => 'Drupal\DrupalExtension\Hook\Call\AfterUserCreate',
29-
'beforenodecreate' => 'Drupal\DrupalExtension\Hook\Call\BeforeNodeCreate',
30-
'beforetermcreate' => 'Drupal\DrupalExtension\Hook\Call\BeforeTermCreate',
31-
'beforeusercreate' => 'Drupal\DrupalExtension\Hook\Call\BeforeUserCreate',
32-
);
25+
private static $classes = [
26+
'afternodecreate' => 'Drupal\DrupalExtension\Hook\Call\AfterNodeCreate',
27+
'aftertermcreate' => 'Drupal\DrupalExtension\Hook\Call\AfterTermCreate',
28+
'afterusercreate' => 'Drupal\DrupalExtension\Hook\Call\AfterUserCreate',
29+
'beforenodecreate' => 'Drupal\DrupalExtension\Hook\Call\BeforeNodeCreate',
30+
'beforetermcreate' => 'Drupal\DrupalExtension\Hook\Call\BeforeTermCreate',
31+
'beforeusercreate' => 'Drupal\DrupalExtension\Hook\Call\BeforeUserCreate',
32+
];
3333

3434
/**
3535
* {@inheritDoc}
@@ -44,7 +44,7 @@ public function readCallee($contextClass, ReflectionMethod $method, $docLine, $d
4444
$type = strtolower($match[1]);
4545
$class = self::$classes[$type];
4646
$pattern = isset($match[2]) ? $match[2] : null;
47-
$callable = array($contextClass, $method->getName());
47+
$callable = [$contextClass, $method->getName()];
4848

4949
return new $class($pattern, $callable, $description);
5050
}

src/Drupal/DrupalExtension/Context/BatchContext.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ public function thereIsAnItemInTheSystemQueue(TableNode $table)
4242

4343
// @see SystemQueue::createItem().
4444
$query = db_insert('queue')
45-
->fields(array(
46-
'name' => $fields['name'] ?: user_password(),
47-
'data' => serialize(json_decode($fields['data'])),
48-
'created' => $fields['created'] ?: REQUEST_TIME,
49-
'expire' => $fields['expire'] ?: 0,
50-
));
45+
->fields([
46+
'name' => $fields['name'] ?: user_password(),
47+
'data' => serialize(json_decode($fields['data'])),
48+
'created' => $fields['created'] ?: REQUEST_TIME,
49+
'expire' => $fields['expire'] ?: 0,
50+
]);
5151
if (!$query->execute()) {
5252
throw new Exception('Unable to create the queue item.');
5353
}

src/Drupal/DrupalExtension/Context/ConfigContext.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public static function getTranslationResources()
2929
*
3030
* @var array
3131
*/
32-
protected $config = array();
32+
protected $config = [];
3333

3434
/**
3535
* Revert any changed config.
@@ -44,7 +44,7 @@ public function cleanConfig()
4444
$this->getDriver()->configSet($name, $key, $value);
4545
}
4646
}
47-
$this->config = array();
47+
$this->config = [];
4848
}
4949

5050
/**
@@ -82,7 +82,7 @@ public function setBasicConfig($name, $key, $value)
8282
*/
8383
public function setComplexConfig($name, $key, TableNode $config_table)
8484
{
85-
$value = array();
85+
$value = [];
8686
foreach ($config_table->getHash() as $row) {
8787
// Allow json values for extra complexity.
8888
if (json_decode($row['value'])) {

src/Drupal/DrupalExtension/Context/ContextClass/ClassGenerator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ public function generateClass(Suite $suite, $contextClass)
6464

6565
return strtr(
6666
static::$template,
67-
array(
68-
'{namespace}' => $namespace,
69-
'{className}' => $contextClass,
70-
)
67+
[
68+
'{namespace}' => $namespace,
69+
'{className}' => $contextClass,
70+
]
7171
);
7272
}
7373
}

src/Drupal/DrupalExtension/Context/DrupalContext.php

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,19 @@ public function assertAuthenticatedByRole($role)
4545
// Check if a user with this role is already logged in.
4646
if (!$this->loggedInWithRole($role)) {
4747
// Create user (and project)
48-
$user = (object) array(
49-
'name' => $this->getRandom()->name(8),
50-
'pass' => $this->getRandom()->name(16),
51-
'role' => $role,
52-
);
48+
$user = (object) [
49+
'name' => $this->getRandom()->name(8),
50+
'pass' => $this->getRandom()->name(16),
51+
'role' => $role,
52+
];
5353
$user->mail = "{$user->name}@example.com";
5454

5555
$this->userCreate($user);
5656

5757
$roles = explode(',', $role);
5858
$roles = array_map('trim', $roles);
5959
foreach ($roles as $role) {
60-
if (!in_array(strtolower($role), array('authenticated', 'authenticated user'))) {
60+
if (!in_array(strtolower($role), ['authenticated', 'authenticated user'])) {
6161
// Only add roles other than 'authenticated user'.
6262
$this->getDriver()->userAddRole($user, $role);
6363
}
@@ -81,11 +81,11 @@ public function assertAuthenticatedByRoleWithGivenFields($role, TableNode $field
8181
// Check if a user with this role is already logged in.
8282
if (!$this->loggedInWithRole($role)) {
8383
// Create user (and project)
84-
$user = (object) array(
85-
'name' => $this->getRandom()->name(8),
86-
'pass' => $this->getRandom()->name(16),
87-
'role' => $role,
88-
);
84+
$user = (object) [
85+
'name' => $this->getRandom()->name(8),
86+
'pass' => $this->getRandom()->name(16),
87+
'role' => $role,
88+
];
8989
$user->mail = "{$user->name}@example.com";
9090

9191
// Assign fields to user before creation.
@@ -98,7 +98,7 @@ public function assertAuthenticatedByRoleWithGivenFields($role, TableNode $field
9898
$roles = explode(',', $role);
9999
$roles = array_map('trim', $roles);
100100
foreach ($roles as $role) {
101-
if (!in_array(strtolower($role), array('authenticated', 'authenticated user'))) {
101+
if (!in_array(strtolower($role), ['authenticated', 'authenticated user'])) {
102102
// Only add roles other than 'authenticated user'.
103103
$this->getDriver()->userAddRole($user, $role);
104104
}
@@ -134,11 +134,11 @@ public function assertLoggedInWithPermissions($permissions)
134134
$role = $this->getDriver()->roleCreate($permissions);
135135

136136
// Create user.
137-
$user = (object) array(
138-
'name' => $this->getRandom()->name(8),
139-
'pass' => $this->getRandom()->name(16),
140-
'role' => $role,
141-
);
137+
$user = (object) [
138+
'name' => $this->getRandom()->name(8),
139+
'pass' => $this->getRandom()->name(16),
140+
'role' => $role,
141+
];
142142
$user->mail = "{$user->name}@example.com";
143143
$this->userCreate($user);
144144

@@ -245,10 +245,10 @@ public function assertCron()
245245
public function createNode($type, $title)
246246
{
247247
// @todo make this easily extensible.
248-
$node = (object) array(
249-
'title' => $title,
250-
'type' => $type,
251-
);
248+
$node = (object) [
249+
'title' => $title,
250+
'type' => $type,
251+
];
252252
$saved = $this->nodeCreate($node);
253253
// Set internal page on the new node.
254254
$this->getSession()->visit($this->locatePath('/node/' . $saved->nid));
@@ -265,12 +265,12 @@ public function createMyNode($type, $title)
265265
throw new \Exception(sprintf('There is no current logged in user to create a node for.'));
266266
}
267267

268-
$node = (object) array(
269-
'title' => $title,
270-
'type' => $type,
271-
'body' => $this->getRandom()->name(255),
272-
'uid' => $this->getUserManager()->getCurrentUser()->uid,
273-
);
268+
$node = (object) [
269+
'title' => $title,
270+
'type' => $type,
271+
'body' => $this->getRandom()->name(255),
272+
'uid' => $this->getUserManager()->getCurrentUser()->uid,
273+
];
274274
$saved = $this->nodeCreate($node);
275275

276276
// Set internal page on the new node.
@@ -306,9 +306,9 @@ public function createNodes($type, TableNode $nodesTable)
306306
*/
307307
public function assertViewingNode($type, TableNode $fields)
308308
{
309-
$node = (object) array(
310-
'type' => $type,
311-
);
309+
$node = (object) [
310+
'type' => $type,
311+
];
312312
foreach ($fields->getRowsHash() as $field => $value) {
313313
$node->{$field} = $value;
314314
}
@@ -326,10 +326,10 @@ public function assertViewingNode($type, TableNode $fields)
326326
*/
327327
public function assertEditNodeOfType($type)
328328
{
329-
$node = (object) array(
330-
'type' => $type,
331-
'title' => "Test $type",
332-
);
329+
$node = (object) [
330+
'type' => $type,
331+
'title' => "Test $type",
332+
];
333333
$saved = $this->nodeCreate($node);
334334

335335
// Set internal browser on the node edit page.
@@ -349,11 +349,11 @@ public function assertEditNodeOfType($type)
349349
public function createTerm($vocabulary, $name)
350350
{
351351
// @todo make this easily extensible.
352-
$term = (object) array(
353-
'name' => $name,
354-
'vocabulary_machine_name' => $vocabulary,
355-
'description' => $this->getRandom()->name(255),
356-
);
352+
$term = (object) [
353+
'name' => $name,
354+
'vocabulary_machine_name' => $vocabulary,
355+
'description' => $this->getRandom()->name(255),
356+
];
357357
$saved = $this->termCreate($term);
358358

359359
// Set internal page on the term.
@@ -374,7 +374,7 @@ public function createUsers(TableNode $usersTable)
374374
{
375375
foreach ($usersTable->getHash() as $userHash) {
376376
// Split out roles to process after user is created.
377-
$roles = array();
377+
$roles = [];
378378
if (isset($userHash['roles'])) {
379379
$roles = explode(',', $userHash['roles']);
380380
$roles = array_filter(array_map('trim', $roles));
@@ -434,9 +434,9 @@ public function createTerms($vocabulary, TableNode $termsTable)
434434
public function createLanguages(TableNode $langcodesTable)
435435
{
436436
foreach ($langcodesTable->getHash() as $row) {
437-
$language = (object) array(
438-
'langcode' => $row['languages'],
439-
);
437+
$language = (object) [
438+
'langcode' => $row['languages'],
439+
];
440440
$this->languageCreate($language);
441441
}
442442
}

0 commit comments

Comments
 (0)