From 37cc16e3d8fd7685ee1618b0beae055bf63c5767 Mon Sep 17 00:00:00 2001 From: YaFou <33806646+YaFou@users.noreply.github.com> Date: Tue, 19 Jan 2021 20:11:07 +0100 Subject: [PATCH] [PropertyInfo] Fix breaking change with has*(arguments...) methods --- .../PropertyInfo/Extractor/ReflectionExtractor.php | 2 +- .../Tests/Extractor/ReflectionExtractorTest.php | 2 ++ src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php b/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php index a4725ba3ceec5..2cb7c8cf5d1eb 100644 --- a/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php +++ b/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php @@ -239,7 +239,7 @@ public function getReadInfo(string $class, string $property, array $context = [] 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); diff --git a/src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php b/src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php index 6998467e57d8b..b4f861ce35c4b 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php @@ -75,6 +75,7 @@ public function testGetProperties() 'xTotals', 'YT', 'date', + 'element', 'c', 'd', 'e', @@ -291,6 +292,7 @@ public function getReadableProperties() ['id', true], ['Guid', true], ['guid', false], + ['element', false], ]; } diff --git a/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php b/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php index bcec074438948..d94148ddc3a07 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php @@ -130,6 +130,8 @@ class Dummy extends ParentDummy */ public $nestedIterators; + private $elements; + public static function getStatic() { } @@ -218,4 +220,8 @@ public function setDate(\DateTime $date) public function addDate(\DateTime $date) { } + + public function hasElement(string $element): bool + { + } }
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: