Skip to content

Commit e72a87d

Browse files
committed
[Form] Minor fixes in docs and cs
1 parent 783643f commit e72a87d

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

Form.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,26 @@
3232
*
3333
* (1) the "model" format required by the form's object
3434
* (2) the "normalized" format for internal processing
35-
* (3) the "view" format used for display
35+
* (3) the "view" format used for display simple fields
36+
* or map children model data for compound fields
3637
*
3738
* A date field, for example, may store a date as "Y-m-d" string (1) in the
3839
* object. To facilitate processing in the field, this value is normalized
3940
* to a DateTime object (2). In the HTML representation of your form, a
40-
* localized string (3) is presented to and modified by the user.
41+
* localized string (3) may be presented to and modified by the user, or it could be an array of values
42+
* to be mapped to choices fields.
4143
*
4244
* In most cases, format (1) and format (2) will be the same. For example,
4345
* a checkbox field uses a Boolean value for both internal processing and
44-
* storage in the object. In these cases you simply need to set a value
46+
* storage in the object. In these cases you simply need to set a view
4547
* transformer to convert between formats (2) and (3). You can do this by
4648
* calling addViewTransformer().
4749
*
4850
* In some cases though it makes sense to make format (1) configurable. To
4951
* demonstrate this, let's extend our above date field to store the value
5052
* either as "Y-m-d" string or as timestamp. Internally we still want to
5153
* use a DateTime object for processing. To convert the data from string/integer
52-
* to DateTime you can set a normalization transformer by calling
54+
* to DateTime you can set a model transformer by calling
5355
* addModelTransformer(). The normalized data is then converted to the displayed
5456
* data as described before.
5557
*
@@ -218,7 +220,7 @@ public function getPropertyPath()
218220
}
219221

220222
if (null === $this->getName() || '' === $this->getName()) {
221-
return;
223+
return null;
222224
}
223225

224226
$parent = $this->parent;
@@ -341,8 +343,8 @@ public function setData($modelData)
341343
$modelData = $event->getData();
342344
}
343345

344-
// Treat data as strings unless a value transformer exists
345-
if (!$this->config->getViewTransformers() && !$this->config->getModelTransformers() && is_scalar($modelData)) {
346+
// Treat data as strings unless a transformer exists
347+
if (is_scalar($modelData) && !$this->config->getViewTransformers() && !$this->config->getModelTransformers()) {
346348
$modelData = (string) $modelData;
347349
}
348350

@@ -1068,7 +1070,7 @@ public function createView(FormView $parent = null)
10681070
}
10691071

10701072
/**
1071-
* Normalizes the value if a normalization transformer is set.
1073+
* Normalizes the value if a model transformer is set.
10721074
*
10731075
* @param mixed $value The value to transform
10741076
*
@@ -1090,7 +1092,7 @@ private function modelToNorm($value)
10901092
}
10911093

10921094
/**
1093-
* Reverse transforms a value if a normalization transformer is set.
1095+
* Reverse transforms a value if a model transformer is set.
10941096
*
10951097
* @param string $value The value to reverse transform
10961098
*
@@ -1114,7 +1116,7 @@ private function normToModel($value)
11141116
}
11151117

11161118
/**
1117-
* Transforms the value if a value transformer is set.
1119+
* Transforms the value if a view transformer is set.
11181120
*
11191121
* @param mixed $value The value to transform
11201122
*
@@ -1145,7 +1147,7 @@ private function normToView($value)
11451147
}
11461148

11471149
/**
1148-
* Reverse transforms a value if a value transformer is set.
1150+
* Reverse transforms a value if a view transformer is set.
11491151
*
11501152
* @param string $value The value to reverse transform
11511153
*

NativeRequestHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Symfony\Component\Form\Util\ServerParams;
1616

1717
/**
18-
* A request handler using PHP's super globals $_GET, $_POST and $_SERVER.
18+
* A request handler using PHP super globals $_GET, $_POST and $_SERVER.
1919
*
2020
* @author Bernhard Schussek <bschussek@gmail.com>
2121
*/
@@ -213,7 +213,7 @@ private static function stripEmptyFiles($data)
213213

214214
if (self::$fileKeys === $keys) {
215215
if (UPLOAD_ERR_NO_FILE === $data['error']) {
216-
return;
216+
return null;
217217
}
218218

219219
return $data;

Util/FormUtil.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ private function __construct()
2727
* Returns whether the given data is empty.
2828
*
2929
* This logic is reused multiple times throughout the processing of
30-
* a form and needs to be consistent. PHP's keyword `empty` cannot
30+
* a form and needs to be consistent. PHP keyword `empty` cannot
3131
* be used as it also considers 0 and "0" to be empty.
3232
*
3333
* @param mixed $data

Util/OrderedHashMap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public function offsetSet($key, $value)
128128
$key = array() === $this->orderedKeys
129129
// If the array is empty, use 0 as key
130130
? 0
131-
// Imitate PHP's behavior of generating a key that equals
131+
// Imitate PHP behavior of generating a key that equals
132132
// the highest existing integer key + 1
133133
: 1 + (int) max($this->orderedKeys);
134134
}

Util/OrderedHashMapIterator.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ class OrderedHashMapIterator implements \Iterator
5656
private $current;
5757

5858
/**
59-
* Creates a new iterator.
60-
*
6159
* @param array $elements The elements of the map, indexed by their
6260
* keys
6361
* @param array $orderedKeys The keys of the map in the order in which
@@ -84,7 +82,7 @@ public function __construct(array &$elements, array &$orderedKeys, array &$manag
8482
*/
8583
public function __destruct()
8684
{
87-
// Use array_splice() instead of isset() to prevent holes in the
85+
// Use array_splice() instead of unset() to prevent holes in the
8886
// array indices, which would break the initialization of $cursorId
8987
array_splice($this->managedCursors, $this->cursorId, 1);
9088
}

0 commit comments

Comments
 (0)