From 56875ddf59d46e21ac4176feafa9aeaa99905dbb Mon Sep 17 00:00:00 2001 From: rv1971 Date: Mon, 14 Dec 2020 16:59:25 +0100 Subject: [PATCH] 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. --- src/spec/PathItem.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/spec/PathItem.php b/src/spec/PathItem.php index 236bda8..3bd0565 100644 --- a/src/spec/PathItem.php +++ b/src/spec/PathItem.php @@ -174,7 +174,8 @@ public function resolveReferences(ReferenceContext $context = null) foreach ($this->$attribute as $k => $item) { if ($item instanceof Reference) { $referencedObject = $item->resolve(); - $this->$attribute[$k] = $referencedObject; + $this->$attribute = + [ $k => $referencedObject ] + $this->$attribute; if (!$referencedObject instanceof Reference && $referencedObject !== null) { $referencedObject->resolveReferences(); }