Skip to content

Commit 56875dd

Browse files
committed
Fix PathItem::resolveReferences() for array fields
The previous code `$this->$attribute[$k] = $referencedObject` had no effect if the value of `$attribute` is an array (as for instance in the case of `parameters`), because `$this->$attribute` invokes `SpecBaseObject::__get()`, which does *not* return a reference. Indeed PHP issued `Notice: Indirect modification of overloaded property cebe\openapi\spec\PathItem::$parameters has no effect` in this case.
1 parent dac8870 commit 56875dd

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/spec/PathItem.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ public function resolveReferences(ReferenceContext $context = null)
174174
foreach ($this->$attribute as $k => $item) {
175175
if ($item instanceof Reference) {
176176
$referencedObject = $item->resolve();
177-
$this->$attribute[$k] = $referencedObject;
177+
$this->$attribute =
178+
[ $k => $referencedObject ] + $this->$attribute;
178179
if (!$referencedObject instanceof Reference && $referencedObject !== null) {
179180
$referencedObject->resolveReferences();
180181
}

0 commit comments

Comments
 (0)