Skip to content

Conversation

baspeeters
Copy link
Contributor

To maintainers @dunglas, @sroze or @theofidry

Setting up a config where a child class inherits its parent's properties
through class inheritance did not work.

The logic in TypesGenerator handled implicit inheritance based on
whether the parent's properties key was not set or not an array, but did
not account for empty arrays.

Also added tests for these implicit and explicit cases.

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #150
License MIT
Doc PR N/A

@baspeeters baspeeters force-pushed the bugfix/property-inheritance branch from 5df6b19 to 0aec771 Compare December 19, 2018 08:15

// Third pass
foreach ($classes as &$class) {
foreach ($classes as $classKey => &$class) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is classKey used for? I think we can remove this unused variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@soyuka You're right, it's unused. I've removed it.

@baspeeters baspeeters force-pushed the bugfix/property-inheritance branch 4 times, most recently from 8706c1a to cbda773 Compare July 20, 2019 04:47
@baspeeters
Copy link
Contributor Author

Had pushed some changes because coverage tests for php 7.2 were failing, but that appears to be unrelated.

Setting up a config where a child class inherits its parent's  properties
through class inheritance did not work.

The logic in TypesGenerator handled implicit inheritance based on
whether the parent's properties key was not set or not an array, but did
not account for empty arrays.

Also added tests for these implicit and explicit cases.
@baspeeters baspeeters force-pushed the bugfix/property-inheritance branch from cbda773 to 050d2c1 Compare July 21, 2019 16:47
@soyuka
Copy link
Member

soyuka commented Jul 22, 2019

wdyt @teohhanhui ? LGTM, though it should target 2.x branch as a bug fix?

if (!isset($parentConfig['properties']) || !is_array($parentConfig['properties'])) {
if (!isset($parentConfig['properties']) ||
!is_array($parentConfig['properties']) ||
0 === count($parentConfig['properties'])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's weird: is_array([]) returns true. What the type of the value in this case?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be '' === $parentConfig['properties'] then right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's weird: is_array([]) returns true. What the type of the value in this case?

is_array([]) should return true, as [] is indeed an array, even if it's empty.

Should be '' === $parentConfig['properties'] then right?

This is already caught by !is_array($parentConfig['properties']).

@dunglas dunglas merged commit 29d0422 into api-platform:master Oct 4, 2019
@dunglas
Copy link
Member

dunglas commented Oct 4, 2019

Thanks @baspeeters

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants