[PropertyInfo] Fix breaking change with has*(arguments...) methods

This commit is contained in:
YaFou 2021-01-19 20:11:07 +01:00
parent 6510b047e6
commit 37cc16e3d8
No known key found for this signature in database
GPG Key ID: A112DE339CED408A
3 changed files with 9 additions and 1 deletions

View File

@ -239,7 +239,7 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
foreach ($this->accessorPrefixes as $prefix) {
$methodName = $prefix.$camelProp;
if ($reflClass->hasMethod($methodName) && ($reflClass->getMethod($methodName)->getModifiers() & $this->methodReflectionFlags)) {
if ($reflClass->hasMethod($methodName) && $reflClass->getMethod($methodName)->getModifiers() & $this->methodReflectionFlags && !$reflClass->getMethod($methodName)->getNumberOfRequiredParameters()) {
$method = $reflClass->getMethod($methodName);
return new PropertyReadInfo(PropertyReadInfo::TYPE_METHOD, $methodName, $this->getReadVisiblityForMethod($method), $method->isStatic(), false);

View File

@ -75,6 +75,7 @@ class ReflectionExtractorTest extends TestCase
'xTotals',
'YT',
'date',
'element',
'c',
'd',
'e',
@ -291,6 +292,7 @@ class ReflectionExtractorTest extends TestCase
['id', true],
['Guid', true],
['guid', false],
['element', false],
];
}

View File

@ -130,6 +130,8 @@ class Dummy extends ParentDummy
*/
public $nestedIterators;
private $elements;
public static function getStatic()
{
}
@ -218,4 +220,8 @@ class Dummy extends ParentDummy
public function addDate(\DateTime $date)
{
}
public function hasElement(string $element): bool
{
}
}