Skip to content

Commit eb256a3

Browse files
authored
Merge pull request #239 from dsavina/improvement/method-name-collision
Improvement - Do not use alternative method name for first occurrence
2 parents ed4baa8 + 9fbe07d commit eb256a3

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/Utils/BeanDescriptor.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -470,9 +470,17 @@ private function checkForDuplicate(MethodDescriptorInterface $descriptor): void
470470
$this->descriptorsByMethodName[$name] = [];
471471
}
472472
$this->descriptorsByMethodName[$name][] = $descriptor;
473-
if (count($this->descriptorsByMethodName[$name]) > 1) {
474-
foreach ($this->descriptorsByMethodName[$name] as $duplicateDescriptor) {
475-
$duplicateDescriptor->useAlternativeName();
473+
$descriptors = $this->descriptorsByMethodName[$name];
474+
if (count($descriptors) > 1) {
475+
$properties = array_filter($descriptors, function ($descriptor) {
476+
return $descriptor instanceof AbstractBeanPropertyDescriptor;
477+
});
478+
$renameProperties = count($properties) > 1;
479+
480+
foreach ($descriptors as $descriptor) {
481+
if ($renameProperties || !$descriptor instanceof AbstractBeanPropertyDescriptor) {
482+
$descriptor->useAlternativeName();
483+
}
476484
}
477485
}
478486
}

0 commit comments

Comments
 (0)