Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PathItem::resolveReferences() for array fields #87

Closed
wants to merge 1 commit into from

Conversation

rv1971
Copy link
Contributor

@rv1971 rv1971 commented Dec 14, 2020

With the previous code $this->$attribute[$k] = $referencedObject, PHP issues Notice: 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.

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.
@rv1971 rv1971 force-pushed the path-item-resolve-refs-array branch from b736548 to 56875dd Compare December 14, 2020 16:39
@cebe
Copy link
Owner

cebe commented Dec 14, 2020

Sorry, I don't understand what you are trying to fix here. Would you be able to add failing test case for this?

@cebe cebe added the needs more info More information is needed to reproduce the issue. label Dec 14, 2020
@rv1971
Copy link
Contributor Author

rv1971 commented Dec 15, 2020

The attached testcase.zip (3 files) is the simplest test case I could derive from my data. If you run php-openapi convert --write-json openapi.json on it, the result is

PHP Notice: Indirect modification of overloaded property cebe\openapi\spec\PathItem::$parameters has no effect in /home/rve/src/php-openapi/src/spec/PathItem.php on line 177
Notice: Indirect modification of overloaded property cebe\openapi\spec\PathItem::$parameters has no effect in /home/rve/src/php-openapi/src/spec/PathItem.php on line 177
{
"openapi": "3.0.3",
"info": {
"title": "Foo",
"version": "0.42.0"
},
"paths": {
"/foo": {
"servers": [],
"parameters": [
{
"name": "X-Param",
"in": "header"
}
]
}
}
}

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.

@cebe cebe self-assigned this Dec 21, 2020
@cebe cebe added bug Something isn't working and removed needs more info More information is needed to reproduce the issue. labels Dec 23, 2020
@cebe cebe added this to the 1.6.0 milestone Dec 23, 2020
@iZucken iZucken mentioned this pull request Mar 1, 2021
@cebe cebe modified the milestones: 1.6.0, 1.5.2 Apr 20, 2021
@cebe cebe closed this in 54d9d01 May 24, 2021
@cebe
Copy link
Owner

cebe commented May 24, 2021

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants