Fix PathItem::resolveReferences() for array fields#87
Fix PathItem::resolveReferences() for array fields#87rv1971 wants to merge 1 commit intocebe:masterfrom
Conversation
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.
b736548 to
56875dd
Compare
|
Sorry, I don't understand what you are trying to fix here. Would you be able to add failing test case for this? |
|
The attached testcase.zip (3 files) is the simplest test case I could derive from my data. If you run
Actually, despite of the notices, the result seems to be correct. To be honest, I did never check the result as such because I think this kind of notices, which suggest there is something wrong in the code, is misleading and should be avoided. |
|
Thank you! |
With the previous code
$this->$attribute[$k] = $referencedObject, PHP issuesNotice: Indirect modification of overloaded property cebe\openapi\spec\PathItem::$parameters has no effect.The simplest fix I could think of is
$this->$attribute = [ $k => $referencedObject ] + $this->$attribute.