From 91e222244c54269bff0414c3ecce358e37c9fd90 Mon Sep 17 00:00:00 2001
From: Taggart Jensen <taggart.jensen@xvt.com.au>
Date: Wed, 4 Jan 2017 08:23:01 +1000
Subject: [PATCH] clean up some documentation and phpcs fixing.

---
 inline_entity_form.api.php                         | 10 +--
 inline_entity_form.module                          | 43 +++++++-----
 src/ElementSubmit.php                              |  2 +-
 src/Form/EntityInlineForm.php                      | 14 +++-
 .../Field/FieldWidget/InlineEntityFormBase.php     | 15 +++--
 .../Field/FieldWidget/InlineEntityFormComplex.php  | 76 +++++++++++++++-------
 .../Field/FieldWidget/InlineEntityFormSimple.php   |  2 +-
 src/Tests/ComplexSimpleWidgetTest.php              |  5 +-
 src/Tests/ComplexWidgetWebTest.php                 | 44 ++++++-------
 src/Tests/ElementWebTest.php                       |  2 +-
 src/Tests/InlineEntityFormTestBase.php             |  7 +-
 src/Tests/SimpleWidgetWebTest.php                  |  8 +--
 src/Tests/TranslationTest.php                      |  2 +-
 src/TranslationHelper.php                          |  6 +-
 14 files changed, 140 insertions(+), 96 deletions(-)

