Commit f6ae5852 authored by catch's avatar catch

Issue #2572801 by alexpott, vprocessor, andriyun, andypost, chishah92, Mile23,...

Issue #2572801 by alexpott, vprocessor, andriyun, andypost, chishah92, Mile23, attiks, hussainweb, klausi, dawehner, pfrenssen: Fix 'Drupal.WhiteSpace.ScopeIndent' coding standard
parent b6a64fc0
......@@ -707,7 +707,7 @@ function update_language_list($flags = LanguageInterface::STATE_CONFIGURABLE) {
// Initialize master language list.
if (!isset($languages)) {
// Initialize local language list cache.
$languages = array();
$languages = array();
// Fill in master language list based on current configuration.
$default = \Drupal::languageManager()->getDefaultLanguage();
......
......@@ -81,9 +81,9 @@ public static function sortByTitleElement($a, $b) {
* @return int
* The comparison result for uasort().
*/
public static function sortByTitleProperty($a, $b) {
return static::sortByKeyString($a, $b, '#title');
}
public static function sortByTitleProperty($a, $b) {
return static::sortByKeyString($a, $b, '#title');
}
/**
* Sorts a string array item by an arbitrary key.
......
......@@ -66,8 +66,8 @@ public function get(EntityTypeInterface $entity_type, $conjunction) {
/**
* {@inheritdoc}
*/
public function getAggregate(EntityTypeInterface $entity_type, $conjunction) {
throw new QueryException('Aggregation over configuration entities is not supported');
public function getAggregate(EntityTypeInterface $entity_type, $conjunction) {
throw new QueryException('Aggregation over configuration entities is not supported');
}
/**
......
......@@ -65,7 +65,7 @@ protected function connect() {
$this->pass('Drupal can CONNECT to the database ok.');
}
catch (\Exception $e) {
// Attempt to create the database if it is not found.
// Attempt to create the database if it is not found.
if ($e->getCode() == Connection::DATABASE_NOT_FOUND) {
// Remove the database string from connection info.
$connection_info = Database::getConnectionInfo();
......
......@@ -90,7 +90,7 @@ public function rowCount();
* If $mode is PDO::FETCH_CLASS, the optional arguments to pass to the
* constructor.
*/
public function setFetchMode($mode, $a1 = NULL, $a2 = array());
public function setFetchMode($mode, $a1 = NULL, $a2 = array());
/**
* Fetches the next row from a result set.
......@@ -109,7 +109,7 @@ public function setFetchMode($mode, $a1 = NULL, $a2 = array());
* @return
* A result, formatted according to $mode.
*/
public function fetch($mode = NULL, $cursor_orientation = NULL, $cursor_offset = NULL);
public function fetch($mode = NULL, $cursor_orientation = NULL, $cursor_offset = NULL);
/**
* Returns a single field from the next record of a result set.
......@@ -128,7 +128,7 @@ public function fetchField($index = 0);
* The object will be of the class specified by StatementInterface::setFetchMode()
* or stdClass if not specified.
*/
public function fetchObject();
public function fetchObject();
/**
* Fetches the next row and returns it as an associative array.
......@@ -155,7 +155,7 @@ public function fetchAssoc();
* @return
* An array of results.
*/
function fetchAll($mode = NULL, $column_index = NULL, $constructor_arguments = NULL);
function fetchAll($mode = NULL, $column_index = NULL, $constructor_arguments = NULL);
/**
* Returns an entire single column of a result set as an indexed array.
......
......@@ -14,7 +14,7 @@ class Container extends DrupalContainer {
* {@inheritdoc}
*/
public function set($id, $service, $scope = ContainerInterface::SCOPE_CONTAINER) {
parent::set($id, $service, $scope);
parent::set($id, $service, $scope);
// Ensure that the _serviceId property is set on synthetic services as well.
if (isset($this->services[$id]) && is_object($this->services[$id]) && !isset($this->services[$id]->_serviceId)) {
......
......@@ -33,10 +33,10 @@ public function validate($value, Constraint $constraint) {
$referenced_entities = $existing_entity->{$value->getFieldDefinition()->getName()}->referencedEntities();
// Check permission if we are not already referencing the entity.
foreach ($referenced_entities as $ref) {
if (isset($referenced_entities[$ref->id()])) {
$check_permission = FALSE;
break;
}
if (isset($referenced_entities[$ref->id()])) {
$check_permission = FALSE;
break;
}
}
}
// We check that the current user had access to view any newly added
......
......@@ -225,7 +225,7 @@ protected function finish() {
if ($this->range) {
$this->sqlQuery->range($this->range['start'], $this->range['length']);
}
foreach ($this->sqlGroupBy as $field) {
foreach ($this->sqlGroupBy as $field) {
$this->sqlQuery->groupBy($field);
}
foreach ($this->sqlFields as $field) {
......
......@@ -893,9 +893,9 @@ function hook_ENTITY_TYPE_storage_load(array $entities) {
* @see hook_ENTITY_TYPE_presave()
*/
function hook_entity_presave(Drupal\Core\Entity\EntityInterface $entity) {
if ($entity instanceof ContentEntityInterface && $entity->isTranslatable()) {
$route_match = \Drupal::routeMatch();
\Drupal::service('content_translation.synchronizer')->synchronizeFields($entity, $entity->language()->getId(), $route_match->getParameter('source_langcode'));
if ($entity instanceof ContentEntityInterface && $entity->isTranslatable()) {
$route_match = \Drupal::routeMatch();
\Drupal::service('content_translation.synchronizer')->synchronizeFields($entity, $entity->language()->getId(), $route_match->getParameter('source_langcode'));
}
}
......
......@@ -30,7 +30,7 @@ trait AllowedTagsXssTrait {
* valid UTF-8.
*/
public function fieldFilterXss($string) {
return FieldFilteredMarkup::create($string);
return FieldFilteredMarkup::create($string);
}
/**
......
......@@ -257,7 +257,7 @@ public function view($display_options = array()) {
/**
* {@inheritdoc}
*/
public function generateSampleItems($count = 1) {
public function generateSampleItems($count = 1) {
$field_definition = $this->getFieldDefinition();
$field_type_class = \Drupal::service('plugin.manager.field.field_type')->getPluginClass($field_definition->getType());
for ($delta = 0; $delta < $count; $delta++) {
......
......@@ -617,7 +617,7 @@ public static function settingsAjaxSubmit($form, FormStateInterface $form_state)
$form_state->setRebuild();
}
/**
/**
* {@inheritdoc}
*/
public static function getPreconfiguredOptions() {
......
......@@ -31,7 +31,7 @@ class MimeTypeGuesser implements MimeTypeGuesserInterface {
*/
protected $sortedGuessers = NULL;
/**
/**
* The stream wrapper manager.
*
* @var \Drupal\Core\StreamWrapper\StreamWrapperManagerInterface
......
......@@ -648,7 +648,7 @@ public function disableRedirect($no_redirect = TRUE) {
* {@inheritdoc}
*/
public function isRedirectDisabled() {
return $this->no_redirect;
return $this->no_redirect;
}
/**
......
......@@ -123,7 +123,7 @@ protected function prepareArguments(array $arguments) {
// Use the default value if the argument is not passed in.
if (!array_key_exists($id, $arguments)) {
$arguments[$id] = $argument['default'];
$arguments[$id] = $argument['default'];
}
}
}
......
......@@ -37,7 +37,7 @@ class SiteSettingsForm extends FormBase {
public function __construct($site_path, RendererInterface $renderer) {
$this->sitePath = $site_path;
$this->renderer = $renderer;
}
}
/**
* {@inheritdoc}
......
......@@ -202,8 +202,7 @@ public static function htmlToText($string, $allowed_tags = NULL) {
// Ensure blank new-line.
$chunk = '';
}
// Fall-through.
// Intentional fall-through to the processing for '/li' and '/dd'.
case '/li':
case '/dd':
array_pop($indent);
......@@ -212,6 +211,7 @@ public static function htmlToText($string, $allowed_tags = NULL) {
case '/h3':
case '/h4':
array_pop($indent);
// Intentional fall-through to the processing for '/h5' and '/h6'.
case '/h5':
case '/h6':
// Ensure blank new-line.
......
......@@ -30,7 +30,7 @@ interface MailInterface {
*
* @see \Drupal\Core\Mail\MailManagerInterface
*/
public function format(array $message);
public function format(array $message);
/**
* Sends a message composed by \Drupal\Core\Mail\MailManagerInterface->mail().
......@@ -60,6 +60,6 @@ public function format(array $message);
* @return bool
* TRUE if the mail was successfully accepted for delivery, otherwise FALSE.
*/
public function mail(array $message);
public function mail(array $message);
}
......@@ -126,11 +126,11 @@ protected function getDiscovery() {
public function processDefinition(&$definition, $plugin_id) {
parent::processDefinition($definition, $plugin_id);
// If there is no route name, this is a broken definition.
// If there is no route name, this is a broken definition.
if (empty($definition['route_name'])) {
throw new PluginException(sprintf('Contextual link plugin (%s) definition must include "route_name".', $plugin_id));
}
// If there is no group name, this is a broken definition.
// If there is no group name, this is a broken definition.
if (empty($definition['group'])) {
throw new PluginException(sprintf('Contextual link plugin (%s) definition must include "group".', $plugin_id));
}
......
......@@ -37,7 +37,7 @@ class DefaultMenuLinkTreeManipulators {
*
* @var \Drupal\Core\Entity\Query\QueryFactory
*/
protected $queryFactory;
protected $queryFactory;
/**
* Constructs a \Drupal\Core\Menu\DefaultMenuLinkTreeManipulators object.
......
......@@ -24,7 +24,7 @@ class LocalActionDefault extends PluginBase implements LocalActionInterface, Con
*
* @var \Drupal\Core\Routing\RouteProviderInterface
*/
protected $routeProvider;
protected $routeProvider;
/**
* Constructs a LocalActionDefault object.
......
......@@ -158,7 +158,7 @@ protected function getDiscovery() {
*/
public function processDefinition(&$definition, $plugin_id) {
parent::processDefinition($definition, $plugin_id);
// If there is no route name, this is a broken definition.
// If there is no route name, this is a broken definition.
if (empty($definition['route_name'])) {
throw new PluginException(sprintf('Plugin (%s) definition must include "route_name"', $plugin_id));
}
......
......@@ -283,7 +283,7 @@ protected function pathAliasWhitelistRebuild($path = NULL) {
if (!empty($path)) {
if ($this->whitelist->get(strtok($path, '/'))) {
return;
}
}
}
$this->whitelist->clear();
}
......
......@@ -85,7 +85,7 @@ public static function create($data_type = 'any') {
*
* @param string $data_type
* The required data type.
* @param mixed string|null $label
* @param string|null $label
* The label of this context definition for the UI.
* @param bool $required
* Whether the context definition is required.
......@@ -245,7 +245,7 @@ public function getDataDefinition() {
->setDescription($this->getDescription())
->setRequired($this->isRequired());
$constraints = $definition->getConstraints() + $this->getConstraints();
$definition->setConstraints($constraints);
$definition->setConstraints($constraints);
return $definition;
}
......
......@@ -555,7 +555,7 @@ function hook_form_system_theme_settings_alter(&$form, \Drupal\Core\Form\FormSta
* The name of the theme hook.
*/
function hook_preprocess(&$variables, $hook) {
static $hooks;
static $hooks;
// Add contextual links to the variables, if the user has permission.
......
......@@ -66,7 +66,7 @@ public function getExternalUrl() {
public static function baseUrl() {
$settings_base_url = Settings::get('file_public_base_url', '');
if ($settings_base_url) {
return (string) $settings_base_url;
return (string) $settings_base_url;
}
else {
return $GLOBALS['base_url'] . '/' . static::basePath();
......
......@@ -44,7 +44,7 @@ interface DataDefinitionInterface {
* If an unsupported data type gets passed to the class; e.g., 'string' to a
* definition class handling 'entity:* data types.
*/
public static function createFromDataType($data_type);
public static function createFromDataType($data_type);
/**
* Returns the data type of the data.
......
......@@ -53,7 +53,7 @@ function __construct($cid, CacheBackendInterface $cache, LockBackendInterface $l
$this->tags = $tags;
$this->persistable = $modules_loaded && \Drupal::hasRequest() && \Drupal::request()->isMethod('GET');
// @todo: Implement lazyload.
// @todo: Implement lazyload.
$this->cacheLoaded = TRUE;
if ($this->persistable && $cached = $this->cache->get($this->cid)) {
......
......@@ -54,7 +54,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
->setDescription(t('The ID of the feed item.'));
$fields['langcode']->setLabel(t('Language code'))
->setDescription(t('The feed item language code.'));
->setDescription(t('The feed item language code.'));
$fields['fid'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Source feed'))
......
......@@ -21,11 +21,9 @@ protected function checkAccess(EntityInterface $entity, $operation, AccountInter
switch ($operation) {
case 'view':
return AccessResult::allowedIfHasPermission($account, 'access news feeds');
break;
default:
return AccessResult::allowedIfHasPermission($account, 'administer news feeds');
break;
}
}
......
......@@ -60,17 +60,17 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
}
foreach ($items as $delta => $item) {
if ($this->getSetting('display_as_link') && $url_string) {
$elements[$delta] = [
if ($this->getSetting('display_as_link') && $url_string) {
$elements[$delta] = [
'#type' => 'link',
'#title' => $item->value,
'#url' => Url::fromUri($url_string),
];
}
else {
$elements[$delta] = ['#markup' => $item->value];
}
];
}
else {
$elements[$delta] = ['#markup' => $item->value];
}
}
return $elements;
}
......
......@@ -24,11 +24,11 @@ class BlockTheme extends ProcessPluginBase implements ContainerFactoryPluginInte
*/
protected $configFactory;
/**
* Contains the system.theme configuration object.
*
* @var \Drupal\Core\Config\Config
*/
/**
* Contains the system.theme configuration object.
*
* @var \Drupal\Core\Config\Config
*/
protected $themeConfig;
/**
......
......@@ -63,7 +63,7 @@ protected function setUp() {
$this->normalUserAlt->save();
// Enable our test block.
$this->block = $this->drupalPlaceBlock('test_cache');
$this->block = $this->drupalPlaceBlock('test_cache');
}
/**
......
......@@ -25,7 +25,7 @@ protected function setUp() {
parent::setUp();
// Enable our test block.
$this->drupalPlaceBlock('test_form_in_block');
$this->drupalPlaceBlock('test_form_in_block');
}
/**
......
......@@ -13,7 +13,7 @@
*/
class MigrateBlockTest extends MigrateDrupal7TestBase {
/**
/**
* {@inheritdoc}
*/
public static $modules = [
......
......@@ -526,49 +526,49 @@ function testNavigationBlockOnAccessModuleInstalled() {
/**
* Tests the access for deleting top-level book nodes.
*/
function testBookDelete() {
$node_storage = $this->container->get('entity.manager')->getStorage('node');
$nodes = $this->createBook();
$this->drupalLogin($this->adminUser);
$edit = array();
// Test access to delete top-level and child book nodes.
$this->drupalGet('node/' . $this->book->id() . '/outline/remove');
$this->assertResponse('403', 'Deleting top-level book node properly forbidden.');
$this->drupalPostForm('node/' . $nodes[4]->id() . '/outline/remove', $edit, t('Remove'));
$node_storage->resetCache(array($nodes[4]->id()));
$node4 = $node_storage->load($nodes[4]->id());
$this->assertTrue(empty($node4->book), 'Deleting child book node properly allowed.');
// Delete all child book nodes and retest top-level node deletion.
foreach ($nodes as $node) {
$nids[] = $node->id();
}
entity_delete_multiple('node', $nids);
$this->drupalPostForm('node/' . $this->book->id() . '/outline/remove', $edit, t('Remove'));
$node_storage->resetCache(array($this->book->id()));
$node = $node_storage->load($this->book->id());
$this->assertTrue(empty($node->book), 'Deleting childless top-level book node properly allowed.');
// Tests directly deleting a book parent.
$nodes = $this->createBook();
$this->drupalLogin($this->adminUser);
$this->drupalGet($this->book->urlInfo('delete-form'));
$this->assertRaw(t('%title is part of a book outline, and has associated child pages. If you proceed with deletion, the child pages will be relocated automatically.', ['%title' => $this->book->label()]));
// Delete parent, and visit a child page.
$this->drupalPostForm($this->book->urlInfo('delete-form'), [], t('Delete'));
$this->drupalGet($nodes[0]->urlInfo());
$this->assertResponse(200);
$this->assertText($nodes[0]->label());
// The book parents should be updated.
$node_storage = \Drupal::entityTypeManager()->getStorage('node');
$node_storage->resetCache();
$child = $node_storage->load($nodes[0]->id());
$this->assertEqual($child->id(), $child->book['bid'], 'Child node book ID updated when parent is deleted.');
// 3rd-level children should now be 2nd-level.
$second = $node_storage->load($nodes[1]->id());
$this->assertEqual($child->id(), $second->book['bid'], '3rd-level child node is now second level when top-level node is deleted.');
}
function testBookDelete() {
$node_storage = $this->container->get('entity.manager')->getStorage('node');
$nodes = $this->createBook();
$this->drupalLogin($this->adminUser);
$edit = array();
// Test access to delete top-level and child book nodes.
$this->drupalGet('node/' . $this->book->id() . '/outline/remove');
$this->assertResponse('403', 'Deleting top-level book node properly forbidden.');
$this->drupalPostForm('node/' . $nodes[4]->id() . '/outline/remove', $edit, t('Remove'));
$node_storage->resetCache(array($nodes[4]->id()));
$node4 = $node_storage->load($nodes[4]->id());
$this->assertTrue(empty($node4->book), 'Deleting child book node properly allowed.');
// Delete all child book nodes and retest top-level node deletion.
foreach ($nodes as $node) {
$nids[] = $node->id();
}
entity_delete_multiple('node', $nids);
$this->drupalPostForm('node/' . $this->book->id() . '/outline/remove', $edit, t('Remove'));
$node_storage->resetCache(array($this->book->id()));
$node = $node_storage->load($this->book->id());
$this->assertTrue(empty($node->book), 'Deleting childless top-level book node properly allowed.');
// Tests directly deleting a book parent.
$nodes = $this->createBook();
$this->drupalLogin($this->adminUser);
$this->drupalGet($this->book->urlInfo('delete-form'));
$this->assertRaw(t('%title is part of a book outline, and has associated child pages. If you proceed with deletion, the child pages will be relocated automatically.', ['%title' => $this->book->label()]));
// Delete parent, and visit a child page.
$this->drupalPostForm($this->book->urlInfo('delete-form'), [], t('Delete'));
$this->drupalGet($nodes[0]->urlInfo());
$this->assertResponse(200);
$this->assertText($nodes[0]->label());
// The book parents should be updated.
$node_storage = \Drupal::entityTypeManager()->getStorage('node');
$node_storage->resetCache();
$child = $node_storage->load($nodes[0]->id());
$this->assertEqual($child->id(), $child->book['bid'], 'Child node book ID updated when parent is deleted.');
// 3rd-level children should now be 2nd-level.
$second = $node_storage->load($nodes[1]->id());
$this->assertEqual($child->id(), $second->book['bid'], '3rd-level child node is now second level when top-level node is deleted.');
}
/**
* Tests re-ordering of books.
......
......@@ -151,10 +151,10 @@ public function buildForm(array $form, FormStateInterface $form_state, $type = '
'operations' => $this->t('Operations'),
);
$cids = $this->commentStorage->getQuery()
->condition('status', $status)
->tableSort($header)
->pager(50)
->execute();
->condition('status', $status)
->tableSort($header)
->pager(50)
->execute();
/** @var $comments \Drupal\comment\CommentInterface[] */
$comments = $this->commentStorage->loadMultiple($cids);
......
......@@ -111,13 +111,12 @@ public function fetchObjectCallback() {
switch ($this->calls_to_fetch) {
case 1:
return 'something';
break;
case 2:
return 'something-else';
break;
default:
return FALSE;
break;
}
}
......
......@@ -120,7 +120,7 @@ public function getEntity() {
return $this->entity;
}
/**
/**
* Sets the entity instance for this mapper.
*
* This method can only be invoked when the concrete entity is known, that is
......
......@@ -40,8 +40,8 @@ class ContactFormEditForm extends EntityForm implements ContainerInjectionInterf
* The email validator.
*/
public function __construct(EmailValidator $email_validator, PathValidatorInterface $path_validator) {
$this->emailValidator = $email_validator;
$this->pathValidator = $path_validator;
$this->emailValidator = $email_validator;
$this->pathValidator = $path_validator;
}
/**
......
......@@ -23,11 +23,11 @@
'weight',
'selected'
))
->values(array(
->values(array(
'category' => 'Upgrade test',
'recipients' => 'test1@example.com,test2@example.com',
'reply' => 'Test reply',
'weight' => 1,
'selected' => 1,
))
->execute();
->execute();
......@@ -39,7 +39,7 @@ function datetime_help($route_name, RouteMatchInterface $route_match) {
$output .= '<dd>' . t('Dates can be displayed using the <em>Plain</em> or the <em>Default</em> formatter. The <em>Plain</em> formatter displays the date in the <a href="http://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a> format. If you choose the <em>Default</em> formatter, you can choose a format from a predefined list that can be managed on the <a href=":date_format_list">Date and time formats</a> page.', array(':date_format_list' => \Drupal::url('entity.date_format.collection'))) . '</dd>';
$output .= '</dl>';
return $output;
}
}
}
/**
......
......@@ -61,16 +61,16 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
break;
}
switch ($time_type) {
case '24':
$date_part_order = array_merge($date_part_order, array('hour', 'minute'));
break;
case '24':
$date_part_order = array_merge($date_part_order, array('hour', 'minute'));
break;
case '12':
$date_part_order = array_merge($date_part_order, array('hour', 'minute', 'ampm'));
break;
case '12':
$date_part_order = array_merge($date_part_order, array('hour', 'minute', 'ampm'));
break;
case 'none':
break;
case 'none':
break;
}
$element['value'] = array(
......