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

Context::getCurrentPath() returns indexes of list items #1325

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

katin-dev
Copy link

Implementing ExclusionStrategyInterface i realized that there is no way to detect if current element is part on the list with specific index.

For example, we have a class

class Node {
  public string $name;
  /** @var Node[] */
  public array $children;
}

When one of $children element has been passed to shouldSkipProperty(PropertyMetadata $property, Context $context), i don't know which one. Context does not know the index of such element. But i have external rules like so which define whether property of element should be serialized or not:

$rules = [
  'children' => [
    0 => ['name'],
    2 => ['name', 'children']
  ]
]

I suggest $context->getCurrentPath() should return array like so: [children][0]['name'] instead of [children]['name'] (current behavior)

Q A
Bug fix? yes
New feature? no
Doc updated no
BC breaks? likely so
Deprecations? no
Tests pass? yes
Fixed tickets
License MIT

@katin-dev
Copy link
Author

@goetas why Scrutinizer Canceled? What should I do to rerun it?

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.

None yet

1 participant