Commit 2242f4ad authored by xjm's avatar xjm

Issue #2901785 by mfernea, xjm, andriyun: Fix 'Generic.Formatting.SpaceAfterCast' coding standard

parent aa7c4ab0
......@@ -50,7 +50,7 @@ public static function validStep($value, $step, $offset = 0.0) {
// can't be represented with single precision floats are acceptable. The
// fractional part of a float has 24 bits. That means remainders smaller than
// $step * 2^-24 are acceptable.
$computed_acceptable_error = (double)($step / pow(2.0, 24));
$computed_acceptable_error = (double) ($step / pow(2.0, 24));
return $computed_acceptable_error >= $remainder || $remainder >= ($step - $computed_acceptable_error);
}
......
......@@ -66,7 +66,7 @@ public function execute() {
// used twice. However, trying to insert a value into a serial
// column should only be done in very rare cases and is not thread
// safe by definition.
$this->connection->query("SELECT setval('" . $table_information->sequences[$index] . "', GREATEST(MAX(" . $serial_field . "), :serial_value)) FROM {" . $this->table . "}", [':serial_value' => (int)$serial_value]);
$this->connection->query("SELECT setval('" . $table_information->sequences[$index] . "', GREATEST(MAX(" . $serial_field . "), :serial_value)) FROM {" . $this->table . "}", [':serial_value' => (int) $serial_value]);
}
}
}
......
......@@ -60,7 +60,7 @@ public function execute() {
// used twice. However, trying to insert a value into a serial
// column should only be done in very rare cases and is not thread
// safe by definition.
$this->connection->query("SELECT setval('" . $table_information->sequences[$index] . "', GREATEST(MAX(" . $serial_field . "), :serial_value)) FROM {" . $this->table . "}", [':serial_value' => (int)$serial_value]);
$this->connection->query("SELECT setval('" . $table_information->sequences[$index] . "', GREATEST(MAX(" . $serial_field . "), :serial_value)) FROM {" . $this->table . "}", [':serial_value' => (int) $serial_value]);
}
}
}
......
......@@ -156,14 +156,14 @@ public function hasTag($tag) {
* {@inheritdoc}
*/
public function hasAllTags() {
return !(boolean)array_diff(func_get_args(), array_keys($this->alterTags));
return !(boolean) array_diff(func_get_args(), array_keys($this->alterTags));
}
/**
* {@inheritdoc}
*/
public function hasAnyTag() {
return (boolean)array_intersect(func_get_args(), array_keys($this->alterTags));
return (boolean) array_intersect(func_get_args(), array_keys($this->alterTags));
}
/**
......
......@@ -348,14 +348,14 @@ public function hasTag($tag) {
* {@inheritdoc}
*/
public function hasAllTags() {
return !(boolean)array_diff(func_get_args(), array_keys($this->alterTags));
return !(boolean) array_diff(func_get_args(), array_keys($this->alterTags));
}
/**
* {@inheritdoc}
*/
public function hasAnyTag() {
return (boolean)array_intersect(func_get_args(), array_keys($this->alterTags));
return (boolean) array_intersect(func_get_args(), array_keys($this->alterTags));
}
/**
......
......@@ -172,7 +172,7 @@ protected function result() {
}
$return = [];
foreach ($this->sqlQuery->execute() as $row) {
$return[] = (array)$row;
$return[] = (array) $row;
}
return $return;
}
......
......@@ -1186,7 +1186,7 @@ public function setCleanValueKeys(array $cleanValueKeys) {
*/
public function addCleanValueKey($cleanValueKey) {
$keys = $this->getCleanValueKeys();
$this->setCleanValueKeys(array_merge((array)$keys, [$cleanValueKey]));
$this->setCleanValueKeys(array_merge((array) $keys, [$cleanValueKey]));
return $this;
}
......
......@@ -192,12 +192,12 @@ public function commentExists(CommentInterface $comment = NULL, $reply = FALSE)
}
$comment_title = $comment_element[0]->xpath('div/h3/a');
if (empty($comment_title) || ((string)$comment_title[0]) !== $comment->getSubject()) {
if (empty($comment_title) || ((string) $comment_title[0]) !== $comment->getSubject()) {
return FALSE;
}
$comment_body = $comment_element[0]->xpath('div/div/p');
if (empty($comment_body) || ((string)$comment_body[0]) !== $comment->comment_body->value) {
if (empty($comment_body) || ((string) $comment_body[0]) !== $comment->comment_body->value) {
return FALSE;
}
......
......@@ -108,7 +108,7 @@ public function setMessage($message) {
* {@inheritdoc}
*/
public function copySender() {
return (bool)$this->get('copy')->value;
return (bool) $this->get('copy')->value;
}
/**
......
......@@ -333,7 +333,7 @@ public static function generateSampleValue(FieldDefinitionInterface $field_defin
$file = file_save_data($data, $destination, FILE_EXISTS_ERROR);
$values = [
'target_id' => $file->id(),
'display' => (int)$settings['display_default'],
'display' => (int) $settings['display_default'],
'description' => $random->sentences(10),
];
return $values;
......
......@@ -51,7 +51,7 @@ public function readNode(Request $request, NodeInterface $node) {
// Update the history table, stating that this user viewed this node.
history_write($node->id());
return new JsonResponse((int)history_read($node->id()));
return new JsonResponse((int) history_read($node->id()));
}
}
......@@ -114,7 +114,7 @@ public function testNodeAccessBasic() {
$this->drupalPostForm('node/add/article', $edit, t('Save'));
$node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
$this->assertEqual($is_private, (int)$node->private->value, 'The private status of the node was properly set in the node_access_test table.');
$this->assertEqual($is_private, (int) $node->private->value, 'The private status of the node was properly set in the node_access_test table.');
if ($is_private) {
$private_nodes[] = $node->id();
}
......
......@@ -71,7 +71,7 @@ protected function initAuthentication() {
$this->sessionCookie = explode(';', $response->getHeader('Set-Cookie')[0], 2)[0];
// Parse and store the CSRF token and logout token.
$data = $this->serializer->decode((string)$response->getBody(), static::$format);
$data = $this->serializer->decode((string) $response->getBody(), static::$format);
$this->csrfToken = $data['csrf_token'];
$this->logoutToken = $data['logout_token'];
}
......
......@@ -131,7 +131,7 @@ public function resetDayCount() {
public function maxTotalCount() {
$query = $this->connection->select('node_counter', 'nc');
$query->addExpression('MAX(totalcount)');
$max_total_count = (int)$query->execute()->fetchField();
$max_total_count = (int) $query->execute()->fetchField();
return $max_total_count;
}
......
......@@ -190,7 +190,7 @@ public function generateResultsKey() {
$query = clone $build_info[$index];
$query->preExecute();
$build_info[$index] = [
'query' => (string)$query,
'query' => (string) $query,
'arguments' => $query->getArguments(),
];
}
......
......@@ -1758,7 +1758,7 @@ public function access($displays = NULL, $account = NULL) {
// We can't use choose_display() here because that function
// calls this one.
$displays = (array)$displays;
$displays = (array) $displays;
foreach ($displays as $display_id) {
if ($this->displayHandlers->has($display_id)) {
if (($display = $this->displayHandlers->get($display_id)) && $display->access($account)) {
......
......@@ -113,6 +113,7 @@
<!-- Generic sniffs -->
<rule ref="Generic.Files.ByteOrderMark"/>
<rule ref="Generic.Files.LineEndings"/>
<rule ref="Generic.Formatting.SpaceAfterCast"/>
<rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
<rule ref="Generic.NamingConventions.ConstructorName"/>
<rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
......
......@@ -30,7 +30,7 @@ class PlaceholderGeneratorTest extends RendererTestBase {
public function testCreatePlaceholderGeneratesValidHtmlMarkup(array $element) {
$build = $this->placeholderGenerator->createPlaceholder($element);
$original_placeholder_markup = (string)$build['#markup'];
$original_placeholder_markup = (string) $build['#markup'];
$processed_placeholder_markup = Html::serialize(Html::load($build['#markup']));
$this->assertEquals($original_placeholder_markup, $processed_placeholder_markup);
......
......@@ -85,14 +85,14 @@ public function testEntitySafePrefixes() {
->with('test')
->willReturn(TRUE);
$result = $this->twig->render('{{ entity.hasLinkTemplate("test") }}', ['entity' => $entity]);
$this->assertTrue((bool)$result, 'Sandbox policy allows has* functions to be called.');
$this->assertTrue((bool) $result, 'Sandbox policy allows has* functions to be called.');
$entity = $this->getMock('Drupal\Core\Entity\EntityInterface');
$entity->expects($this->atLeastOnce())
->method('isNew')
->willReturn(TRUE);
$result = $this->twig->render('{{ entity.isNew }}', ['entity' => $entity]);
$this->assertTrue((bool)$result, 'Sandbox policy allows is* functions to be called.');
$this->assertTrue((bool) $result, 'Sandbox policy allows is* functions to be called.');
$entity = $this->getMock('Drupal\Core\Entity\EntityInterface');
$entity->expects($this->atLeastOnce())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment