diff --git a/book_access.api.php b/book_access.api.php
index 0e96413..be0e9e6 100644
--- a/book_access.api.php
+++ b/book_access.api.php
@@ -1,11 +1,12 @@
 <?php
 
-use Drupal\Core\Session\AccountInterface;
 /**
  * @file
  * Hooks provided by the Book access module.
  */
 
+use Drupal\Core\Session\AccountInterface;
+
 /**
  * @addtogroup hooks
  * @{
diff --git a/book_access.module b/book_access.module
index b2618e9..d3c04ee 100644
--- a/book_access.module
+++ b/book_access.module
@@ -2,6 +2,7 @@
 
 /**
  * @file
+ * Module book_access.
  */
 
 use Drupal\user\UserInterface;
@@ -35,15 +36,24 @@ function book_access_node_insert(NodeInterface $node) {
   // @FIXME
   // Could not extract the default value because it is either indeterminate, or
   // not scalar. You'll need to provide a default value in
-  // config/install/book_access.settings.yml and config/schema/book_access.schema.yml.
+  // config/install/book_access.settings.yml and
+  // config/schema/book_access.schema.yml.
   // @FIXME
   // Could not extract the default value because it is either indeterminate, or
   // not scalar. You'll need to provide a default value in
-  // config/install/book_access.settings.yml and config/schema/book_access.schema.yml.
+  // config/install/book_access.settings.yml and
+  // config/schema/book_access.schema.yml.
   BookAccess::setAuthorGrants(
   $node->book['bid'],
   $node->getOwnerId(),
-  array_combine($node->getOwnerId() == 0 ? BookAccess::defaultGrants() : \Drupal::config('book_access.settings')->get("book_access_default_author_access"), $node->getOwnerId() == 0 ? BookAccess::defaultGrants() : \Drupal::config('book_access.settings')->get("book_access_default_author_access"))
+  array_combine($node->getOwnerId() == 0 ?
+  BookAccess::defaultGrants() :
+  \Drupal::config('book_access.settings')->
+  get("book_access_default_author_access"),
+  $node->getOwnerId() == 0 ?
+  BookAccess::defaultGrants() :
+  \Drupal::config('book_access.settings')->
+  get("book_access_default_author_access"))
   );
 
   $roles = user_roles();
@@ -53,7 +63,8 @@ function book_access_node_insert(NodeInterface $node) {
   // // @FIXME
   // // The correct configuration object could not be determined. You'll need to
   // // rewrite this call manually.
-  // $roleDefaults = variable_get( "book_access_default_role_{$rid}_access", array());
+  // $roleDefaults = variable_get(
+  "book_access_default_role_{$rid}_access", array());
 
   foreach ($roleDefaults as $default) {
   $roleGrants[$default][$rid] = TRUE;
@@ -69,61 +80,73 @@ function book_access_node_insert(NodeInterface $node) {
  * Makes sure defaults propagate to pages that have been 'upgraded' to a book.
  */
 function book_access_node_update(NodeInterface $node) {
- /* if (isset($node->book['bid']) && $node->book['bid']) {
-    // Check for existing permissions
-    //    $rowCount = \Drupal::database()->select('book_access_author', 'book_access_author')
-    //      ->condition( 'nid', $node->book['bid'], '=')
-    //      ->condition( 'uid', $node->getOwnerId())
-    //      ->countQuery()
-    //      ->execute()
-    //      ->fetchField();
-    if ($rowCount == 0) {
-      // @FIXME
-      // Could not extract the default value because it is either indeterminate, or
-      // not scalar. You'll need to provide a default value in
-      // config/install/book_access.settings.yml and config/schema/book_access.schema.yml.
-      // @FIXME
-      // Could not extract the default value because it is either indeterminate, or
-      // not scalar. You'll need to provide a default value in
-      // config/install/book_access.settings.yml and config/schema/book_access.schema.yml.
-      // BookAccess::setAuthorGrants(
-      //        $node->book['bid'],
-      //        $node->getOwnerId(),
-      //        array_combine($node->getOwnerId() == 0 ? BookAccess::defaultGrants() : \Drupal::config('book_access.settings')->get("book_access_default_author_access"), $node->getOwnerId() == 0 ? BookAccess::defaultGrants() : \Drupal::config('book_access.settings')->get("book_access_default_author_access"))
-      //      );
-    }
+  /* if (isset($node->book['bid']) && $node->book['bid']) {
+  // Check for existing permissions
+  //    $rowCount = \Drupal::database()->
+  // select('book_access_author', 'book_access_author')
+  //      ->condition( 'nid', $node->book['bid'], '=')
+  //      ->condition( 'uid', $node->getOwnerId())
+  //      ->countQuery()
+  //      ->execute()
+  //      ->fetchField();
+  if ($rowCount == 0) {
+  // @FIXME
+  // Could not extract the default value because it is either indeterminate, or
+  // not scalar. You'll need to provide a default value in
+  // config/install/book_access.settings.yml and
+  // config/schema/book_access.schema.yml.
+  // @FIXME
+  // Could not extract the default value because it is either indeterminate, or
+  // not scalar. You'll need to provide a default value in
+  // config/install/book_access.settings.yml and
+  // config/schema/book_access.schema.yml.
+  // BookAccess::setAuthorGrants(
+  //        $node->book['bid'],
+  //        $node->getOwnerId(),
+  //        array_combine($node->getOwnerId() == 0 ?
+  // BookAccess::defaultGrants() :
+  // \Drupal::config('book_access.settings')->
+  // get("book_access_default_author_access"),
+  // $node->getOwnerId() == 0 ? BookAccess::defaultGrants() :
+  // \Drupal::config('book_access.settings')->
+  // get("book_access_default_author_access"))
+  //      );
+  }
 
-    $roles = user_roles();
-    $rids = array_keys($roles);
-    $roleResultSet = \Drupal::database()->select('book_access_role', 'book_access_role')
-      ->condition('nid', $node->book['bid'], '=')
-      ->condition('rid', $rids, 'IN')
-      ->fields('book_access_role', ['rid'])
-      ->distinct()
-      ->execute();
-    if ($roleResultSet->rowCount() < count($rids)) {
-      // Fill in the missing ones.
-      $existingRids = [];
-      foreach ($roleResultSet as $row) {
-        $existingRids[] = $row->rid;
-      }
+  $roles = user_roles();
+  $rids = array_keys($roles);
+  $roleResultSet = \Drupal::database()->
+  // select('book_access_role', 'book_access_role')
+  ->condition('nid', $node->book['bid'], '=')
+  ->condition('rid', $rids, 'IN')
+  ->fields('book_access_role', ['rid'])
+  ->distinct()
+  ->execute();
+  if ($roleResultSet->rowCount() < count($rids)) {
+  // Fill in the missing ones.
+  $existingRids = [];
+  foreach ($roleResultSet as $row) {
+  $existingRids[] = $row->rid;
+  }
 
-      $missingRids = array_diff($rids, $existingRids);
-      foreach ($missingRids as $rid) {
-        // @FIXME
-        // // @FIXME
-        // // The correct configuration object could not be determined. You'll need to
-        // // rewrite this call manually.
-        // $defaultToUse = variable_get( "book_access_role_{$rid}_default");
-        if ($defaultToUse !== NULL) {
-          $roleDefaults = [];
-          foreach ($defaultToUse as $grant) {
-            $roleDefaults[$grant] = $rid;
-          }
-          // BookAccess::addRoleGrants( $node->book['bid'], array($rid), $roleDefaults);.
-        }
-      }
-    }
+  $missingRids = array_diff($rids, $existingRids);
+  foreach ($missingRids as $rid) {
+  // @FIXME
+  // // @FIXME
+  // // The correct configuration object could not be determined.
+  // You'll need to
+  // // rewrite this call manually.
+  // $defaultToUse = variable_get( "book_access_role_{$rid}_default");
+  if ($defaultToUse !== NULL) {
+  $roleDefaults = [];
+  foreach ($defaultToUse as $grant) {
+  $roleDefaults[$grant] = $rid;
+  }
+  // BookAccess::addRoleGrants( $node->book['bid'],
+  // array($rid), $roleDefaults);.
+  }
+  }
+  }
   }*/
 }
 
@@ -135,7 +158,7 @@ function book_access_node_update(NodeInterface $node) {
  * @see book_access_edit_form_submit()
  */
 function book_access_form_alter(&$form, FormStateInterface &$form_state, $form_id) {
-  /* @var \Drupal\book_access\BookAccessHelper $bookAccessHelper */
+  /** @var \Drupal\book_access\BookAccessHelper $bookAccessHelper */
   $bookAccessHelper = \Drupal::service('book_access.book_access_helper');
   if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] . '_node_form' == $form_id) {
     if (isset($form['book']['bid']['#options'])) {
@@ -203,7 +226,10 @@ function book_access_form_alter(&$form, FormStateInterface &$form_state, $form_i
         $form['bad_fs']['book_access_defaults'][$id][$grant_type] = [
           '#type' => 'checkbox',
           '#title' => t('%role_label %grant_type',
-            ['%role_label' => $role_default['label'], '%grant_type' => $grant_type]),
+            [
+              '%role_label' => $role_default['label'],
+              '%grant_type' => $grant_type,
+            ]),
           '#title_display' => 'invisible',
           '#default_value' => $grant,
         ];
@@ -217,7 +243,9 @@ function book_access_form_alter(&$form, FormStateInterface &$form_state, $form_i
  * Submit handler for book_admin_settings form.
  *
  * @param array $form
+ *   Form.
  * @param \Drupal\Core\Form\FormStateInterface $form_state
+ *   Form state.
  */
 function book_access_admin_settings_submit(array $form, FormStateInterface $form_state) {
   if ($form['#id'] == 'book-admin-settings' && $form_state->hasValue('book_access_defaults')) {
@@ -228,6 +256,8 @@ function book_access_admin_settings_submit(array $form, FormStateInterface $form
 }
 
 /**
+ * Implements hook_menu_alter().
+ *
  * @FIXME
  * hook_menu_alter() is gone in Drupal 8. You will have to port its
  * functionality manually. The are several mechanisms for this:
@@ -256,11 +286,13 @@ function book_access_admin_settings_submit(array $form, FormStateInterface $form
  */
 function book_access_menu_alter(&$items) {
   /*  if (isset($items['node/%node/outline'])) {
-  $items['node/%node/outline']['access callback'] = '_book_access_outline_access';
+  $items['node/%node/outline']['access callback'] =
+  'bookAccessOutlineAccess';
   }
 
   if (isset($items['node/%node/outline/remove'])) {
-  $items['node/%node/outline/remove']['access callback'] = '_book_access_outline_remove_access';
+  $items['node/%node/outline/remove']['access callback'] =
+  'bookAccessOutlineRemoveAccess';
   }*/
 }
 
@@ -302,23 +334,24 @@ function book_access_node_view_alter(&$build) {
     if (!empty($links['book_add_child'])) {
       // @FIXME
       // // @FIXME
-      // // This looks like another module's variable. You'll need to rewrite this call
+      // // This looks like another module's variable.
+      // You'll need to rewrite this call
       // // to ensure that it uses the correct configuration object.
       // $bool = (
-      //         (
-      //           (
-      //             \Drupal::currentUser()->hasPermission('add content to books') &&
-      //             BookAccess::checkGrant($node->book['bid'], 'add_child')
-      //           ) ||
-      //           \Drupal::currentUser()->hasPermission('administer book outlines')
-      //         ) &&
-      //         node_access('create', variable_get('book_child_type', 'book')) &&
-      //         ($node->status == 1) &&
-      //         ($node->book['depth'] < MENU_MAX_DEPTH)
-      //       );
-      //      if (!$bool) {
-      //        unset($links['book_add_child']);
-      //      }
+      // (
+      // (
+      // \Drupal::currentUser()->hasPermission('add content to books') &&
+      // BookAccess::checkGrant($node->book['bid'], 'add_child')
+      // ) ||
+      // \Drupal::currentUser()->hasPermission('administer book outlines')
+      // ) &&
+      // node_access('create', variable_get('book_child_type', 'book')) &&
+      // ($node->status == 1) &&
+      // ($node->book['depth'] < MENU_MAX_DEPTH)
+      // );
+      // if (!$bool) {
+      // unset($links['book_add_child']);
+      // }
     }
   }
 }
@@ -360,7 +393,8 @@ function book_access_node_access_explain($row) {
   }
   }
   elseif ($row->realm == 'book_access_user') {
-  if ($user = \Drupal::entityTypeManager()->getStorage('user')->load($row->gid)) {
+  if ($user = \Drupal::entityTypeManager()->
+  getStorage('user')->load($row->gid)) {
   $result = array(
   t('Grants for user %username',
   array('%username' => $user->name)
@@ -444,7 +478,8 @@ function book_access_edit_form_submit($form, &$form_state) {
  * @see book_access_form_alter()
  */
 function book_access_outline_form_submit($form, &$form_state) {
-  /*  if (isset($form['plid']) && $form['plid'] != $form_state['values']['plid']) {
+  /*  if (isset($form['plid']) && $form['plid']
+  != $form_state['values']['plid']) {
   BookAccess::writeGrantRecords($form['#node']);
   }*/
 }
diff --git a/src/Access/BookAccess.php b/src/Access/BookAccess.php
index d184870..2425e91 100644
--- a/src/Access/BookAccess.php
+++ b/src/Access/BookAccess.php
@@ -1,18 +1,25 @@
 <?php
+
 namespace Drupal\book_access\Access;
 
+use Drupal\Core\Session\AccountInterface;
 use Drupal\Core\Entity\EntityAccessControlHandler;
 use Drupal\Core\Entity\EntityHandlerInterface;
 use Drupal\Core\Entity\EntityTypeInterface;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 
 /**
- * @file
- *
- * Allows to set the access control for book nodes on a per book basis.
+ * The class BookAccess.
  */
-
 final class BookAccess extends EntityAccessControlHandler implements EntityHandlerInterface {
+
+  /**
+   * The current user.
+   *
+   * @var \Drupal\Core\Session\AccountInterface
+   */
+  protected $currentUser;
+
   /**
    * The minimum API version with which the module is compatible.
    */
@@ -23,14 +30,35 @@ final class BookAccess extends EntityAccessControlHandler implements EntityHandl
    */
   const API_VERSION = '2.5';
 
+  /**
+   * Creates an NodeViewController object.
+   *
+   * @param \Drupal\Core\Session\AccountInterface $current_user
+   *   The current user.
+   */
+  public function __construct(
+    AccountInterface $current_user = NULL
+  ) {
+    $this->currentUser = $current_user;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function create(ContainerInterface $container) {
+    return new static(
+      $container->get('current_user')
+    );
+  }
+
   /**
    * Adds author grants to book pages.
    *
-   * @param $bid
+   * @param string $bid
    *   The book ID.
-   * @param $uid
+   * @param string $uid
    *   The user ID of the book author.
-   * @param $grants
+   * @param array $grants
    *   An array of grants, in the format @code $grants[$grant] @endcode,
    *   where @code $grant @endcode is a string between 'grant_view',
    *   'grant_update', 'grant_delete', 'grant_admin_access', 'grant_add_child',
@@ -43,23 +71,23 @@ final class BookAccess extends EntityAccessControlHandler implements EntityHandl
 
     $bool = db_query_range(
       "SELECT 1 FROM {book_access_author} WHERE nid = :nid AND uid = :uid",
-      0, 1, array(':nid' => $bid, ':uid' => $uid))->fetchField();
+      0, 1, [':nid' => $bid, ':uid' => $uid])->fetchField();
 
     foreach (self::grantIDs() as $id) {
       $row->$id = !empty($grants[$id]);
     }
 
-    drupal_write_record('book_access_author', $row, $bool ? array('nid', 'uid') : array());
+    drupal_write_record('book_access_author', $row, $bool ? ['nid', 'uid'] : []);
   }
 
   /**
    * Adds role grants to book pages.
    *
-   * @param $bid
+   * @param string $bid
    *   The book ID.
-   * @param $rids
+   * @param array $rids
    *   An array of role IDs for which to add the book grants.
-   * @param $grants
+   * @param array $grants
    *   An array of grants, in the format @code $grants[$grant][$rid] @endcode,
    *   where @code $grant @endcode is a string between 'grant_view',
    *   'grant_update', 'grant_delete', 'grant_admin_access', 'grant_add_child',
@@ -74,29 +102,31 @@ final class BookAccess extends EntityAccessControlHandler implements EntityHandl
 
       $bool = db_query_range(
           "SELECT 1 FROM {book_access_role} WHERE nid = :nid AND rid = :rid",
-          0, 1, array(':nid' => $bid, ':rid' => $rid)
+          0, 1, [':nid' => $bid, ':rid' => $rid]
         )->fetchField();
 
       $granted = 0;
       foreach (self::grantIDs() as $id) {
         $row->$id = !empty($grants[$id][$rid]);
-        if ($row->$id != 0)
+        if ($row->$id != 0) {
           $granted++;
+        }
       }
 
-      if ($granted > 0)
-        drupal_write_record('book_access_role', $row, $bool ? array('nid', 'rid') : array());
+      if ($granted > 0) {
+        drupal_write_record('book_access_role', $row, $bool ? ['nid', 'rid'] : []);
+      }
     }
   }
 
   /**
    * Adds user grants to book pages.
    *
-   * @param $bid
+   * @param string $bid
    *   The book ID.
-   * @param $uids
+   * @param array $uids
    *   An array of user IDs for which to add the book grants.
-   * @param $grants
+   * @param array $grants
    *   An array of grants, in the format @code $grants[$grant][$uid] @endcode,
    *   where @code $grant @endcode is a string between 'grant_view',
    *   'grant_update', 'grant_delete', 'grant_admin_access', 'grant_add_child',
@@ -106,7 +136,7 @@ final class BookAccess extends EntityAccessControlHandler implements EntityHandl
     foreach ($uids as $uid) {
       $bool = db_query_range(
         "SELECT 1 FROM {book_access_user} WHERE nid = :nid AND uid = :uid",
-        0, 1, array(':nid' => $bid, ':uid' => $uid)
+        0, 1, [':nid' => $bid, ':uid' => $uid]
       )->fetchField();
 
       $row = new stdClass();
@@ -117,22 +147,23 @@ final class BookAccess extends EntityAccessControlHandler implements EntityHandl
         $row->$id = !empty($grants[$id][$uid]);
       }
 
-      drupal_write_record('book_access_user', $row, $bool ? array('nid', 'uid') : array());
+      drupal_write_record('book_access_user', $row, $bool ? ['nid', 'uid'] : []);
     }
   }
 
   /**
-   * Verifies the current API version is included between two values passed as
-   * arguments.
+   * Verifies the current API version is included.
+   *
+   * Between two values passed as arguments.
    *
-   * @param $minimum
+   * @param string $minimum
    *   The minimum API version required. If the parameter is not passed, the
    *   method will use the constant API_COMPATIBLE_VERSION.
-   * @param $maximum
+   * @param string $maximum
    *   The maximum version required. This argument is optional; the current API
    *   will be checked against this value only if it is passed to the function.
    *
-   * @return
+   * @return bool
    *   TRUE, if the current API version is included between the passed values.
    */
   public static function api($minimum = NULL, $maximum = NULL) {
@@ -154,88 +185,94 @@ final class BookAccess extends EntityAccessControlHandler implements EntityHandl
   /**
    * Checks if a user has access to the book passed as argument.
    *
-   * @param $bid
+   * @param string $bid
    *   The ID of the book to check.
-   * @param $grant
+   * @param string $grant
    *   The permission to check for.  Can either be in the form "grant_update" or
    *   "update" though the former is now preferred for consistency.
-   * @param $account
-   *   The user account for which the permission is checked; if it is not passed,
-   *   the permission is checked against the current logged in user.
+   * @param string $account
+   *   The user account for which the permission is checked.
+   *   If it is not passed, the permission is checked
+   *   against the current logged in user.
    *
-   * @return
+   * @return bool
    *   TRUE if the user has the permission, FALSE otherwise.
    */
   public static function checkGrant($bid, $grant, $account = NULL) {
     static $queries = NULL;
     if ($queries == NULL) {
-      $queries = array(
+      $queries = [
         "book_access_author",
         "book_access_role",
         "book_access_user",
-      );
+      ];
     }
 
     if (!isset($account)) {
       $account = \Drupal::currentUser();
     }
 
-    if (! preg_match( '/^grant_/', $grant)) {
+    if (!preg_match('/^grant_/', $grant)) {
       $grant = "grant_$grant";
     }
 
     $roles = array_keys($account->roles);
 
-    $resultSets = array();
+    $resultSets = [];
     foreach ($queries as $table) {
       $queryObj = \Drupal::database()->select($table, $table);
       $queryObj
-        ->condition( "nid", $bid, "=");
+        ->condition("nid", $bid, "=");
       if ($table == 'book_access_role') {
-        $queryObj->condition( "rid", $roles, "IN");
+        $queryObj->condition("rid", $roles, "IN");
       }
       else {
-        $queryObj->condition( "uid", $account->uid, "=");
+        $queryObj->condition("uid", $account->uid, "=");
       }
       $queryObj
-        ->fields( $table, array( $grant))
-        ->orderBy( $grant, 'DESC') // for role-based queries, we want to enable where possible
-        ->range( 0, 1);
+        ->fields($table, [$grant])
+      // For role-based queries, we want to enable where possible.
+        ->orderBy($grant, 'DESC')
+        ->range(0, 1);
       $resultSets[$table] = $queryObj->execute();
     }
 
     $rowCount = 0;
     $grantCount = 0;
-    $explicitTables = array();
+    $explicitTables = [];
     foreach ($resultSets as $table => $resultSet) {
       if ($resultSet->rowCount() > 0) {
         $row = $resultSet->fetchAssoc();
         $explicitTables[$table] = TRUE;
         ++$rowCount;
-        $grantCount += (int)$row[$grant];
+        $grantCount += (int) $row[$grant];
       }
     }
     $hasPermission = $grantCount > 0;
 
-    // if our row count is less than 3, that means taht we are missing an explicit
-    // permissions entry in one of the tables.  iterate and find the missing ones
+    // If our row count is less than 3,
+    // that means taht we are missing an explicit
+    // permissions entry in one of the tables.
+    // iterate and find the missing ones
     // and check the defaults instead.
-    if (! $hasPermission && $rowCount < 3) {
+    if (!$hasPermission && $rowCount < 3) {
       $node = \Drupal::service('entity_type.manager')->getStorage('node')->load($bid);
 
-      // check default author permissions first
-      if (! isset($explicitTables['book_access_author'])) {
-        $authorDefaults = variable_get( "book_access_default_author_access");
+      // Check default author permissions first.
+      if (!isset($explicitTables['book_access_author'])) {
+        $authorDefaults = variable_get("book_access_default_author_access");
 
-        $hasPermission = ($account->uid == $node->uid && in_array( $grant, $authorDefaults));
+        $hasPermission = ($account->uid == $node->uid && in_array($grant, $authorDefaults));
       }
 
-      // then, failing that, check default role permissions
-      if (! $hasPermission && ! isset( $explicitTables['book_access_role'])) {
+      // then, failing that, check default role permissions.
+      if (!$hasPermission && !isset($explicitTables['book_access_role'])) {
         foreach ($roles as $role) {
-          $roleDefaults = variable_get( "book_access_default_role_{$role}_access");
-          $hasPermission = in_array( $grant, $roleDefaults);
-          if ($hasPermission) break;
+          $roleDefaults = variable_get("book_access_default_role_{$role}_access");
+          $hasPermission = in_array($grant, $roleDefaults);
+          if ($hasPermission) {
+            break;
+          }
         }
       }
     }
@@ -249,19 +286,19 @@ final class BookAccess extends EntityAccessControlHandler implements EntityHandl
    * NOTE: once a grant has been created, it is merely set to 0 to avoid using
    * defaults.
    *
-   * @param $value
+   * @param string $value
    *   The value to look for.
-   * param $field
+   * @param string $field
    *   The database field where to look the value. The currently accepted
    *   values are 'bid', 'nid', 'uid', 'rid'.
-   * @param $types
+   * @param array $types
    *   An array of grants types for which the function deletes records; the
    *   currently used values are 'author', 'role', 'user'. When this parameter
    *   is not passed, the method cues off the $field setting.
    */
   public static function deleteGrants($value, $field = 'nid', array $types = NULL) {
     if (isset($types)) {
-      $tables = array();
+      $tables = [];
       foreach ($types as $type) {
         switch ($type) {
           case 'author':
@@ -276,33 +313,37 @@ final class BookAccess extends EntityAccessControlHandler implements EntityHandl
       switch ($field) {
         case 'bid':
         case 'nid':
-          $tables = array('book_access_author', 'book_access_role', 'book_access_user');
-           break;
+          $tables = [
+            'book_access_author',
+            'book_access_role',
+            'book_access_user',
+          ];
+          break;
 
         case 'uid':
-          $tables = array('book_access_author', 'book_access_user');
+          $tables = ['book_access_author', 'book_access_user'];
           break;
 
         case 'rid':
-          $tables = array('book_access_role');
+          $tables = ['book_access_role'];
           break;
 
         default:
-          $tables = array();
+          $tables = [];
       }
     }
 
     foreach ($tables as $table) {
       \Drupal::database()->update($table)
-        ->fields( array(
+        ->fields([
           "grant_admin_access" => 0,
           "grant_update" => 0,
           "grant_delete" => 0,
           "grant_add_child" => 0,
           "grant_edit_outline" => 0,
           "grant_view" => 0,
-        ))
-        ->condition( $field == "bid" ? "nid" : $field, $value, '=')
+        ])
+        ->condition($field == "bid" ? "nid" : $field, $value, '=')
         ->execute();
     }
   }
@@ -310,23 +351,23 @@ final class BookAccess extends EntityAccessControlHandler implements EntityHandl
   /**
    * Returns the book author grants.
    *
-   * @param $bid
+   * @param string $bid
    *   The book ID.
-   * @param $uid
+   * @param string $uid
    *   The user ID for the book author.
-   * @param $defaults
+   * @param array $defaults
    *   An array containing the default values for the grants.
    *
-   * @return
+   * @return array
    *   An array of grants, in the format @code $grants[$grant] @endcode,
    *   where @code $grant @endcode is a string between 'grant_view',
    *   'grant_update', 'grant_delete', 'grant_admin_access', 'grant_add_child',
    *   'grant_edit_outline'.
    */
-  public static function getAuthorGrants($bid, $uid, array $defaults = array()) {
+  public static function getAuthorGrants($bid, $uid, array $defaults = []) {
     $grants = db_query_range(
       'SELECT * FROM {book_access_author} WHERE nid = :nid AND uid = :uid',
-      0, 1, array(':nid' => $bid, ':uid' => $uid))->fetchAssoc();
+      0, 1, [':nid' => $bid, ':uid' => $uid])->fetchAssoc();
 
     if (!$grants) {
       $defaults = array_filter($defaults);
@@ -342,38 +383,39 @@ final class BookAccess extends EntityAccessControlHandler implements EntityHandl
   /**
    * Lists all the books to which the current user has access.
    *
-   * @param $account
-   *   The user account to use; if NULL, the currently logged in user account
-   *   will be used.
-   * @param $grants
+   * @param array $grants
    *   An array containing one or more values between 'view', 'update',
    *   'delete', 'admin_access', 'add_child', and 'edit_outline'.
+   * @param string $account
+   *   The user account to use; if NULL, the currently logged in user account
+   *   will be used.
    *
-   * @return
-   *   An array containing the node ID of the books to which the user has access.
+   * @return array
+   *   An array containing the node ID of the books
+   *   to which the user has access.
    */
-  public static function getBookList(array $grants = array('update'), $account = NULL) {
-    $permitted_bids = array();
+  public static function getBookList(array $grants = ['update'], $account = NULL) {
+    $permitted_bids = [];
 
     if (!isset($account)) {
       $account = \Drupal::currentUser();
     }
 
     foreach ($grants as $grant) {
-      $result = \Drupal::database()->query("SELECT nid FROM {book_access_author} WHERE uid = :uid AND grant_$grant > 0", array(':uid' => $account->uid));
+      $result = \Drupal::database()->query("SELECT nid FROM {book_access_author} WHERE uid = :uid AND grant_$grant > 0", [':uid' => $account->uid]);
 
       foreach ($result as $book) {
         $permitted_bids[$book->nid] = $book->nid;
       }
 
       $roles = array_keys($account->roles);
-      $result = \Drupal::database()->query("SELECT nid FROM {book_access_role} WHERE rid IN (:rid) AND grant_$grant > 0", array(':rid' => $roles));
+      $result = \Drupal::database()->query("SELECT nid FROM {book_access_role} WHERE rid IN (:rid) AND grant_$grant > 0", [':rid' => $roles]);
 
       foreach ($result as $book) {
         $permitted_bids[$book->nid] = $book->nid;
       }
 
-      $result = \Drupal::database()->query("SELECT nid FROM {book_access_user} WHERE uid = :uid AND grant_$grant > 0", array(':uid' => $account->uid));
+      $result = \Drupal::database()->query("SELECT nid FROM {book_access_user} WHERE uid = :uid AND grant_$grant > 0", [':uid' => $account->uid]);
 
       foreach ($result as $book) {
         $permitted_bids[$book->nid] = $book->nid;
@@ -386,56 +428,58 @@ final class BookAccess extends EntityAccessControlHandler implements EntityHandl
   /**
    * Gets the list of grant records assigned to a book.
    *
-   * @param $bid
+   * @param string $bid
    *   The ID of the book for which the function returns the grant records.
-   * @param $types
+   * @param array $types
    *   An array of grants types for which the function returns the records; the
    *   currently used values are 'author', 'role', 'user'.
    *
-   * @return
+   * @return array
    *   The array of grant records for the specified book.
    */
-  public static function getGrantRecords($bid, array $types = array('author', 'role', 'user')) {
-    $grants = array();
-    $info = array();
+  public static function getGrantRecords($bid,
+    array $types = ['author', 'role', 'user']
+  ) {
+    $grants = [];
+    $info = [];
 
     foreach ($types as $type) {
       switch ($type) {
         case 'author':
-          $info[] = array(
+          $info[] = [
             'table' => 'book_access_author',
             'gid' => 'uid',
-          );
+          ];
           break;
 
         case 'role':
-          $info[] = array(
+          $info[] = [
             'table' => 'book_access_role',
             'gid' => 'rid',
-          );
+          ];
           break;
 
         case 'user':
-          $info[] = array(
+          $info[] = [
             'table' => 'book_access_user',
             'gid' => 'uid',
-          );
+          ];
           break;
       }
     }
 
     foreach ($info as $data) {
-      $result = \Drupal::database()->query("SELECT * FROM {" . db_escape_table($data['table']) . "} WHERE nid = :nid", array(':nid' => $bid));
+      $result = \Drupal::database()->query("SELECT * FROM {" . db_escape_table($data['table']) . "} WHERE nid = :nid", [':nid' => $bid]);
 
       foreach ($result as $grant) {
-        $grants[] = array(
+        $grants[] = [
           'realm' => $data['table'],
           'gid' => $grant->{$data['gid']},
           'grant_view' => $grant->grant_view,
           'grant_update' => $grant->grant_update,
           'grant_delete' => $grant->grant_delete,
           'priority' => variable_get('book_access_priority', 0),
-        );
+        ];
       }
     }
 
@@ -445,33 +489,36 @@ final class BookAccess extends EntityAccessControlHandler implements EntityHandl
   /**
    * Returns the role book grants.
    *
-   * @param $bid
+   * @param string $bid
    *   The book ID.
-   * @param $roles
+   * @param string $roles
    *   The variables where to store the value returned by user_roles().
-   * @param $defaults
+   * @param array $defaults
    *   An array containing the default values for the grants.
    *
-   * @return
+   * @return array
    *   An array of grants, in the format @code $grants[$grant][$rid] @endcode,
    *   where @code $grant @endcode is a string between 'grant_view',
    *   'grant_update', 'grant_delete', 'grant_admin_access', 'grant_add_child',
    *   'grant_edit_outline', and @code $rid @endcode is the role ID.
    */
-  public static function getRoleGrants($bid, &$roles, array $defaults = array()) {
-    $grants = array(
-      'grant_view' => array(),
-      'grant_update' => array(),
-      'grant_delete' => array(),
-      'grant_admin_access' => array(),
-      'grant_add_child' => array(),
-      'grant_edit_outline' => array(),
-    );
+  public static function getRoleGrants($bid, &$roles, array $defaults = []) {
+    $grants = [
+      'grant_view' => [],
+      'grant_update' => [],
+      'grant_delete' => [],
+      'grant_admin_access' => [],
+      'grant_add_child' => [],
+      'grant_edit_outline' => [],
+    ];
     $roles = user_roles();
     $rcopy = $roles;
 
     $rids = array_keys($roles);
-    $result = \Drupal::database()->query("SELECT * FROM {book_access_role} WHERE nid = :nid AND rid IN (:rid)", array(':nid' => $bid, ':rid' => $rids));
+    $result = \Drupal::database()
+      ->query("SELECT * FROM {book_access_role} WHERE nid = :nid AND rid IN (:rid)",
+        [':nid' => $bid, ':rid' => $rids]
+      );
 
     // Build the role access permissions for the book.
     if ($result->rowCount() > 0) {
@@ -485,13 +532,13 @@ final class BookAccess extends EntityAccessControlHandler implements EntityHandl
     }
     else {
       foreach ($rids as $rid) {
-        $roleDefaults = variable_get( "book_access_default_role_{$rid}_access");
+        $roleDefaults = variable_get("book_access_default_role_{$rid}_access");
         if ($roleDefaults) {
 
           unset($rcopy[$rid]);
 
           foreach (self::grantIDs() as $id) {
-            $grants[$id][$rid] = in_array( $id, $roleDefaults);
+            $grants[$id][$rid] = in_array($id, $roleDefaults);
           }
         }
       }
@@ -513,31 +560,29 @@ final class BookAccess extends EntityAccessControlHandler implements EntityHandl
   /**
    * Returns the user book grants.
    *
-   * @param $bid
+   * @param string $bid
    *   The book ID.
-   * @param $uids
+   * @param string $uids
    *   The variables where to store the user IDs.
-   * @param $defaults
-   *   An array containing the default values for the grants.
    *
-   * @return
+   * @return array
    *   An array of grants, in the format @code $grants[$grant][$uid] @endcode,
    *   where @code $grant @endcode is a string between 'grant_view',
    *   'grant_update', 'grant_delete', 'grant_admin_access', 'grant_add_child',
    *   'grant_edit_outline', and @code $uid @endcode is the user ID.
    */
   public static function getUserGrants($bid, &$uids) {
-    $grants = array(
-      'grant_view' => array(),
-      'grant_update' => array(),
-      'grant_delete' => array(),
-      'grant_admin_access' => array(),
-      'grant_add_child' => array(),
-      'grant_edit_outline' => array(),
-    );
-    $uids = array();
-
-    $result = \Drupal::database()->query("SELECT * FROM {book_access_user} bau INNER JOIN {users} u ON u.uid = bau.uid WHERE bau.nid = :nid", array(':nid' => $bid));
+    $grants = [
+      'grant_view' => [],
+      'grant_update' => [],
+      'grant_delete' => [],
+      'grant_admin_access' => [],
+      'grant_add_child' => [],
+      'grant_edit_outline' => [],
+    ];
+    $uids = [];
+
+    $result = \Drupal::database()->query("SELECT * FROM {book_access_user} bau INNER JOIN {users} u ON u.uid = bau.uid WHERE bau.nid = :nid", [':nid' => $bid]);
     foreach ($result as $access) {
       $uid = $access->uid;
       $uids[$uid] = $uid;
@@ -553,23 +598,23 @@ final class BookAccess extends EntityAccessControlHandler implements EntityHandl
   /**
    * Restricts the options available to who moves book pages between books.
    *
-   * @param $options
+   * @param array $options
    *   The options array used from book_outline_form() and the book edit form
    *   for the list of books to which the page can be moved to.
-   * @param $account
+   * @param string $account
    *   The user account to use; if NULL, the currently logged in user account
    *   will be used.
    */
-  public static function restrictOptions(&$options, $account = NULL) {
+  public static function restrictOptions(array &$options, $account = NULL) {
     if (!isset($account)) {
-      $account = \Drupal::currentUser();
+      $account = $this->currentUser();
     }
 
     if (user_access('administer nodes', $account)) {
       return;
     }
 
-    $permitted_bids = self::getBookList(array('update'), $account);
+    $permitted_bids = self::getBookList(['update'], $account);
 
     foreach ($options as $bid => $value) {
       if ($bid > 0 && !isset($permitted_bids[$bid])) {
@@ -583,11 +628,11 @@ final class BookAccess extends EntityAccessControlHandler implements EntityHandl
    *
    * The method delete the author grants before to set the new ones.
    *
-   * @param $bid
+   * @param string $bid
    *   The book ID.
-   * @param $uid
+   * @param string $uid
    *   The user ID of the book author.
-   * @param $grants
+   * @param array $grants
    *   An array of grants, in the format @code $grants[$grant] @endcode,
    *   where @code $grant @endcode is a string between 'grant_view',
    *   'grant_update', 'grant_delete', 'grant_admin_access', 'grant_add_child',
@@ -605,11 +650,11 @@ final class BookAccess extends EntityAccessControlHandler implements EntityHandl
    *
    * The method delete the role grants before to set the new ones.
    *
-   * @param $bid
+   * @param string $bid
    *   The book ID.
-   * @param $rids
+   * @param array $rids
    *   An array of role IDs for which to add the book grants.
-   * @param $grants
+   * @param array $grants
    *   An array of grants, in the format @code $grants[$grant][$rid] @endcode,
    *   where @code $grant @endcode is a string between 'grant_view',
    *   'grant_update', 'grant_delete', 'grant_admin_access', 'grant_add_child',
@@ -627,11 +672,11 @@ final class BookAccess extends EntityAccessControlHandler implements EntityHandl
    *
    * The method delete the user grants before to set the new ones.
    *
-   * @param $bid
+   * @param string $bid
    *   The book ID.
-   * @param $uids
+   * @param array $uids
    *   An array of user IDs for which to add the book grants.
-   * @param $grants
+   * @param array $grants
    *   An array of grants, in the format @code $grants[$grant][$uid] @endcode,
    *   where @code $grant @endcode is a string between 'grant_view',
    *   'grant_update', 'grant_delete', 'grant_admin_access', 'grant_add_child',
@@ -655,11 +700,11 @@ final class BookAccess extends EntityAccessControlHandler implements EntityHandl
     BookAccess::setAuthorGrants(
       $nid,
       $node->uid,
-      drupal_map_assoc( $authorDefaults));
+      drupal_map_assoc($authorDefaults));
 
-    // clear out the existing role grants and add on to it
-    BookAccess::setRoleGrants( $nid, array_keys( $roles), array());
-    $roleGrantsToAdd = array();
+    // Clear out the existing role grants and add on to it.
+    BookAccess::setRoleGrants($nid, array_keys($roles), []);
+    $roleGrantsToAdd = [];
     foreach ($roles as $rid => $rname) {
       $roleDefaults = variable_get("book_access_default_role_{$rid}_access");
       foreach ($roleDefaults as $grant) {
@@ -667,22 +712,25 @@ final class BookAccess extends EntityAccessControlHandler implements EntityHandl
       }
     }
 
-    BookAccess::addRoleGrants( $nid, array_keys( $roles), $roleGrantsToAdd);
+    BookAccess::addRoleGrants($nid, array_keys($roles), $roleGrantsToAdd);
   }
 
   /**
    * Updates the grants for a book.
    *
-   * @param $bid
+   * @param string $bid
    *   The book ID.
-   * @param $fields
+   * @param array $fields
    *   The fields to update.
-   * @param $types
+   * @param array $types
    *   An array containing the grant types; the currently used values are
    *   'author', 'role', 'user'. It is responsibility of the caller to use
    *   values for $types for which $field is valid.
    */
-  public static function updateGrants($bid, array $fields, array $types = array('author', 'role', 'user')) {
+  public static function updateGrants($bid,
+    array $fields,
+    array $types = ['author', 'role', 'user']
+  ) {
     foreach ($types as $type) {
       switch ($type) {
         case 'author':
@@ -704,16 +752,18 @@ final class BookAccess extends EntityAccessControlHandler implements EntityHandl
     }
   }
 
-  /*
+  /**
    * Writes the grant records to the Drupal node access table.
    *
-   * @param $node
+   * @param string $node
    *   The node object for the book page.
-   * @param $types
+   * @param array $types
    *   An array of grants types that are written; the currently used values are
    *   'author', 'role', 'user'.
    */
-  public static function writeGrantRecords($node, array $types = array('author', 'role', 'user')) {
+  public static function writeGrantRecords($node,
+    array $types = ['author', 'role', 'user']
+  ) {
     if (!empty($node->nid) && !empty($node->book['bid'])) {
       foreach ($types as $type) {
         switch ($type) {
@@ -727,7 +777,7 @@ final class BookAccess extends EntityAccessControlHandler implements EntityHandl
             $table = '';
         }
 
-        if ($table && ($grants = self::getGrantRecords($node->book['bid'], array($type)))) {
+        if ($table && ($grants = self::getGrantRecords($node->book['bid'], [$type]))) {
           node_access_write_grants($node, $grants, $table, TRUE);
         }
       }
@@ -739,14 +789,13 @@ final class BookAccess extends EntityAccessControlHandler implements EntityHandl
    *
    * @see book_access_menu_alter()
    */
-  function _book_access_outline_access($node) {
+  public function bookAccessOutlineAccess($node) {
     if (empty($node->book['bid'])) {
       return FALSE;
     }
 
-    //$view_access = node_access('view', $node);
-
-    if (\Drupal::currentUser()->hasPermission('administer book outlines') && $view_access) {
+    // $view_access = node_access('view', $node);
+    if ($this->currentUser()->hasPermission('administer book outlines') && $view_access) {
       return TRUE;
     }
 
@@ -758,16 +807,20 @@ final class BookAccess extends EntityAccessControlHandler implements EntityHandl
    *
    * @see book_access_menu_alter()
    */
-  function _book_access_outline_remove_access($node) {
-/*    $bool = (
-      !empty($node->book['bid']) &&
-      ($node->book['bid'] != $node->nid) && _book_access_outline_access($node)
+  public function bookAccessOutlineRemoveAccess($node) {
+    /*    $bool = (
+    !empty($node->book['bid']) &&
+    ($node->book['bid'] != $node->nid) && bookAccessOutlineAccess($node)
     );
 
     return $bool;*/
   }
 
+  /**
+   * Create Instance.
+   */
   public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
-    // TODO: Implement createInstance() method.
+    // @todo Implement createInstance() method.
   }
+
 }
diff --git a/src/Routing/RouteSubscriber.php b/src/Routing/RouteSubscriber.php
index 29a71a9..db4d819 100644
--- a/src/Routing/RouteSubscriber.php
+++ b/src/Routing/RouteSubscriber.php
@@ -1,7 +1,4 @@
-<?php /**
- * @file
- * Contains \Drupal\book_access\Routing\RouteSubscriber.
- */
+<?php
 
 namespace Drupal\book_access\Routing;
 
@@ -17,13 +14,12 @@ class RouteSubscriber extends RouteSubscriberBase {
    * {@inheritdoc}
    */
   public function alterRoutes(RouteCollection $collection) {
-    /**
-     * @FIXME
-     * Parts of your hook_menu_alter() logic should be moved in here. You should NOT
-     * use this method to define new routes -- read the documentation at
-     * https://www.drupal.org/node/2122201 to learn how to define dynamic routes --
-     * but to alter existing ones.
-     */
+    // @FIXME
+    // Parts of your hook_menu_alter() logic should be moved in here.
+    // You should NOT use this method to define new routes
+    // -- read the documentation at https://www.drupal.org/node/2122201
+    // to learn how to define dynamic routes --
+    // but to alter existing ones.
   }
 
 }
diff --git a/tests/src/Kernel/BookAccessDefaultsTest.php b/tests/src/Kernel/BookAccessDefaultsTest.php
index 7e7ee9f..78027d2 100644
--- a/tests/src/Kernel/BookAccessDefaultsTest.php
+++ b/tests/src/Kernel/BookAccessDefaultsTest.php
@@ -92,7 +92,7 @@ class BookAccessDefaultsTest extends KernelTestBase {
       ->execute();
     $this->assertIsArray($results, "Results are not available. Not an array");
     $this->assertEquals(count($results), 1, "One result expected.");
-    /** @var $config \Drupal\book_access\Entity\BookAccessDefaultsInterface */
+    /** @var \Drupal\book_access\Entity\BookAccessDefaultsInterface $config */
     $config = $this->defaultStorage->load(current($results));
     $grants = $config->getGrants();
     $this->assertEquals($grants['grant_add_child'], FALSE, "Grant add child expected FALSE.");
@@ -107,7 +107,7 @@ class BookAccessDefaultsTest extends KernelTestBase {
       ->execute();
     $this->assertIsArray($results, "Results are not available. Not an array");
     $this->assertEquals(count($results), 1, "One result expected.");
-    /** @var $config \Drupal\book_access\Entity\BookAccessDefaultsInterface */
+    /** @var \Drupal\book_access\Entity\BookAccessDefaultsInterface $config */
     $config = $this->defaultStorage->load(current($results));
     $grants = $config->getGrants();
     $this->assertEquals($grants['grant_add_child'], TRUE, "Grant add child expected TRUE.");
