Skip to content

Commit 8ac272b

Browse files
Add return types to internal|final|private methods
1 parent b933434 commit 8ac272b

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

FormFieldRegistry.php

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,8 @@ public function add(FormField $field)
4848

4949
/**
5050
* Removes a field and its children from the registry.
51-
*
52-
* @param string $name The fully qualified name of the base field
5351
*/
54-
public function remove($name)
52+
public function remove(string $name)
5553
{
5654
$segments = $this->getSegments($name);
5755
$target = &$this->fields;
@@ -68,13 +66,11 @@ public function remove($name)
6866
/**
6967
* Returns the value of the field and its children.
7068
*
71-
* @param string $name The fully qualified name of the field
72-
*
7369
* @return mixed The value of the field
7470
*
7571
* @throws \InvalidArgumentException if the field does not exist
7672
*/
77-
public function &get($name)
73+
public function &get(string $name)
7874
{
7975
$segments = $this->getSegments($name);
8076
$target = &$this->fields;
@@ -92,11 +88,9 @@ public function &get($name)
9288
/**
9389
* Tests whether the form has the given field.
9490
*
95-
* @param string $name The fully qualified name of the field
96-
*
9791
* @return bool Whether the form has the given field
9892
*/
99-
public function has($name)
93+
public function has(string $name): bool
10094
{
10195
try {
10296
$this->get($name);
@@ -110,12 +104,11 @@ public function has($name)
110104
/**
111105
* Set the value of a field and its children.
112106
*
113-
* @param string $name The fully qualified name of the field
114-
* @param mixed $value The value
107+
* @param mixed $value The value
115108
*
116109
* @throws \InvalidArgumentException if the field does not exist
117110
*/
118-
public function set($name, $value)
111+
public function set(string $name, $value)
119112
{
120113
$target = &$this->get($name);
121114
if ((!\is_array($value) && $target instanceof Field\FormField) || $target instanceof Field\ChoiceFormField) {
@@ -135,7 +128,7 @@ public function set($name, $value)
135128
*
136129
* @return FormField[] The list of fields as [string] Fully qualified name => (mixed) value)
137130
*/
138-
public function all()
131+
public function all(): array
139132
{
140133
return $this->walk($this->fields, $this->base);
141134
}
@@ -146,12 +139,11 @@ public function all()
146139
* This function is made private because it allows overriding the $base and
147140
* the $values properties without any type checking.
148141
*
149-
* @param string $base The fully qualified name of the base field
150-
* @param array $values The values of the fields
142+
* @param array $values The values of the fields
151143
*
152144
* @return static
153145
*/
154-
private static function create($base, array $values)
146+
private static function create(string $base, array $values)
155147
{
156148
$registry = new static();
157149
$registry->base = $base;

0 commit comments

Comments
 (0)