Skip to content

Commit 990195e

Browse files
committed
compatibility with php 8.0
1 parent bdae9af commit 990195e

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/Deserializer.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ private static function deserializeXmlModel(\SimpleXMLElement $element, $class):
9797

9898
$type = (string)$property->getType();
9999
$value = self::deserializeXmlAny($element->$name, $type, $annotation);
100+
$property->setAccessible(true);
100101
$property->setValue($obj, $value);
101102
}
102103

@@ -233,6 +234,7 @@ public static function deserializeOutputHeaders(ResultModel $result, OperationOu
233234
}
234235

235236
$value = self::castToAny( $headers[$name], $annotation->type, $annotation->format);
237+
$property->setAccessible(true);
236238
$property->setValue($result, $value);
237239
}
238240

@@ -249,6 +251,7 @@ public static function deserializeOutputHeaders(ResultModel $result, OperationOu
249251
}
250252

251253
if (count($meta) > 0) {
254+
$property->setAccessible(true);
252255
$property->setValue($result, $meta);
253256
}
254257
}
@@ -277,6 +280,7 @@ public static function deserializeOutputBody(ResultModel $result, OperationOutpu
277280

278281
if ('xml' === $annotation->format) {
279282
$value = self::deserializeXml($content, $annotation->type, $annotation->rename);
283+
$property->setAccessible(true);
280284
$property->setValue($result, $value);
281285
} else {
282286
throw new DeserializationExecption("Unsupport body format:$annotation->format");

src/Serializer.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ private static function serializeXmlModel(\XMLWriter $writer, string $name, Mode
100100

101101
// children element
102102
foreach ($ro->getProperties() as $property) {
103+
$property->setAccessible(true);
103104
$val = $property->getValue($value);
104105
if (!isset($val)) {
105106
continue;
@@ -129,6 +130,7 @@ public static function serializeInput(RequestModel $request, OperationInput $inp
129130

130131
//headers
131132
$hp = $ro->getProperty('headers');
133+
$hp->setAccessible(true);
132134
$h = $hp->getValue($request);
133135
if (is_array($h)) {
134136
foreach ($h as $key => $value) {
@@ -138,6 +140,7 @@ public static function serializeInput(RequestModel $request, OperationInput $inp
138140

139141
//parameters
140142
$pp = $ro->getProperty('parameters');
143+
$pp->setAccessible(true);
141144
$p = $pp->getValue($request);
142145
if (is_array($p)) {
143146
foreach ($p as $key => $value) {
@@ -147,13 +150,15 @@ public static function serializeInput(RequestModel $request, OperationInput $inp
147150

148151
//payload
149152
$pd = $ro->getProperty('payload');
153+
$pd->setAccessible(true);
150154
$payload = $pd->getValue($request);
151155
if ($payload instanceof StreamInterface) {
152156
$input->setBody($payload);
153157
}
154158

155159
// all properties in request
156160
foreach ($ro->getProperties() as $property) {
161+
$property->setAccessible(true);
157162
$val = $property->getValue($request);
158163
if (!isset($val)) {
159164
if (Functions::isRequiredProperty($property)) {

0 commit comments

Comments
 (0)