You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/complexTypes/array.rst
+9-4Lines changed: 9 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,8 @@ Generated interface:
24
24
25
25
.. code-block:: php
26
26
27
-
public function setExample(?array $example): self;
27
+
public function setExample(array $example): self;
28
+
// As the property is not required it may be initialized with null. Consequently the return value is nullable
28
29
public function getExample(): ?array;
29
30
30
31
Possible exceptions:
@@ -117,17 +118,17 @@ In this case the model generator will generate two classes: **Family** and **Mem
117
118
.. code-block:: php
118
119
119
120
// class Family
120
-
public function setMembers(?array $members): self;
121
+
public function setMembers(array $members): self;
121
122
public function getMembers(): ?array;
122
123
123
124
// class Member
124
125
public function setName(string $name): self;
125
126
public function getName(): string;
126
127
127
-
public function setAge(?int $age): self;
128
+
public function setAge(int $age): self;
128
129
public function getAge(): ?int;
129
130
130
-
The *getMembers* function of the class *Family* is typehinted with *@returns Member[]*. Consequently auto completion is available when developing something like:
131
+
The *getMembers* function of the class *Family* is type hinted with *@returns Member[]*. Consequently auto completion is available when developing something like:
131
132
132
133
.. code-block:: php
133
134
@@ -138,6 +139,10 @@ The *getMembers* function of the class *Family* is typehinted with *@returns Mem
138
139
$member->getName();
139
140
}
140
141
142
+
.. hint::
143
+
144
+
Arrays with item validation don't accept elements which contain `null`. If your array needs to accept `null` entries you have to add null to the type of your items explicitly (eg. "type": ["object", "null"]).
Copy file name to clipboardExpand all lines: docs/source/generic/required.rst
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
Required values
2
2
===============
3
3
4
-
By default the values of a schema are not required. In this case the input is valid if the property is not provided. Additionally an explicit `null` value is also valid. If the value isn't provided an optionally defined default value is used.
4
+
By default the values of a schema are not required. In this case the input is valid if the property is not provided. If the value isn't provided an optionally defined default value is used.
5
5
6
6
.. code-block:: json
7
7
@@ -21,7 +21,8 @@ Generated interface:
21
21
22
22
.. code-block:: php
23
23
24
-
public function setExample(?string $example): self;
24
+
public function setExample(string $example): self;
25
+
// As the property is not required it may be initialized with null. Consequently the return value is nullable
25
26
public function getExample(): ?string;
26
27
27
28
Behaviour with different inputs:
@@ -35,6 +36,7 @@ Behaviour with different inputs:
35
36
// property example explicitly set to null.
36
37
// allowed as the property isn't required.
37
38
// Works only if implicitNull is enabled. Otherwise an exception will be thrown.
39
+
// If implicitNull is enabled the signature of setExample will also change to accept null.
Copy file name to clipboardExpand all lines: docs/source/gettingStarted.rst
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -161,6 +161,8 @@ By default the properties are strictly checked against their defined types. Cons
161
161
162
162
By setting the implicit null option to true all of your object properties which aren't required will implicitly accept null. All properties which are required and don't explicitly allow null in the type definition will still reject null.
163
163
164
+
If the implicit null option is enabled the interface of your classes may change. If you have disabled immutability the type hints of your optional property setters will be nullable (eg. a string property will be type hinted with `?string`).
0 commit comments