diff --git a/inline_entity_form.api.php b/inline_entity_form.api.php
index 444f5cf..dfc80f5 100644
--- a/inline_entity_form.api.php
+++ b/inline_entity_form.api.php
@@ -8,9 +8,9 @@
 /**
  * Perform alterations before an entity form is included in the IEF widget.
  *
- * @param $entity_form
+ * @param array $entity_form
  *   Nested array of form elements that comprise the entity form.
- * @param $form_state
+ * @param object $form_state
  *   The form state of the parent form.
  */
 function hook_inline_entity_form_entity_form_alter(&$entity_form, &$form_state) {
@@ -23,11 +23,11 @@ function hook_inline_entity_form_entity_form_alter(&$entity_form, &$form_state)
  * Perform alterations before the reference form is included in the IEF widget.
  *
  * The reference form is used to add existing entities through an autocomplete
- * field
+ * field.
  *
- * @param $reference_form
+ * @param array $reference_form
  *   Nested array of form elements that comprise the reference form.
- * @param $form_state
+ * @param object $form_state
  *   The form state of the parent form.
  */
 function hook_inline_entity_form_reference_form_alter(&$reference_form, &$form_state) {
diff --git a/inline_entity_form.module b/inline_entity_form.module
index 89e27de..161b74d 100644
--- a/inline_entity_form.module
+++ b/inline_entity_form.module
@@ -2,6 +2,8 @@
 
 /**
  * @file
+ * Inline Module.
+ *
  * Provides a widget for inline management (creation, modification, removal) of
  * referenced entities. The primary use case is the parent -> children one
  * (for example, order -> line items), where the child entities are never
@@ -61,8 +63,8 @@ function inline_entity_form_theme() {
  *
  * @param array $reference_form
  *   The form array that will receive the form.
- * @param \Drupal\Core\Form\FormStateInterface $form_state
- *   The form state of the parent form.
+ * @param mixed $form_state
+ *   Overloaded Form state object of the parent form FormStateInterface.
  *
  * @return array
  *   The form array containing the embedded form.
@@ -86,7 +88,7 @@ function inline_entity_form_reference_form($reference_form, &$form_state) {
     '#required' => TRUE,
     '#maxlength' => 255,
   ];
-  // Add the actions
+  // Add the actions.
   $reference_form['actions'] = [
     '#type' => 'container',
     '#weight' => 100,
@@ -128,9 +130,9 @@ function inline_entity_form_reference_form($reference_form, &$form_state) {
  * Validates the form for adding existing entities.
  *
  * @param array $reference_form
- *  The reference entity form.
+ *   The reference entity form.
  * @param \Drupal\Core\Form\FormStateInterface $form_state
- *   The form state of the parent form.
+ *   Form state object of the parent form \Drupal\Core\Form\FormStateInterface.
  */
 function inline_entity_form_reference_form_validate(&$reference_form, FormStateInterface $form_state) {
   $form_values = NestedArray::getValue($form_state->getValues(), $reference_form['#parents']);
@@ -161,7 +163,7 @@ function inline_entity_form_reference_form_validate(&$reference_form, FormStateI
  * Adds the specified entity to the IEF form state.
  *
  * @param array $reference_form
- *  The reference entity form.
+ *   The reference entity form.
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The form state of the parent form.
  */
@@ -191,9 +193,9 @@ function inline_entity_form_reference_form_submit($reference_form, FormStateInte
  *
  * The form is shown below the entity table, at the bottom of the widget.
  *
- * @param $form
+ * @param array $form
  *   The complete parent form.
- * @param $form_state
+ * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The form state of the parent form.
  */
 function inline_entity_form_open_form($form, FormStateInterface $form_state) {
@@ -217,9 +219,9 @@ function inline_entity_form_open_form($form, FormStateInterface $form_state) {
 /**
  * Button #submit callback: Cleans up form state for a closed entity form.
  *
- * @param $form
+ * @param array $form
  *   The complete parent form.
- * @param $form_state
+ * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The form state of the parent form.
  */
 function inline_entity_form_cleanup_form_state($form, FormStateInterface $form_state) {
@@ -233,9 +235,9 @@ function inline_entity_form_cleanup_form_state($form, FormStateInterface $form_s
  * The row is identified by #ief_row_delta stored on the triggering
  * element.
  *
- * @param $form
+ * @param array $form
  *   The complete parent form.
- * @param $form_state
+ * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The form state of the parent form.
  */
 function inline_entity_form_open_row_form($form, FormStateInterface $form_state) {
@@ -247,15 +249,14 @@ function inline_entity_form_open_row_form($form, FormStateInterface $form_state)
   $form_state->set(['inline_entity_form', $ief_id, 'entities', $delta, 'form'], $form_state->getTriggeringElement()['#ief_row_form']);
 }
 
-
 /**
  * Closes all open IEF forms.
  *
  * Recurses and closes open forms in nested IEF widgets as well.
  *
- * @param $elements
+ * @param array $elements
  *   An array of form elements containing entity forms.
- * @param $form_state
+ * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The form state of the parent form.
  */
 function inline_entity_form_close_all_forms($elements, FormStateInterface $form_state) {
@@ -282,9 +283,9 @@ function inline_entity_form_close_all_forms($elements, FormStateInterface $form_
 /**
  * Button #submit callback: Cleans up form state for a closed entity row form.
  *
- * @param $form
+ * @param array $form
  *   The complete parent form.
- * @param $form_state
+ * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The form state of the parent form.
  */
 function inline_entity_form_cleanup_row_form_state($form, FormStateInterface $form_state) {
@@ -401,7 +402,13 @@ function theme_inline_entity_form_entity_table($variables) {
       $row = [
         ['data' => $renderer->render($form[$key]['form']), 'colspan' => count($fields) + 1],
       ];
-      $rows[] = ['data' => $row, 'class' => ['ief-row-form'], 'no_striping' => TRUE];
+      $rows[] = [
+        'data' => $row,
+        'class' => [
+          'ief-row-form',
+        ],
+        'no_striping' => TRUE,
+      ];
     }
   }
 
diff --git a/src/ElementSubmit.php b/src/ElementSubmit.php
index 0abde9b..e9ab89e 100644
--- a/src/ElementSubmit.php
+++ b/src/ElementSubmit.php
@@ -60,7 +60,7 @@ class ElementSubmit {
 
     $element['#submit'] = array_merge([[get_called_class(), 'trigger']], $element['#submit']);
     // Used to distinguish between an inline form submit and main form submit.
-    $element['#ief_submit_trigger']  = TRUE;
+    $element['#ief_submit_trigger']     = TRUE;
     $element['#ief_submit_trigger_all'] = TRUE;
   }
 
diff --git a/src/Form/EntityInlineForm.php b/src/Form/EntityInlineForm.php
index 06cbbdc..fafc4dd 100644
--- a/src/Form/EntityInlineForm.php
+++ b/src/Form/EntityInlineForm.php
@@ -203,7 +203,7 @@ class EntityInlineForm implements InlineFormInterface {
       $form_display->validateFormValues($entity, $entity_form, $form_state);
       $entity->setValidationRequired(FALSE);
 
-      foreach($form_state->getErrors() as $name => $message) {
+      foreach ($form_state->getErrors() as $name => $message) {
         // $name may be unknown in $form_state and
         // $form_state->setErrorByName($name, $message) may suppress the error message.
         $form_state->setError($triggering_element, $message);
@@ -253,7 +253,15 @@ class EntityInlineForm implements InlineFormInterface {
     // Invoke all specified builders for copying form values to entity fields.
     if (isset($entity_form['#entity_builders'])) {
       foreach ($entity_form['#entity_builders'] as $function) {
-        call_user_func_array($function, [$entity->getEntityTypeId(), $entity, &$entity_form, &$form_state]);
+        call_user_func_array(
+          $function,
+          [
+            $entity->getEntityTypeId(),
+            $entity,
+            &$entity_form,
+            &$form_state,
+          ]
+        );
       }
     }
   }
@@ -268,7 +276,7 @@ class EntityInlineForm implements InlineFormInterface {
    *
    * @param $entity_form
    *   The entity form.
-   * @param $form_state
+   * @param \Drupal\Core\Form\FormStateInterface $form_state
    *   The form state of the parent form.
    */
   public static function submitCleanFormState(&$entity_form, FormStateInterface $form_state) {
diff --git a/src/Plugin/Field/FieldWidget/InlineEntityFormBase.php b/src/Plugin/Field/FieldWidget/InlineEntityFormBase.php
index 2d6054e..d6da06e 100644
--- a/src/Plugin/Field/FieldWidget/InlineEntityFormBase.php
+++ b/src/Plugin/Field/FieldWidget/InlineEntityFormBase.php
@@ -2,7 +2,6 @@
 
 namespace Drupal\inline_entity_form\Plugin\Field\FieldWidget;
 
-use Drupal\Core\Entity\ContentEntityInterface;
 use Drupal\Core\Entity\EntityDisplayRepositoryInterface;
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
@@ -72,7 +71,7 @@ abstract class InlineEntityFormBase extends WidgetBase implements ContainerFacto
    *   The entity type bundle info.
    * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
    *   The entity type manager.
-   * @param \Drupal\Core\Entity\EntityDisplayRepositoryInterface
+   * @param \Drupal\Core\Entity\EntityDisplayRepositoryInterface $entity_display_repository
    *   The entity display repository.
    */
   public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, array $third_party_settings, EntityTypeBundleInfoInterface $entity_type_bundle_info, EntityTypeManagerInterface $entity_type_manager, EntityDisplayRepositoryInterface $entity_display_repository) {
@@ -280,6 +279,7 @@ abstract class InlineEntityFormBase extends WidgetBase implements ContainerFacto
     }
 
     if ($this->getSetting('collapsible')) {
+      // @todo Only string literals should be passed to t().
       $summary[] = $this->t($this->getSetting('collapsed') ? 'Collapsible, collapsed by default' : 'Collapsible');
     }
 
@@ -349,7 +349,7 @@ abstract class InlineEntityFormBase extends WidgetBase implements ContainerFacto
         'delete' => [],
         'entities' => [],
       ];
-      // Store the $items entities in the widget state, for further manipulation.
+      // Store $items entities in the widget state, for further manipulation.
       foreach ($items as $delta => $item) {
         $entity = $item->entity;
         // The $entity can be NULL if the reference is broken.
@@ -425,7 +425,7 @@ abstract class InlineEntityFormBase extends WidgetBase implements ContainerFacto
    * @return bool
    *   TRUE if translating is in progress, FALSE otherwise.
    *
-   * @see \Drupal\inline_entity_form\TranslationHelper::initFormLangcodes().
+   * @see \Drupal\inline_entity_form\TranslationHelper::initFormLangcodes()
    */
   protected function isTranslating(FormStateInterface $form_state) {
     if (TranslationHelper::isTranslating($form_state)) {
@@ -473,9 +473,9 @@ abstract class InlineEntityFormBase extends WidgetBase implements ContainerFacto
    * Note that at this point the entity is not yet saved, since the user might
    * still decide to cancel the parent form.
    *
-   * @param $entity_form
-   *  The form of the entity being managed inline.
-   * @param $form_state
+   * @param array $entity_form
+   *   The form of the entity being managed inline.
+   * @param \Drupal\Core\Form\FormStateInterface $form_state
    *   The form state of the parent form.
    */
   public static function submitSaveEntity($entity_form, FormStateInterface $form_state) {
@@ -559,6 +559,7 @@ abstract class InlineEntityFormBase extends WidgetBase implements ContainerFacto
    * Determines if the current user can add any new entities.
    *
    * @return bool
+   *   Returns a bool.
    */
   protected function canAddNew() {
     $create_bundles = $this->getCreateBundles();
diff --git a/src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php b/src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php
index 0859058..64f4ace 100644
--- a/src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php
+++ b/src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php
@@ -53,7 +53,7 @@ class InlineEntityFormComplex extends InlineEntityFormBase implements ContainerF
    *   The entity type bundle info.
    * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
    *   The entity type manager.
-   * @param \Drupal\Core\Entity\EntityDisplayRepositoryInterface
+   * @param \Drupal\Core\Entity\EntityDisplayRepositoryInterface $entity_display_repository
    *   The entity display repository.
    * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
    *   Module handler service.
@@ -216,7 +216,11 @@ class InlineEntityFormComplex extends InlineEntityFormBase implements ContainerF
     $element['#attached']['library'][] = 'inline_entity_form/widget';
 
     $this->prepareFormState($form_state, $items, $element['#translating']);
-    $entities = $form_state->get(['inline_entity_form', $this->getIefId(), 'entities']);
+    $entities = $form_state->get([
+      'inline_entity_form',
+      $this->getIefId(),
+      'entities',
+    ]);
 
     // Build the "Multiple value" widget.
     // TODO - does this belong in #element_validate?
@@ -275,7 +279,15 @@ class InlineEntityFormComplex extends InlineEntityFormBase implements ContainerF
               $entity->bundle(),
               $parent_langcode,
               $key,
-              array_merge($parents,  ['inline_entity_form', 'entities', $key, 'form']),
+              array_merge(
+                $parents,
+                [
+                  'inline_entity_form',
+                  'entities',
+                  $key,
+                  'form',
+                ]
+              ),
               $entity
             ),
           ];
@@ -402,10 +414,14 @@ class InlineEntityFormComplex extends InlineEntityFormBase implements ContainerF
         // The parent entity type and bundle must not be the same as the inline
         // entity type and bundle, to prevent recursion.
         $parent_entity_type = $this->fieldDefinition->getTargetEntityTypeId();
-        $parent_bundle =  $this->fieldDefinition->getTargetBundle();
+        $parent_bundle = $this->fieldDefinition->getTargetBundle();
         if ($parent_entity_type != $target_type || $parent_bundle != $bundle) {
-          $form_state->set(['inline_entity_form', $this->getIefId(), 'form'], 'add');
-          $form_state->set(['inline_entity_form', $this->getIefId(), 'form settings'], [
+          $form_state->set([
+            'inline_entity_form', $this->getIefId(), 'form',
+          ], 'add');
+          $form_state->set([
+            'inline_entity_form', $this->getIefId(), 'form settings',
+          ], [
             'bundle' => $bundle,
           ]);
           $hide_cancel = TRUE;
@@ -414,7 +430,9 @@ class InlineEntityFormComplex extends InlineEntityFormBase implements ContainerF
     }
 
     // If no form is open, show buttons that open one.
-    $open_form = $form_state->get(['inline_entity_form', $this->getIefId(), 'form']);
+    $open_form = $form_state->get([
+      'inline_entity_form', $this->getIefId(), 'form',
+    ]);
 
     if (empty($open_form)) {
       $element['actions'] = [
@@ -488,7 +506,7 @@ class InlineEntityFormComplex extends InlineEntityFormBase implements ContainerF
             $parent_langcode,
             NULL,
             array_merge($parents, ['inline_entity_form'])
-          )
+          ),
         ];
         $element['form']['inline_entity_form']['#process'] = [
           ['\Drupal\inline_entity_form\Element\InlineEntityForm', 'processEntityForm'],
@@ -739,12 +757,12 @@ class InlineEntityFormComplex extends InlineEntityFormBase implements ContainerF
   /**
    * Button #submit callback: Closes a row form in the IEF widget.
    *
-   * @param $form
+   * @param array $form
    *   The complete parent form.
-   * @param $form_state
+   * @param \Drupal\Core\Form\FormStateInterface $form_state
    *   The form state of the parent form.
    *
-   * @see inline_entity_form_open_row_form().
+   * @see inline_entity_form_open_row_form()
    */
   public static function submitCloseRow($form, FormStateInterface $form_state) {
     $element = inline_entity_form_get_element($form, $form_state);
@@ -755,7 +773,6 @@ class InlineEntityFormComplex extends InlineEntityFormBase implements ContainerF
     $form_state->set(['inline_entity_form', $ief_id, 'entities', $delta, 'form'], NULL);
   }
 
-
   /**
    * Remove form submit callback.
    *
@@ -764,9 +781,9 @@ class InlineEntityFormComplex extends InlineEntityFormBase implements ContainerF
    * This isn't an #element_validate callback to avoid processing the
    * remove form when the main form is submitted.
    *
-   * @param $form
+   * @param array $form
    *   The complete parent form.
-   * @param $form_state
+   * @param \Drupal\Core\Form\FormStateInterface $form_state
    *   The form state of the parent form.
    */
   public static function submitConfirmRemove($form, FormStateInterface $form_state) {
@@ -775,7 +792,9 @@ class InlineEntityFormComplex extends InlineEntityFormBase implements ContainerF
     $delta = $remove_button['#ief_row_delta'];
 
     /** @var \Drupal\Core\Field\FieldDefinitionInterface $instance */
-    $instance = $form_state->get(['inline_entity_form', $element['#ief_id'], 'instance']);
+    $instance = $form_state->get([
+      'inline_entity_form', $element['#ief_id'], 'instance',
+    ]);
 
     /** @var \Drupal\Core\Entity\EntityInterface $entity */
     $entity = $element['entities'][$delta]['form']['#entity'];
@@ -827,10 +846,18 @@ class InlineEntityFormComplex extends InlineEntityFormBase implements ContainerF
   public static function updateRowWeights($element, FormStateInterface $form_state, $form) {
     $ief_id = $element['#ief_id'];
 
-    // Loop over the submitted delta values and update the weight of the entities
-    // in the form state.
+    // Loop over the submitted delta values and update the weight of the,
+    // entities in the form state.
     foreach (Element::children($element['entities']) as $key) {
-      $form_state->set(['inline_entity_form', $ief_id, 'entities', $key, 'weight'], $element['entities'][$key]['delta']['#value']);
+      $form_state->set([
+        'inline_entity_form',
+        $ief_id,
+        'entities',
+        $key,
+        'weight',
+      ],
+        $element['entities'][$key]['delta']['#value']
+      );
     }
   }
 
@@ -856,12 +883,12 @@ class InlineEntityFormComplex extends InlineEntityFormBase implements ContainerF
   /**
    * Button #submit callback: Closes a form in the IEF widget.
    *
-   * @param $form
+   * @param array $form
    *   The complete parent form.
-   * @param $form_state
+   * @param \Drupal\Core\Form\FormStateInterface $form_state
    *   The form state of the parent form.
    *
-   * @see inline_entity_form_open_form().
+   * @see inline_entity_form_open_form()
    */
   public static function closeForm($form, FormStateInterface $form_state) {
     $element = inline_entity_form_get_element($form, $form_state);
@@ -874,14 +901,15 @@ class InlineEntityFormComplex extends InlineEntityFormBase implements ContainerF
   /**
    * Add common submit callback functions and mark element as a IEF trigger.
    *
-   * @param $element
+   * @param array $element
+   *   This is submit callback element.
    */
   public static function addSubmitCallbacks(&$element) {
     $element['#submit'] = [
       ['\Drupal\inline_entity_form\ElementSubmit', 'trigger'],
       ['\Drupal\inline_entity_form\Plugin\Field\FieldWidget\InlineEntityFormComplex', 'closeForm'],
     ];
-    $element['#ief_submit_trigger']  = TRUE;
+    $element['#ief_submit_trigger'] = TRUE;
   }
 
   /**
@@ -890,7 +918,7 @@ class InlineEntityFormComplex extends InlineEntityFormBase implements ContainerF
    * Used to ensure that forms in nested IEF widgets are properly closed
    * when a parent IEF's form gets submitted or cancelled.
    *
-   * @param $form
+   * @param array $form
    *   The IEF Form element.
    * @param FormStateInterface $form_state
    *   The form state of the parent form.
diff --git a/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php b/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php
index f8f4038..88a0226 100644
--- a/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php
+++ b/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php
@@ -57,7 +57,7 @@ class InlineEntityFormSimple extends InlineEntityFormBase {
     $parents = array_merge($element['#field_parents'], [
       $items->getName(),
       $delta,
-      'inline_entity_form'
+      'inline_entity_form',
     ]);
     $bundle = !empty($this->getFieldSetting('handler_settings')['target_bundles']) ? reset($this->getFieldSetting('handler_settings')['target_bundles']) : NULL;
     $element['inline_entity_form'] = $this->getInlineEntityForm($op, $bundle, $langcode, $delta, $parents, $entity);
diff --git a/src/Tests/ComplexSimpleWidgetTest.php b/src/Tests/ComplexSimpleWidgetTest.php
index 115a879..64be99e 100644
--- a/src/Tests/ComplexSimpleWidgetTest.php
+++ b/src/Tests/ComplexSimpleWidgetTest.php
@@ -22,6 +22,9 @@ class ComplexSimpleWidgetTest extends InlineEntityFormTestBase {
     'field_ui',
   ];
 
+  /**
+   *
+   */
   protected function setUp() {
     parent::setUp();
 
@@ -82,7 +85,7 @@ class ComplexSimpleWidgetTest extends InlineEntityFormTestBase {
         $this->assertNoFieldByName($inner_title_field, NULL);
         $this->assertEqual('', $this->getButtonName($create_outer_button_selector), 'Create node button not found after Ajax submit.');
 
-        // The nodes should not actually be saved at this point
+        // The nodes should not actually be saved at this point.
         $this->assertNoNodeByTitle($outer_title, 'Outer node was not created when widget submitted.');
         $this->assertNoNodeByTitle($inner_title, 'Inner node was not created when widget submitted.');
 
diff --git a/src/Tests/ComplexWidgetWebTest.php b/src/Tests/ComplexWidgetWebTest.php
index 974c8a0..53f811f 100644
--- a/src/Tests/ComplexWidgetWebTest.php
+++ b/src/Tests/ComplexWidgetWebTest.php
@@ -37,7 +37,7 @@ class ComplexWidgetWebTest extends InlineEntityFormTestBase {
   protected $entityFormDisplayStorage;
 
   /**
-   * Prepares environment for
+   * Prepares environment for.
    */
   protected function setUp() {
     parent::setUp();
@@ -173,7 +173,7 @@ class ComplexWidgetWebTest extends InlineEntityFormTestBase {
   /**
    * Tests the entity creation with different bundles nested in each other.
    *
-   * ief_test_nested1 -> ief_test_nested2 -> ief_test_nested3
+   * Ief_test_nested1 -> ief_test_nested2 -> ief_test_nested3
    */
   public function testNestedEntityCreationWithDifferentBundlesAjaxSubmit() {
     $required_possibilities = [
@@ -183,7 +183,6 @@ class ComplexWidgetWebTest extends InlineEntityFormTestBase {
     foreach ($required_possibilities as $required) {
       $this->setupNestedComplexForm($required);
 
-
       $nested3_title = 'nested3 title steps ' . ($required ? 'required' : 'not required');
       $nested2_title = 'nested2 title steps ' . ($required ? 'required' : 'not required');
       $nested1_title = 'nested1 title steps ' . ($required ? 'required' : 'not required');
@@ -213,10 +212,9 @@ class ComplexWidgetWebTest extends InlineEntityFormTestBase {
    * Checks that nested IEF entity references can be edit and saved.
    *
    * @param \Drupal\node\Entity\Node $node
-   *  Top level node of type ief_test_nested1 to check.
+   *   Top level node of type ief_test_nested1 to check.
    * @param bool $ajax_submit
-   *  Whether IEF form widgets should be submitted via AJax or left open.
-   *
+   *   Whether IEF form widgets should be submitted via AJax or left open.
    */
   protected function checkNestedEntityEditing(Node $node, $ajax_submit = TRUE) {
     $this->drupalGet("node/{$node->id()}/edit");
@@ -225,14 +223,14 @@ class ComplexWidgetWebTest extends InlineEntityFormTestBase {
     /** @var \Drupal\node\Entity\Node $level_2_node */
     $level_2_node = $node->test_ref_nested1->entity->test_ref_nested2->entity;
     $level_2_node_update_title = $level_2_node->getTitle() . ' - updated';
-    //edit-test-ref-nested1-entities-0-actions-ief-entity-edit
+    // edit-test-ref-nested1-entities-0-actions-ief-entity-edit.
     $this->drupalPostAjaxForm(NULL, [], $this->getButtonName('//input[@type="submit" and @data-drupal-selector="edit-test-ref-nested1-entities-0-actions-ief-entity-edit"]'));
-    //edit-test-ref-nested1-form-inline-entity-form-entities-0-form-test-ref-nested2-entities-0-actions-ief-entity-edit
+    // edit-test-ref-nested1-form-inline-entity-form-entities-0-form-test-ref-nested2-entities-0-actions-ief-entity-edit.
     $this->drupalPostAjaxForm(NULL, [], $this->getButtonName('//input[@type="submit" and @data-drupal-selector="edit-test-ref-nested1-form-inline-entity-form-entities-0-form-test-ref-nested2-entities-0-actions-ief-entity-edit"]'));
     $edit['test_ref_nested1[form][inline_entity_form][entities][0][form][test_ref_nested2][form][inline_entity_form][entities][0][form][title][0][value]'] = $level_2_node_update_title;
     if ($ajax_submit) {
       // Close IEF Forms with AJAX posts
-      //edit-test-ref-nested1-form-inline-entity-form-entities-0-form-test-ref-nested2-form-inline-entity-form-entities-0-form-actions-ief-edit-save
+      // edit-test-ref-nested1-form-inline-entity-form-entities-0-form-test-ref-nested2-form-inline-entity-form-entities-0-form-actions-ief-edit-save.
       $this->drupalPostAjaxForm(NULL, $edit, $this->getButtonName('//input[@type="submit" and @data-drupal-selector="edit-test-ref-nested1-form-inline-entity-form-entities-0-form-test-ref-nested2-form-inline-entity-form-entities-0-form-actions-ief-edit-save"]'));
       $this->drupalPostAjaxForm(NULL, [], $this->getButtonName('//input[@type="submit" and @data-drupal-selector="edit-test-ref-nested1-form-inline-entity-form-entities-0-form-actions-ief-edit-save"]'));
       $this->drupalPostForm(NULL, [], t('Save'));
@@ -248,7 +246,7 @@ class ComplexWidgetWebTest extends InlineEntityFormTestBase {
   /**
    * Tests the entity creation with different bundles nested in each other.
    *
-   * ief_test_nested1 -> ief_test_nested2 -> ief_test_nested3
+   * Ief_test_nested1 -> ief_test_nested2 -> ief_test_nested3
    */
   public function testNestedEntityCreationWithDifferentBundlesNoAjaxSubmit() {
     $required_possibilities = [
@@ -291,7 +289,7 @@ class ComplexWidgetWebTest extends InlineEntityFormTestBase {
     $parent_node = $this->drupalGetNodeByTitle('Some title');
 
     // Edit the second entity.
-    $this->drupalGet('node/'. $parent_node->id() .'/edit');
+    $this->drupalGet('node/' . $parent_node->id() . '/edit');
     $cell = $this->xpath('//table[@id="ief-entity-table-edit-multi-entities"]/tbody/tr[@class="ief-row-entity draggable even"]/td[@class="inline-entity-form-node-label"]');
     $title = (string) $cell[0];
 
@@ -315,7 +313,7 @@ class ComplexWidgetWebTest extends InlineEntityFormTestBase {
     $this->assertTrue($node->last_name->value == 'Doe', 'Last name in reference node changed to Doe');
 
     // Delete the second entity.
-    $this->drupalGet('node/'. $parent_node->id() .'/edit');
+    $this->drupalGet('node/' . $parent_node->id() . '/edit');
     $cell = $this->xpath('//table[@id="ief-entity-table-edit-multi-entities"]/tbody/tr[@class="ief-row-entity draggable even"]/td[@class="inline-entity-form-node-label"]');
     $title = (string) $cell[0];
 
@@ -335,13 +333,13 @@ class ComplexWidgetWebTest extends InlineEntityFormTestBase {
     $this->assertTrue(empty($deleted_node), 'The inline entity was deleted from the site.');
 
     // Checks that entity does nor appear in IEF.
-    $this->drupalGet('node/'. $parent_node->id() .'/edit');
+    $this->drupalGet('node/' . $parent_node->id() . '/edit');
     $this->assertNoText($title, 'Deleted inline entity is not present on the page after saving parent.');
 
     // Delete the third entity reference only, don't delete the node. The third
     // entity now is second referenced entity because the second one was deleted
     // in previous step.
-    $this->drupalGet('node/'. $parent_node->id() .'/edit');
+    $this->drupalGet('node/' . $parent_node->id() . '/edit');
     $cell = $this->xpath('//table[@id="ief-entity-table-edit-multi-entities"]/tbody/tr[@class="ief-row-entity draggable even"]/td[@class="inline-entity-form-node-label"]');
     $title = (string) $cell[0];
 
@@ -356,7 +354,7 @@ class ComplexWidgetWebTest extends InlineEntityFormTestBase {
     $this->assertResponse(200, 'Saving parent node was successful.');
 
     // Checks that entity does nor appear in IEF.
-    $this->drupalGet('node/'. $parent_node->id() . '/edit');
+    $this->drupalGet('node/' . $parent_node->id() . '/edit');
     $this->assertNoText($title, 'Deleted inline entity is not present on the page after saving parent.');
 
     // Checks that entity is not deleted.
@@ -417,10 +415,10 @@ class ComplexWidgetWebTest extends InlineEntityFormTestBase {
     $this->assertResponse(200, 'Saving parent for was successful.');
 
     // Check if entities are referenced.
-    $this->drupalGet('node/'. $parent_node->id() .'/edit');
+    $this->drupalGet('node/' . $parent_node->id() . '/edit');
     for ($i = 2; $i <= 3; $i++) {
       $cell = $this->xpath('//table[@id="ief-entity-table-edit-multi-entities"]/tbody/tr[' . $i . ']/td[@class="inline-entity-form-node-label"]');
-      $this->assertTrue($cell[0] == 'Some reference ' . $i, 'Found reference node title "Some reference ' . $i .'" in the IEF table.');
+      $this->assertTrue($cell[0] == 'Some reference ' . $i, 'Found reference node title "Some reference ' . $i . '" in the IEF table.');
     }
     // Check if all remaining nodes from all bundles are referenced.
     $count = 2;
@@ -507,7 +505,6 @@ class ComplexWidgetWebTest extends InlineEntityFormTestBase {
 
     // The changed value of the referenced content is now newer than the
     // changed value of the second node.
-
     // Edit referenced content in second node.
     $this->drupalGet('node/' . $second_node->id() . '/edit');
 
@@ -530,7 +527,8 @@ class ComplexWidgetWebTest extends InlineEntityFormTestBase {
    * Creates ief_reference_type nodes which shall serve as reference nodes.
    *
    * @param int $numNodes
-   *   The number of nodes to create
+   *   The number of nodes to create.
+   *
    * @return array
    *   Array of created node ids keyed by labels.
    */
@@ -589,7 +587,7 @@ class ComplexWidgetWebTest extends InlineEntityFormTestBase {
    * Gets the form.
    * Opens the inline entity forms if they are not required.
    *
-   * @param boolean $required
+   * @param bool $required
    *   Whether the fields are required.
    * @param array $permissions
    *   (optional) Permissions to sign testing user in with. You may pass in an
@@ -653,9 +651,9 @@ class ComplexWidgetWebTest extends InlineEntityFormTestBase {
    * Checks that an invalid value for an existing node will be display the expected error.
    *
    * @param $existing_node_text
-   *  The text to enter into the existing node text field.
+   *   The text to enter into the existing node text field.
    * @param $expected_error
-   *  The error message that is expected to be shown.
+   *   The error message that is expected to be shown.
    */
   protected function checkExistingValidationExpectation($existing_node_text, $expected_error) {
     $edit = [
@@ -700,7 +698,7 @@ class ComplexWidgetWebTest extends InlineEntityFormTestBase {
 
     $user = $this->createUser([
       'create ief_test_complex content',
-      'create ief_reference_type content'
+      'create ief_reference_type content',
     ]);
     $this->drupalLogin($user);
 
diff --git a/src/Tests/ElementWebTest.php b/src/Tests/ElementWebTest.php
index 59a5a5f..e616031 100644
--- a/src/Tests/ElementWebTest.php
+++ b/src/Tests/ElementWebTest.php
@@ -17,7 +17,7 @@ class ElementWebTest extends InlineEntityFormTestBase {
   public static $modules = ['inline_entity_form_test'];
 
   /**
-   * Prepares environment for
+   * Prepares environment for.
    */
   protected function setUp() {
     parent::setUp();
diff --git a/src/Tests/InlineEntityFormTestBase.php b/src/Tests/InlineEntityFormTestBase.php
index e3bf62d..dc71c90 100644
--- a/src/Tests/InlineEntityFormTestBase.php
+++ b/src/Tests/InlineEntityFormTestBase.php
@@ -19,7 +19,7 @@ abstract class InlineEntityFormTestBase extends WebTestBase {
   /**
    * Node storage.
    *
-   * @var \Drupal\Core\Entity\ContentEntityStorageInterface;
+   * @var \Drupal\Core\Entity\ContentEntityStorageInterface
    */
   protected $nodeStorage;
 
@@ -47,7 +47,6 @@ abstract class InlineEntityFormTestBase extends WebTestBase {
     $this->fieldConfigStorage = $this->container->get('entity_type.manager')->getStorage('field_config');
   }
 
-
   /**
    * Gets IEF button name.
    *
@@ -140,7 +139,7 @@ abstract class InlineEntityFormTestBase extends WebTestBase {
    * in inline_entity_form_test module.
    *
    * @param $form_display
-   *  The form display to check.
+   *   The form display to check.
    */
   protected function checkFormDisplayFields($form_display, $prefix) {
     $form_display_fields = [
@@ -171,7 +170,7 @@ abstract class InlineEntityFormTestBase extends WebTestBase {
       ],
     ];
     if ($fields = $form_display_fields[$form_display]) {
-      $this->assert('debug', 'Checking form dispaly: '. $form_display);
+      $this->assert('debug', 'Checking form dispaly: ' . $form_display);
       foreach ($fields['expected'] as $expected_field) {
         $this->assertFieldByName($prefix . $expected_field);
       }
diff --git a/src/Tests/SimpleWidgetWebTest.php b/src/Tests/SimpleWidgetWebTest.php
index 519c261..e01480c 100644
--- a/src/Tests/SimpleWidgetWebTest.php
+++ b/src/Tests/SimpleWidgetWebTest.php
@@ -20,7 +20,7 @@ class SimpleWidgetWebTest extends InlineEntityFormTestBase {
   public static $modules = ['inline_entity_form_test'];
 
   /**
-   * Prepares environment for
+   * Prepares environment for.
    */
   protected function setUp() {
     parent::setUp();
@@ -134,8 +134,8 @@ class SimpleWidgetWebTest extends InlineEntityFormTestBase {
       $child_node = $this->getNodeByTitle($child_title);
       if ($this->assertNotNull($child_node)) {
         $this->assertEqual($host_node->single[0]->target_id, $child_node->id(), 'Child node is referenced');
-        $this->assertEqual($child_node->positive_int[0]->value,1, 'Child node int field correct.');
-        $this->assertEqual($child_node->bundle(),'ief_test_custom', 'Child node is correct bundle.');
+        $this->assertEqual($child_node->positive_int[0]->value, 1, 'Child node int field correct.');
+        $this->assertEqual($child_node->bundle(), 'ief_test_custom', 'Child node is correct bundle.');
       }
     }
   }
@@ -157,7 +157,7 @@ class SimpleWidgetWebTest extends InlineEntityFormTestBase {
    * Tests that user only has access to the their own nodes.
    *
    * @param \Drupal\node\Entity\Node $host_node
-   *   The node of the type of ief_simple_single
+   *   The node of the type of ief_simple_single.
    * @param int $child_count
    *   The number of entity reference values in the "single" field.
    */
diff --git a/src/Tests/TranslationTest.php b/src/Tests/TranslationTest.php
index 8d226a3..b589497 100644
--- a/src/Tests/TranslationTest.php
+++ b/src/Tests/TranslationTest.php
@@ -56,7 +56,7 @@ class TranslationTest extends InlineEntityFormTestBase {
     /** @var \Drupal\Core\Entity\Display\EntityFormDisplayInterface $display */
     $display = $form_display_storage->load('node.ief_test_complex.default');
     $component = $display->getComponent('multi');
-    $component['settings']['allow_existing'] = TRUe;
+    $component['settings']['allow_existing'] = TRUE;
     $display->setComponent('multi', $component)->save();
   }
 
diff --git a/src/TranslationHelper.php b/src/TranslationHelper.php
index 6c71e5f..99973c5 100644
--- a/src/TranslationHelper.php
+++ b/src/TranslationHelper.php
@@ -21,7 +21,7 @@ class TranslationHelper {
    * @return \Drupal\Core\Entity\ContentEntityInterface
    *   The prepared entity.
    *
-   * @see \Drupal\Core\Entity\ContentEntityForm::initFormLangcodes().
+   * @see \Drupal\Core\Entity\ContentEntityForm::initFormLangcodes()
    */
   public static function prepareEntity(ContentEntityInterface $entity, FormStateInterface $form_state) {
     $form_langcode = $form_state->get('langcode');
@@ -66,7 +66,7 @@ class TranslationHelper {
    * @return bool
    *   TRUE if the entity langcode was updated, FALSE otherwise.
    */
-  public static function updateEntityLangcode(ContentEntityInterface $entity, $form_state) {
+  public static function updateEntityLangcode(ContentEntityInterface $entity, FormStateInterface $form_state) {
     $changed = FALSE;
     // This method is first called during form validation, at which point
     // the 'langcode' form state flag hasn't been updated with the new value.
@@ -97,7 +97,7 @@ class TranslationHelper {
    * @return bool
    *   TRUE if translating is in progress, FALSE otherwise.
    *
-   * @see \Drupal\Core\Entity\ContentEntityForm::initFormLangcodes().
+   * @see \Drupal\Core\Entity\ContentEntityForm::initFormLangcodes()
    */
   public static function isTranslating(FormStateInterface $form_state) {
     $form_langcode = $form_state->get('langcode');
-- 
2.9.0.windows.1

