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
123123 */
124124 public static function componentTypes (): array
125125 {
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);
127127 }
128128
129129 /**
Original file line number Diff line number Diff line change @@ -183,6 +183,18 @@ public function getDebugLocation(): string
183183 return $ location ;
184184 }
185185
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+
186198 /**
187199 * Traverse the context tree to get the property value.
188200 */
Original file line number Diff line number Diff line change @@ -81,11 +81,11 @@ protected function expandContextEnum(Analysis $analysis): void
8181 // no (or invalid) schema type means name
8282 $ useName = Generator::isDefault ($ schemaType ) || ($ enumType && $ this ->native2spec ($ enumType ) != $ schemaType );
8383
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 ());
8585
8686 if ($ this ->enumNames !== null && !$ useName ) {
8787 $ 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 ());
8989
9090 $ schema ->x = $ schemaX ;
9191 }
Original file line number Diff line number Diff line change @@ -39,4 +39,12 @@ public function testInvalidVersion(): void
3939 $ openapi ->openapi = '2 ' ;
4040 $ openapi ->validate ();
4141 }
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+ }
4250}
You can’t perform that action at this time.
0 commit comments