Skip to content

Commit 830a84e

Browse files
author
Dominic Tubach
committed
Support properties named properties
1 parent 8425da6 commit 830a84e

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/JsonForms/ScopePointer.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,24 @@ public function getPath(): array {
8484
* @return array<string|int>
8585
*/
8686
public function getPropertyPath(): array {
87-
return array_values(array_filter($this->getPath(), fn ($value) => 'properties' !== $value && '' !== $value));
87+
$consecutivePropertiesCount = 0;
88+
return array_values(array_filter(
89+
$this->getPath(),
90+
function ($value) use (&$consecutivePropertiesCount) {
91+
// There might be a property named "properties" and the corresponding
92+
// scope would contain ".../properties/properties/properties/...". Thus,
93+
// we cannot just filter out every occurrence of "properties".
94+
if ('properties' === $value) {
95+
$consecutivePropertiesCount++;
96+
97+
return $consecutivePropertiesCount % 2 === 0;
98+
}
99+
100+
$consecutivePropertiesCount = 0;
101+
102+
return '' !== $value;
103+
}
104+
));
88105
}
89106

90107
public function getScope(): string {

0 commit comments

Comments
 (0)