File tree Expand file tree Collapse file tree 4 files changed +23
-3
lines changed Expand file tree Collapse file tree 4 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -123,7 +123,7 @@ class Components extends AbstractAnnotation
123
123
*/
124
124
public static function componentTypes (): array
125
125
{
126
- return array_filter (array_keys (self ::$ _nested ), fn ($ value ): bool => $ value !== Attachable::class);
126
+ return array_filter (array_keys (self ::$ _nested ), fn (string $ value ): bool => $ value !== Attachable::class);
127
127
}
128
128
129
129
/**
Original file line number Diff line number Diff line change @@ -183,6 +183,18 @@ public function getDebugLocation(): string
183
183
return $ location ;
184
184
}
185
185
186
+ /**
187
+ * Excludes `reflector` property.
188
+ */
189
+ public function __serialize (): array
190
+ {
191
+ $ data = (array ) $ this ;
192
+ $ data ['reflector ' ] = null ;
193
+ unset($ data ['reflector ' ]);
194
+
195
+ return $ data ;
196
+ }
197
+
186
198
/**
187
199
* Traverse the context tree to get the property value.
188
200
*/
Original file line number Diff line number Diff line change @@ -81,11 +81,11 @@ protected function expandContextEnum(Analysis $analysis): void
81
81
// no (or invalid) schema type means name
82
82
$ useName = Generator::isDefault ($ schemaType ) || ($ enumType && $ this ->native2spec ($ enumType ) != $ schemaType );
83
83
84
- $ schema ->enum = array_map (fn ($ case ) => ($ useName || !($ case instanceof \ReflectionEnumBackedCase)) ? $ case ->name : $ case ->getBackingValue (), $ re ->getCases ());
84
+ $ schema ->enum = array_map (fn (\ ReflectionEnumUnitCase $ case ) => ($ useName || !($ case instanceof \ReflectionEnumBackedCase)) ? $ case ->name : $ case ->getBackingValue (), $ re ->getCases ());
85
85
86
86
if ($ this ->enumNames !== null && !$ useName ) {
87
87
$ schemaX = Generator::isDefault ($ schema ->x ) ? [] : $ schema ->x ;
88
- $ schemaX [$ this ->enumNames ] = array_map (fn ($ case ): string => $ case ->name , $ re ->getCases ());
88
+ $ schemaX [$ this ->enumNames ] = array_map (fn (\ ReflectionEnumUnitCase $ case ): string => $ case ->name , $ re ->getCases ());
89
89
90
90
$ schema ->x = $ schemaX ;
91
91
}
Original file line number Diff line number Diff line change @@ -39,4 +39,12 @@ public function testInvalidVersion(): void
39
39
$ openapi ->openapi = '2 ' ;
40
40
$ openapi ->validate ();
41
41
}
42
+
43
+ public function testSerialize (): void
44
+ {
45
+ $ openapi = $ this ->analysisFromFixtures (['Customer.php ' ])->openapi ;
46
+ $ unserialized = unserialize (serialize ($ openapi ));
47
+
48
+ $ this ->assertSpecEquals ($ openapi , $ unserialized );
49
+ }
42
50
}
You can’t perform that action at this time.
0 commit comments