diff --git a/core/modules/block/block.api.php b/core/modules/block/block.api.php
index c9b3b1f..f1775dc 100644
--- a/core/modules/block/block.api.php
+++ b/core/modules/block/block.api.php
@@ -60,7 +60,7 @@ function hook_block_view_alter(array &$build, \Drupal\block\Plugin\Core\Entity\B
  * @see hook_block_view_alter()
  * @see hook_block_view_NAME_alter()
  */
-function hook_block_view_ID_alter(array &$build, \Drupal\block\BlockInterface $block) {
+function hook_block_view_ID_alter(array &$build, \Drupal\block\Plugin\Core\Entity\Block $block) {
   // This code will only run for a specific block. For example, if ID
   // in the function definition above is set to "someid", the code
   // will only run on the "someid" block.
@@ -89,7 +89,7 @@ function hook_block_view_ID_alter(array &$build, \Drupal\block\BlockInterface $b
  * @see hook_block_view_alter()
  * @see hook_block_view_ID_alter()
  */
-function hook_block_view_NAME_alter(array &$build, \Drupal\block\BlockInterface $block) {
+function hook_block_view_NAME_alter(array &$build, \Drupal\block\Plugin\Core\Entity\Block $block) {
   // This code will only run for a specific block instance. For example, if NAME
   // in the function definition above is set to "someid", the code will only run
   // on the "someid" block.
diff --git a/core/modules/block/lib/Drupal/block/BlockRenderController.php b/core/modules/block/lib/Drupal/block/BlockRenderController.php
index e1c560e..d64b385 100644
--- a/core/modules/block/lib/Drupal/block/BlockRenderController.php
+++ b/core/modules/block/lib/Drupal/block/BlockRenderController.php
@@ -78,9 +78,13 @@ public function viewMultiple(array $entities = array(), $view_mode = 'full', $la
       }
       $build[$entity_id]['content'] = $content;
 
-      // All blocks, even when empty, should be available for altering.
+      // Valid PHP function names cannot contain hyphens.
       $id = str_replace(':', '__', $entity->get('plugin'));
-      list(, $name) = $entity->id();
+      $id = str_replace('-', '_', $id);
+      list(, $name) = explode('.', $entity->id());
+      $name = str_replace('-', '_', $name);
+
+      // All blocks, even when empty, should be available for altering.
       drupal_alter(array('block_view', "block_view_$id", "block_view_$name"), $build[$entity_id], $entity);
 
     }
diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockViewAlterTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockViewAlterTest.php
new file mode 100644
index 0000000..42cf4c5
--- /dev/null
+++ b/core/modules/block/lib/Drupal/block/Tests/BlockViewAlterTest.php
@@ -0,0 +1,50 @@
+<?php
+
+/**
+ * @file
+ * Contains Drupal\block\Tests\BlockViewAlterTest.
+ */
+
+namespace Drupal\block\Tests;
+
+use Drupal\simpletest\WebTestBase;
+
+/**
+ * Tests block HTML ID validity.
+ */
+class BlockViewAlterTest extends WebTestBase {
+
+  /**
+   * Modules to enable.
+   *
+   * @var array
+   */
+  public static $modules = array('block', 'block_test');
+
+  public static function getInfo() {
+    return array(
+      'name' => 'Block view alter hook',
+      'description' => 'Test the hook block view alter hooks.',
+      'group' => 'Block',
+    );
+  }
+
+  function setUp() {
+    parent::setUp();
+
+    $this->drupalLogin($this->root_user);
+  }
+
+  /**
+   * Tests block alter hooks with hyphens.
+   */
+  function testHyphen() {
+    // Enable our test blocks.
+    $this->drupalPlaceBlock('test-id-hyphen', array('machine_name' => 'test-name-hyphen'));
+
+    $this->drupalGet('');
+    $this->assertText('hook_block_view_ID_alter() invoked.');
+    $this->assertText('hook_block_view_NAME_alter() invoked.');
+  }
+
+}
diff --git a/core/modules/block/lib/Drupal/block/Tests/NewDefaultThemeBlocksTest.php b/core/modules/block/lib/Drupal/block/Tests/NewDefaultThemeBlocksTest.php
index f9a7792..72ded9c 100644
--- a/core/modules/block/lib/Drupal/block/Tests/NewDefaultThemeBlocksTest.php
+++ b/core/modules/block/lib/Drupal/block/Tests/NewDefaultThemeBlocksTest.php
@@ -2,7 +2,7 @@
 
 /**
  * @file
- * Definition of Drupal\block\Tests\NewDefaultThemeBlocksTest.
+ * Definition of \Drupal\block\Tests\NewDefaultThemeBlocksTest.
  */
 
 namespace Drupal\block\Tests;
diff --git a/core/modules/block/tests/block_test.module b/core/modules/block/tests/block_test.module
index 6abb95f..4885e12 100644
--- a/core/modules/block/tests/block_test.module
+++ b/core/modules/block/tests/block_test.module
@@ -12,3 +12,17 @@ function block_test_system_theme_info() {
   $themes['block_test_theme'] = drupal_get_path('module', 'block_test') . '/themes/block_test_theme/block_test_theme.info.yml';
   return $themes;
 }
+
+/**
+ * Implements hook_block_view_ID_alter().
+ */
+function block_test_block_view_test_id_hyphen_alter(array &$build, Drupal\block\Plugin\Core\Entity\Block $block) {
+    $build['content']['#children'] .= 'hook_block_view_ID_alter() invoked.';
+}
+
+/**
+ * Implements hook_block_view_NAME_alter().
+ */
+function block_test_block_view_test_name_hyphen_alter(array &$build, Drupal\block\Plugin\Core\Entity\Block $block) {
+    $build['content']['#children'] .= 'hook_block_view_NAME_alter() invoked.';
+}
diff --git a/core/modules/block/tests/lib/Drupal/block_test/Plugin/block/block/TestViewAlterBlock.php b/core/modules/block/tests/lib/Drupal/block_test/Plugin/block/block/TestViewAlterBlock.php
new file mode 100644
index 0000000..0b14489
--- /dev/null
+++ b/core/modules/block/tests/lib/Drupal/block_test/Plugin/block/block/TestViewAlterBlock.php
@@ -0,0 +1,34 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\block_test\Plugin\block\block\TestViewAlterBlock.
+ */
+
+namespace Drupal\block_test\Plugin\block\block;
+
+use Drupal\block\BlockBase;
+use Drupal\Component\Annotation\Plugin;
+use Drupal\Core\Annotation\Translation;
+
+/**
+ * Provides a block to test view alter hooks.
+ *
+ * @Plugin(
+ *   id = "test-id-hyphen",
+ *   admin_label = @Translation("Test block view alter hooks."),
+ *   module = "block_test"
+ * )
+ */
+class TestViewAlterBlock extends BlockBase {
+
+  /**
+   * Implements \Drupal\block\BlockBase::build().
+   */
+  public function build() {
+    return array(
+      '#children' => state()->get('block_test.content'),
+    );
+  }
+
+}
