Skip to content

Commit

Permalink
Fix PathItem::resolveReferences() for array fields
Browse files Browse the repository at this point in the history
Fixed path references resolution fail tied to a dynamic prop modification:
dynamic attribute array references were not resolving, producing an E_NOTICE.

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.

close #87
close #102

Co-authored-by: rv1971 <[email protected]>
  • Loading branch information
2 people authored and cebe committed May 24, 2021
1 parent 6d2a7bb commit 54d9d01
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/spec/PathItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ 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();
}
Expand Down

0 comments on commit 54d9d01

Please sign in to comment.