commit 2c115c3dcc52b6bf00b4a6855ba82352df54ffde Author: Joel Pittet Date: Sun Apr 19 00:46:25 2015 -0700 nitpik fix diff --git a/core/lib/Drupal/Core/Form/FormErrorHandler.php b/core/lib/Drupal/Core/Form/FormErrorHandler.php index df91969..9691361 100644 --- a/core/lib/Drupal/Core/Form/FormErrorHandler.php +++ b/core/lib/Drupal/Core/Form/FormErrorHandler.php @@ -25,7 +25,7 @@ class FormErrorHandler implements FormErrorHandlerInterface { /** * Array of elements with errors which need to be linked to from - * the error message + * the error message. * * @var array[] */ @@ -54,7 +54,7 @@ public function handleFormErrors(array &$form, FormStateInterface $form_state) { // Display error messages for each element. $this->displayErrorMessages($form_state); - // Reset the list of elements with errors + // Reset the list of elements with errors. $this->errorLinkElements = []; return $this; @@ -66,7 +66,7 @@ public function handleFormErrors(array &$form, FormStateInterface $form_state) { * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form. * @param array[] $error_elements - * An array of elements with errors + * An array of elements with errors. */ protected function displayErrorMessages(FormStateInterface $form_state) { $error_links = []; @@ -119,7 +119,7 @@ protected function displayErrorMessages(FormStateInterface $form_state) { /** * Stores the errors of each element directly on the element and keeps a list - * of these elements + * of these elements. * * We must provide a way for non-form functions to check the errors for a * specific element. The most common usage of this is a #pre_render callback. @@ -138,10 +138,10 @@ protected function setElementErrorsFromFormState(array &$elements, FormStateInte } // Store the errors for this element on the element directly and - // keep a list of elements with errors + // keep a list of elements with errors. if (($elements['#errors'] = $form_state->getError($elements))) { $this->errorLinkElements[] = $elements; - }; + } } /** diff --git a/core/lib/Drupal/Core/Render/Element.php b/core/lib/Drupal/Core/Render/Element.php index 73eefda..e9e23eb 100644 --- a/core/lib/Drupal/Core/Render/Element.php +++ b/core/lib/Drupal/Core/Render/Element.php @@ -162,7 +162,7 @@ public static function getVisibleChildren(array $elements) { * TRUE if the element is visible, otherwise FALSE. */ public static function isVisibleElement($element) { - return (!isset($element['#type']) || !in_array($element['#type'], ['value', 'hidden', 'token'])) && (!isset($element['#access']) || $element['#access']); + return (!isset($element['#type']) || !in_array($element['#type'], ['value', 'hidden', 'token'])) && (!isset($element['#access']) || $element['#access']); } /** diff --git a/core/modules/file/src/Tests/FileFieldValidateTest.php b/core/modules/file/src/Tests/FileFieldValidateTest.php index d31ef09..3e35a00 100644 --- a/core/modules/file/src/Tests/FileFieldValidateTest.php +++ b/core/modules/file/src/Tests/FileFieldValidateTest.php @@ -35,7 +35,7 @@ function testRequired() { $edit['title[0][value]'] = $this->randomMachineName(); $this->drupalPostForm('node/add/' . $type_name, $edit, t('Save and publish')); $this->assertText('1 error has been found: ' . $field->label(), 'Node save failed when required file field was empty.'); - $this->assertIdentical(1, count($this->xpath('//div[contains(concat(" ", normalize-space(@class), " "), :class)]//a', array(':class' => ' messages--error '))), 'There is one link in the error message.'); + $this->assertIdentical(1, count($this->xpath('//div[contains(concat(" ", normalize-space(@class), " "), :class)]//a', [':class' => ' messages--error '])), 'There is one link in the error message.'); // Create a new node with the uploaded file. $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); @@ -57,7 +57,7 @@ function testRequired() { $edit['title[0][value]'] = $this->randomMachineName(); $this->drupalPostForm('node/add/' . $type_name, $edit, t('Save and publish')); $this->assertText('1 error has been found: ' . $field->label(), 'Node save failed when required multiple value file field was empty.'); - $this->assertIdentical(1, count($this->xpath('//div[contains(concat(" ", normalize-space(@class), " "), :class)]//a', array(':class' => ' messages--error '))), 'There is one link in the error message.'); + $this->assertIdentical(1, count($this->xpath('//div[contains(concat(" ", normalize-space(@class), " "), :class)]//a', [':class' => ' messages--error '])), 'There is one link in the error message.'); // Create a new node with the uploaded file into the multivalue field. $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); diff --git a/core/modules/shortcut/src/Form/SwitchShortcutSet.php b/core/modules/shortcut/src/Form/SwitchShortcutSet.php index e7ee0e1..55cdd12 100644 --- a/core/modules/shortcut/src/Form/SwitchShortcutSet.php +++ b/core/modules/shortcut/src/Form/SwitchShortcutSet.php @@ -112,9 +112,7 @@ public function buildForm(array $form, FormStateInterface $form_state, UserInter // This ID could be used for menu name. '#maxlength' => 23, '#states' => array( - 'required' => array( - ':input[name="set"]' => array('value' => 'new'), - ), + 'required' => [':input[name="set"]' => ['value' => 'new']], ), '#required' => FALSE, ); diff --git a/core/modules/system/src/Tests/Form/ValidationTest.php b/core/modules/system/src/Tests/Form/ValidationTest.php index 389ef9c..eda6dae 100644 --- a/core/modules/system/src/Tests/Form/ValidationTest.php +++ b/core/modules/system/src/Tests/Form/ValidationTest.php @@ -236,7 +236,6 @@ function testCustomRequiredError() { } $this->assertErrorMessages($messages); - // Verify that no custom validation error appears with valid values. $edit = array( 'textfield' => $this->randomString(), diff --git a/core/tests/Drupal/Tests/Core/Form/FormErrorHandlerTest.php b/core/tests/Drupal/Tests/Core/Form/FormErrorHandlerTest.php index 4b14df0..88af835 100644 --- a/core/tests/Drupal/Tests/Core/Form/FormErrorHandlerTest.php +++ b/core/tests/Drupal/Tests/Core/Form/FormErrorHandlerTest.php @@ -54,12 +54,12 @@ public function testDisplayErrorMessages() { ]; $form['fieldset'] = [ '#parents' => ['fieldset'], - 'test3' => array( + 'test3' => [ '#type' => 'textfield', '#title' => 'Test 3', '#parents' => ['fieldset', 'test3'], '#id' => 'edit-test3', - ), + ], ]; $form_state = new FormState(); $form_state->setErrorByName('test1', 'invalid'); diff --git a/core/tests/Drupal/Tests/Core/Form/FormStateTest.php b/core/tests/Drupal/Tests/Core/Form/FormStateTest.php index b662342..b92c5f7 100644 --- a/core/tests/Drupal/Tests/Core/Form/FormStateTest.php +++ b/core/tests/Drupal/Tests/Core/Form/FormStateTest.php @@ -122,7 +122,7 @@ public function providerTestSetErrorByName() { array(array(array('options')), array('options' => '')), // Do not limit an validation, and, ensuring the first error is returned // for the 'test' element. - array(NULL, array('test' => 'Fail 1', 'options' => '')), + [NULL, ['test' => 'Fail 1', 'options' => '']], // Limit all validation. array(array(), array()), );