Skip to content

Commit 6848b94

Browse files
committed
wrapObject=false is only for encode object
1 parent 2c805b6 commit 6848b94

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

generator/src/Definition/OperatorDefinition.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ public function __construct(
4343
default => throw new UnexpectedValueException(sprintf('Unexpected "encode" value for operator "%s". Got "%s"', $name, $encode)),
4444
};
4545

46+
if (!$wrapObject && $this->encode !== Encode::Object) {
47+
throw new UnexpectedValueException(sprintf('Operator "%s" cannot have wrapObject set to false when encode is not "object"', $name));
48+
}
49+
4650
// Convert arguments to ArgumentDefinition objects
4751
// Optional arguments must be after required arguments
4852
$requiredArgs = $optionalArgs = [];

psalm-baseline.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,6 @@
7575
<code><![CDATA[$val]]></code>
7676
<code><![CDATA[$val]]></code>
7777
</MixedAssignment>
78-
<MixedInferredReturnType>
79-
<code><![CDATA[stdClass]]></code>
80-
</MixedInferredReturnType>
81-
<MixedReturnStatement>
82-
<code><![CDATA[$result]]></code>
83-
</MixedReturnStatement>
8478
<PossibleRawObjectIteration>
8579
<code><![CDATA[$val]]></code>
8680
</PossibleRawObjectIteration>

src/Builder/Encoder/OperatorEncoder.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ private function encodeAsObject(OperatorInterface $value): stdClass
8989
}
9090
}
9191

92+
if ($value::NAME === null) {
93+
return $result;
94+
}
95+
9296
return $this->wrap($value, $result);
9397
}
9498

@@ -113,9 +117,7 @@ private function encodeAsSingle(OperatorInterface $value): stdClass
113117
*/
114118
private function wrap(OperatorInterface $value, mixed $result): stdClass
115119
{
116-
if ($value::NAME === null) {
117-
return $result;
118-
}
120+
assert(is_string($value::NAME));
119121

120122
$object = new stdClass();
121123
$object->{$value::NAME} = $result;

0 commit comments

Comments
 (0)