Browse Source

Fixed phpcs issues

lilHermit 9 years ago
parent
commit
8ff6564d54

+ 1 - 1
src/View/Helper/FormHelper.php

@@ -1053,7 +1053,7 @@ class FormHelper extends Helper
             $options['hiddenField'] = '_split';
         }
 
-        $input = $this->_getInput($fieldName, $options + [ 'label' => $optionsLabel] );
+        $input = $this->_getInput($fieldName, $options + ['label' => $optionsLabel]);
         if ($options['type'] === 'hidden' || $options['type'] === 'submit') {
             if ($newTemplates) {
                 $templater->pop();

+ 10 - 9
src/View/Widget/MultiCheckboxWidget.php

@@ -200,22 +200,22 @@ class MultiCheckboxWidget implements WidgetInterface
             $label = $input;
         } else {
             $labelAttrs = [
-                    'for' => $checkbox['id'],
-                    'escape' => $checkbox['escape'],
-                    'text' => $checkbox['text'],
-                    'templateVars' => $checkbox['templateVars'],
-                    'input' => $input
-                ];
+                'for' => $checkbox['id'],
+                'escape' => $checkbox['escape'],
+                'text' => $checkbox['text'],
+                'templateVars' => $checkbox['templateVars'],
+                'input' => $input
+            ];
 
-            if(is_array($checkbox['label'])) {
+            if (is_array($checkbox['label'])) {
                 $labelAttrs += $checkbox['label'];
             }
 
             if (isset($checkbox['checked']) && $checkbox['checked']) {
-                if(isset($labelAttrs['class'])) {
+                if (isset($labelAttrs['class'])) {
                     if (is_array($labelAttrs['class'])) {
                         $labelAttrs['class'][] = 'selected';
-                    } else if(is_string($labelAttrs['class'])) {
+                    } elseif (is_string($labelAttrs['class'])) {
                         $labelAttrs['class'] .= ' selected';
                     }
                 } else {
@@ -225,6 +225,7 @@ class MultiCheckboxWidget implements WidgetInterface
 
             $label = $this->_label->render($labelAttrs, $context);
         }
+
         return $this->_templates->format('checkboxWrapper', [
             'templateVars' => $checkbox['templateVars'],
             'label' => $label,

+ 2 - 2
src/View/Widget/RadioWidget.php

@@ -183,10 +183,10 @@ class RadioWidget implements WidgetInterface
                 $data['label']['class'] = [];
             }
             if (isset($radio['checked']) && $radio['checked']) {
-                if(isset($data['label']['class'])) {
+                if (isset($data['label']['class'])) {
                     if (is_array($data['label']['class'])) {
                         $data['label']['class'][] = 'selected';
-                    } else if(is_string($data['label']['class'])) {
+                    } elseif (is_string($data['label']['class'])) {
                         $data['label']['class'] .= ' selected';
                     }
                 } else {

+ 8 - 11
tests/TestCase/View/Helper/FormHelperTest.php

@@ -8505,9 +8505,8 @@ class FormHelperTest extends TestCase
      * Tests false, class (as string and array) also makes sure 'selected' is added to the class if checked.
      * Also checks to make sure any custom attributes are rendered
      */
-    public function testControlLabelManipulator()
+    public function testControlLabelManipulation()
     {
-
         // Tests removal of label around input (Radio)
         $result = $this->Form->input('test', [
             'type' => 'radio',
@@ -8601,15 +8600,13 @@ class FormHelperTest extends TestCase
         $this->assertHtml($expected, $result);
 
         // Tests class as array and adding selected as well as custom attributes (Radio)
-        $result = $this->Form->radio('test', ['A', 'B'],
-            [
-                'label' => [
-                    'class' => ['custom-class', 'another-class'],
-                    'some-other-attr' => 'blah'
-                ],
-                'value' => 1
-            ]
-        );
+        $result = $this->Form->radio('test', ['A', 'B'], [
+            'label' => [
+                'class' => ['custom-class', 'another-class'],
+                'some-other-attr' => 'blah'
+            ],
+            'value' => 1
+        ]);
         $expected = [
             'input' => ['type' => 'hidden', 'name' => 'test', 'value' => ''],
             ['label' => ['class' => 'custom-class another-class', 'some-other-attr' => 'blah', 'for' => 'test-0']],