diff --git a/core/lib/Drupal/Component/Utility/Number.php b/core/lib/Drupal/Component/Utility/Number.php
index 39143d93aa..838c33c454 100644
--- a/core/lib/Drupal/Component/Utility/Number.php
+++ b/core/lib/Drupal/Component/Utility/Number.php
@@ -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);
   }
diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Insert.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Insert.php
index 45c7a47ea6..3310547969 100644
--- a/core/lib/Drupal/Core/Database/Driver/pgsql/Insert.php
+++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Insert.php
@@ -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]);
           }
         }
       }
diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/NativeUpsert.php b/core/lib/Drupal/Core/Database/Driver/pgsql/NativeUpsert.php
index 8cb2ce7760..bb4e68cc7b 100644
--- a/core/lib/Drupal/Core/Database/Driver/pgsql/NativeUpsert.php
+++ b/core/lib/Drupal/Core/Database/Driver/pgsql/NativeUpsert.php
@@ -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]);
           }
         }
       }
diff --git a/core/lib/Drupal/Core/Database/Query/Select.php b/core/lib/Drupal/Core/Database/Query/Select.php
index b3426e6d4d..6ea96816de 100644
--- a/core/lib/Drupal/Core/Database/Query/Select.php
+++ b/core/lib/Drupal/Core/Database/Query/Select.php
@@ -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));
   }
 
   /**
diff --git a/core/lib/Drupal/Core/Entity/Query/QueryBase.php b/core/lib/Drupal/Core/Entity/Query/QueryBase.php
index ed3d12b2c8..38deabd8db 100644
--- a/core/lib/Drupal/Core/Entity/Query/QueryBase.php
+++ b/core/lib/Drupal/Core/Entity/Query/QueryBase.php
@@ -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));
   }
 
   /**
diff --git a/core/lib/Drupal/Core/Entity/Query/Sql/QueryAggregate.php b/core/lib/Drupal/Core/Entity/Query/Sql/QueryAggregate.php
index 2d2aacfdf3..c791bb5552 100644
--- a/core/lib/Drupal/Core/Entity/Query/Sql/QueryAggregate.php
+++ b/core/lib/Drupal/Core/Entity/Query/Sql/QueryAggregate.php
@@ -172,7 +172,7 @@ protected function result() {
     }
     $return = [];
     foreach ($this->sqlQuery->execute() as $row) {
-      $return[] = (array)$row;
+      $return[] = (array) $row;
     }
     return $return;
   }
diff --git a/core/lib/Drupal/Core/Form/FormState.php b/core/lib/Drupal/Core/Form/FormState.php
index b78efb30d1..5585a76234 100644
--- a/core/lib/Drupal/Core/Form/FormState.php
+++ b/core/lib/Drupal/Core/Form/FormState.php
@@ -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;
   }
 
diff --git a/core/modules/comment/src/Tests/CommentTestBase.php b/core/modules/comment/src/Tests/CommentTestBase.php
index e15915ff93..b09d402b5a 100644
--- a/core/modules/comment/src/Tests/CommentTestBase.php
+++ b/core/modules/comment/src/Tests/CommentTestBase.php
@@ -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;
       }
 
diff --git a/core/modules/contact/src/Entity/Message.php b/core/modules/contact/src/Entity/Message.php
index 193687087d..b1086602d8 100644
--- a/core/modules/contact/src/Entity/Message.php
+++ b/core/modules/contact/src/Entity/Message.php
@@ -108,7 +108,7 @@ public function setMessage($message) {
    * {@inheritdoc}
    */
   public function copySender() {
-    return (bool)$this->get('copy')->value;
+    return (bool) $this->get('copy')->value;
   }
 
   /**
diff --git a/core/modules/file/src/Plugin/Field/FieldType/FileItem.php b/core/modules/file/src/Plugin/Field/FieldType/FileItem.php
index 7373c4397f..542be122df 100644
--- a/core/modules/file/src/Plugin/Field/FieldType/FileItem.php
+++ b/core/modules/file/src/Plugin/Field/FieldType/FileItem.php
@@ -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;
diff --git a/core/modules/history/src/Controller/HistoryController.php b/core/modules/history/src/Controller/HistoryController.php
index 6a4e80a238..c6a4834903 100644
--- a/core/modules/history/src/Controller/HistoryController.php
+++ b/core/modules/history/src/Controller/HistoryController.php
@@ -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()));
   }
 
 }
diff --git a/core/modules/node/tests/src/Functional/NodeAccessBaseTableTest.php b/core/modules/node/tests/src/Functional/NodeAccessBaseTableTest.php
index 5b99ccf68e..d9e4e8b092 100644
--- a/core/modules/node/tests/src/Functional/NodeAccessBaseTableTest.php
+++ b/core/modules/node/tests/src/Functional/NodeAccessBaseTableTest.php
@@ -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();
         }
diff --git a/core/modules/rest/tests/src/Functional/CookieResourceTestTrait.php b/core/modules/rest/tests/src/Functional/CookieResourceTestTrait.php
index 8975c3fa28..3b7c3b4862 100644
--- a/core/modules/rest/tests/src/Functional/CookieResourceTestTrait.php
+++ b/core/modules/rest/tests/src/Functional/CookieResourceTestTrait.php
@@ -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'];
   }
diff --git a/core/modules/statistics/src/NodeStatisticsDatabaseStorage.php b/core/modules/statistics/src/NodeStatisticsDatabaseStorage.php
index 0cccb1700b..dcb69833e8 100644
--- a/core/modules/statistics/src/NodeStatisticsDatabaseStorage.php
+++ b/core/modules/statistics/src/NodeStatisticsDatabaseStorage.php
@@ -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;
   }
 
diff --git a/core/modules/views/src/Plugin/views/cache/CachePluginBase.php b/core/modules/views/src/Plugin/views/cache/CachePluginBase.php
index 36b8e19c9c..e6c8c15c3d 100644
--- a/core/modules/views/src/Plugin/views/cache/CachePluginBase.php
+++ b/core/modules/views/src/Plugin/views/cache/CachePluginBase.php
@@ -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(),
           ];
         }
diff --git a/core/modules/views/src/ViewExecutable.php b/core/modules/views/src/ViewExecutable.php
index b8e7346b7c..82c1cb9832 100644
--- a/core/modules/views/src/ViewExecutable.php
+++ b/core/modules/views/src/ViewExecutable.php
@@ -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)) {
diff --git a/core/phpcs.xml.dist b/core/phpcs.xml.dist
index 8475e3f0fe..1f4360c48d 100644
--- a/core/phpcs.xml.dist
+++ b/core/phpcs.xml.dist
@@ -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"/>
diff --git a/core/tests/Drupal/Tests/Core/Render/PlaceholderGeneratorTest.php b/core/tests/Drupal/Tests/Core/Render/PlaceholderGeneratorTest.php
index 3e80a3f2e1..ce0f1518c5 100644
--- a/core/tests/Drupal/Tests/Core/Render/PlaceholderGeneratorTest.php
+++ b/core/tests/Drupal/Tests/Core/Render/PlaceholderGeneratorTest.php
@@ -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);
diff --git a/core/tests/Drupal/Tests/Core/Template/TwigSandboxTest.php b/core/tests/Drupal/Tests/Core/Template/TwigSandboxTest.php
index 1bbb9f4dd1..cf39a8bb3a 100644
--- a/core/tests/Drupal/Tests/Core/Template/TwigSandboxTest.php
+++ b/core/tests/Drupal/Tests/Core/Template/TwigSandboxTest.php
@@ -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())
