Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 25d1299

Browse filesBrowse files
committed
[PropertyInfo] Fix breaking change with has*(arguments...) methods
1 parent 6510b04 commit 25d1299
Copy full SHA for 25d1299

File tree

3 files changed

+12
-2
lines changed
Filter options

3 files changed

+12
-2
lines changed

‎src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,12 @@ public function getReadInfo(string $class, string $property, array $context = []
239239
foreach ($this->accessorPrefixes as $prefix) {
240240
$methodName = $prefix.$camelProp;
241241

242-
if ($reflClass->hasMethod($methodName) && ($reflClass->getMethod($methodName)->getModifiers() & $this->methodReflectionFlags)) {
242+
if ($reflClass->hasMethod($methodName)) {
243243
$method = $reflClass->getMethod($methodName);
244244

245-
return new PropertyReadInfo(PropertyReadInfo::TYPE_METHOD, $methodName, $this->getReadVisiblityForMethod($method), $method->isStatic(), false);
245+
if ($method->getModifiers() & $this->methodReflectionFlags && 0 === $method->getNumberOfRequiredParameters()) {
246+
return new PropertyReadInfo(PropertyReadInfo::TYPE_METHOD, $methodName, $this->getReadVisiblityForMethod($method), $method->isStatic(), false);
247+
}
246248
}
247249
}
248250

‎src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public function testGetProperties()
7575
'xTotals',
7676
'YT',
7777
'date',
78+
'element',
7879
'c',
7980
'd',
8081
'e',
@@ -291,6 +292,7 @@ public function getReadableProperties()
291292
['id', true],
292293
['Guid', true],
293294
['guid', false],
295+
['element', false],
294296
];
295297
}
296298

‎src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ class Dummy extends ParentDummy
130130
*/
131131
public $nestedIterators;
132132

133+
private $elements;
134+
133135
public static function getStatic()
134136
{
135137
}
@@ -218,4 +220,8 @@ public function setDate(\DateTime $date)
218220
public function addDate(\DateTime $date)
219221
{
220222
}
223+
224+
public function hasElement(string $element): bool
225+
{
226+
}
221227
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.