diff --git a/src/Controller/TokenAutocompleteController.php b/src/Controller/TokenAutocompleteController.php index a50da70..35b5a37 100644 --- a/src/Controller/TokenAutocompleteController.php +++ b/src/Controller/TokenAutocompleteController.php @@ -48,7 +48,7 @@ class TokenAutocompleteController extends ControllerBase { public function autocomplete($token_type, $filter, Request $request) { $filter = substr($filter, strrpos($filter, '[')); - $matches = array(); + $matches = []; if (!Unicode::strlen($filter)) { $matches["[{$token_type}:"] = 0; diff --git a/src/Routing/RouteSubscriber.php b/src/Routing/RouteSubscriber.php index ae6815a..376b48f 100644 --- a/src/Routing/RouteSubscriber.php +++ b/src/Routing/RouteSubscriber.php @@ -68,7 +68,7 @@ class RouteSubscriber extends RouteSubscriberBase { */ public static function getSubscribedEvents() { $events = parent::getSubscribedEvents(); - $events[RoutingEvents::ALTER] = array('onAlterRoutes', 100); + $events[RoutingEvents::ALTER] = ['onAlterRoutes', 100]; return $events; } } diff --git a/src/Tests/TokenBlockTest.php b/src/Tests/TokenBlockTest.php index 66e3025..1a4bdd5 100644 --- a/src/Tests/TokenBlockTest.php +++ b/src/Tests/TokenBlockTest.php @@ -21,38 +21,38 @@ class TokenBlockTest extends TokenTestBase { /** * {@inheritdoc} */ - public function setUp($modules = array()) { + public function setUp($modules = []) { parent::setUp(); - $this->admin_user = $this->drupalCreateUser(array('access content', 'administer blocks')); + $this->admin_user = $this->drupalCreateUser(['access content', 'administer blocks']); $this->drupalLogin($this->admin_user); } public function testBlockTitleTokens() { $label = 'tokenblock'; - $bundle = BlockContentType::create(array( + $bundle = BlockContentType::create([ 'id' => $label, 'label' => $label, 'revision' => FALSE - )); + ]); $bundle->save(); - $block_content = BlockContent::create(array( + $block_content = BlockContent::create([ 'type' => $label, 'label' => '[current-page:title] block title', 'info' => 'Test token title block', 'body[value]' => 'This is the test token title block.', - )); + ]); $block_content->save(); - $block = $this->drupalPlaceBlock('block_content:' . $block_content->uuid(), array( + $block = $this->drupalPlaceBlock('block_content:' . $block_content->uuid(), [ 'label' => '[user:name]', - )); + ]); $this->drupalGet($block->urlInfo()); // Ensure that the link to available tokens is present and correctly // positioned. $this->assertLink('Browse available tokens.'); $this->assertText('This field supports tokens. Browse available tokens.'); - $this->drupalPostForm(NULL, array(), t('Save block')); + $this->drupalPostForm(NULL, [] , t('Save block')); // Ensure token validation is working on the block. $this->assertText('Title is using the following invalid tokens: [user:name].'); @@ -63,8 +63,8 @@ class TokenBlockTest extends TokenTestBase { $block->save(); // Ensure that tokens are not double-escaped when output as a block title. - $this->drupalCreateContentType(array('type' => 'page')); - $node = $this->drupalCreateNode(array('title' => "Site's first node")); + $this->drupalCreateContentType['type' => 'page']); + $node = $this->drupalCreateNode(['title' => "Site's first node"]); $this->drupalGet('node/' . $node->id()); // The apostraphe should only be escaped once. $this->assertRaw("Site's first node block title"); diff --git a/src/Tests/TokenCurrentPageTest.php b/src/Tests/TokenCurrentPageTest.php index cd8ac37..f54cbe5 100644 --- a/src/Tests/TokenCurrentPageTest.php +++ b/src/Tests/TokenCurrentPageTest.php @@ -16,19 +16,19 @@ class TokenCurrentPageTest extends TokenTestBase { * * @var array */ - public static $modules = array('node'); + public static $modules = ['node']; function testCurrentPageTokens() { - $tokens = array( + $tokens = [ '[current-page:title]' => t('Log in'), - '[current-page:url]' => Url::fromRoute('user.login', [], array('absolute' => TRUE))->toString(), - '[current-page:url:absolute]' => Url::fromRoute('user.login', [], array('absolute' => TRUE))->toString(), + '[current-page:url]' => Url::fromRoute('user.login', [], ['absolute' => TRUE])->toString(), + '[current-page:url:absolute]' => Url::fromRoute('user.login', [], ['absolute' => TRUE])->toString(), '[current-page:url:relative]' => Url::fromRoute('user.login')->toString(), '[current-page:url:path]' => '/user/login', '[current-page:url:args:value:0]' => 'user', '[current-page:url:args:value:1]' => 'login', '[current-page:url:args:value:2]' => NULL, - '[current-page:url:unaliased]' => Url::fromRoute('user.login', [], array('absolute' => TRUE, 'alias' => TRUE))->toString(), + '[current-page:url:unaliased]' => Url::fromRoute('user.login', [], ['absolute' => TRUE, 'alias' => TRUE])->toString(), '[current-page:page-number]' => 1, '[current-page:query:foo]' => NULL, '[current-page:query:bar]' => NULL, @@ -36,20 +36,20 @@ class TokenCurrentPageTest extends TokenTestBase { '[current-page:arg:0]' => 'user', '[current-page:arg:1]' => 'login', '[current-page:arg:2]' => NULL, - ); + ]; $this->assertPageTokens('user/login', $tokens); - $this->drupalCreateContentType(array('type' => 'page')); - $node = $this->drupalCreateNode(array('title' => 'Node title', 'path' => array('alias' => '/node-alias'))); - $tokens = array( + $this->drupalCreateContentType(['type' => 'page']); + $node = $this->drupalCreateNode(['title' => 'Node title', 'path' => ['alias' => '/node-alias']]); + $tokens = [ '[current-page:title]' => 'Node title', - '[current-page:url]' => $node->url('canonical', array('absolute' => TRUE)), - '[current-page:url:absolute]' => $node->url('canonical', array('absolute' => TRUE)), + '[current-page:url]' => $node->url('canonical', ['absolute' => TRUE]), + '[current-page:url:absolute]' => $node->url('canonical', ['absolute' => TRUE]), '[current-page:url:relative]' => $node->url(), '[current-page:url:alias]' => '/node-alias', '[current-page:url:args:value:0]' => 'node-alias', '[current-page:url:args:value:1]' => NULL, - '[current-page:url:unaliased]' => $node->url('canonical', array('absolute' => TRUE, 'alias' => TRUE)), + '[current-page:url:unaliased]' => $node->url('canonical', ['absolute' => TRUE, 'alias' => TRUE]), '[current-page:url:unaliased:args:value:0]' => 'node', '[current-page:url:unaliased:args:value:1]' => $node->id(), '[current-page:url:unaliased:args:value:2]' => NULL, @@ -60,7 +60,7 @@ class TokenCurrentPageTest extends TokenTestBase { '[current-page:arg:0]' => 'node', '[current-page:arg:1]' => 1, '[current-page:arg:2]' => NULL, - ); - $this->assertPageTokens("/node/{$node->id()}", $tokens, array(), array('url_options' => array('query' => array('foo' => 'bar')))); + ]; + $this->assertPageTokens("/node/{$node->id()}", $tokens, [], ['url_options' => ['query' => ['foo' => 'bar']]]); } }