File tree Expand file tree Collapse file tree 1 file changed +12
-16
lines changed Expand file tree Collapse file tree 1 file changed +12
-16
lines changed Original file line number Diff line number Diff line change @@ -99,27 +99,23 @@ public function jsonSerialize()
99
99
{
100
100
$ result = new \stdClass ();
101
101
$ schema = static ::schema ();
102
- $ classname = $ schema ->getObjectItemClass ();
103
- $ classReference = (class_exists ($ classname )) ? new $ classname () : new \stdClass ();
104
102
$ properties = $ schema ->getProperties ();
105
103
if (null !== $ properties ) {
106
104
foreach ($ properties ->getDataKeyMap () as $ propertyName => $ dataName ) {
107
105
$ value = $ this ->$ propertyName ;
108
- $ types = ($ schema ->getProperty ($ propertyName ) instanceof Schema)
109
- ? $ schema ->getProperty ($ propertyName )->type
110
- : null ;
111
- if (
112
- (
113
- null !== $ value
114
- ||
115
- ($ value === null
116
- && is_array ($ types )
117
- && in_array ('null ' , $ types )
118
- )
119
- )
120
- || array_key_exists ($ propertyName , $ this ->__arrayOfData )
121
- ) {
106
+ // Value is exported if exists.
107
+ if (null !== $ value || array_key_exists ($ propertyName , $ this ->__arrayOfData )) {
122
108
$ result ->$ dataName = $ value ;
109
+ continue ;
110
+ }
111
+
112
+ // Non-existent value is only exported if belongs to nullable property (having 'null' in type array).
113
+ $ property = $ schema ->getProperty ($ propertyName );
114
+ if ($ property instanceof Schema) {
115
+ $ types = $ property ->type ;
116
+ if ($ types === Schema::NULL || (is_array ($ types ) && in_array (Schema::NULL , $ types ))) {
117
+ $ result ->$ dataName = $ value ;
118
+ }
123
119
}
124
120
}
125
121
}
You can’t perform that action at this time.
0 commit comments