Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitf50f92a

Browse files
committed
bug#16911 [PropertyInfo] Update List Information from ReflectionExtractor (zanderbaldwin)
This PR was squashed before being merged into the 2.8 branch (closes#16911).Discussion----------[PropertyInfo] Update List Information from ReflectionExtractor| Q | A| ------------- | ---| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#16889| License | MIT| Doc PR |symfony/symfony-docs#5974Unless a property with the same casing exists, lowercase the first letter of a property name extracted from a method. From what I understand, we don't actually need to support `snake_case` at all in the PropertyInfo component.I cannot think of any use-case where PropertyAccess would be used to get/set a property value *before* using PropertyInfo to find out information about the property and the values it supports.Since PropertyInfo supports the discovery of property names, which can then be used as identifiers in PropertyAccess, there should be no need to support a naming strategy to map property identifiers from one naming convention to another.---Running `$reflectionExtractor->getProperties($class)` with the following classes:```phpclass X{ public $a; public $b; public function getA() {}}// Result: array('a', 'b');``````phpclass Y{ public $A; public $b; public function setA() {}}// Result: array('A', 'b');``````phpclass Y{ public $username; protected $emailAddress; public $password; public function getEmailAddress() {} public function isActive() {}}// Result: array('username', 'emailAddress', 'password', 'active');```Commits-------b2da76c [PropertyInfo] Update List Information from ReflectionExtractor
2 parents25b89d4 +b2da76c commitf50f92a

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,13 @@ public function getProperties($class, array $context = array())
6262

6363
foreach ($reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC)as$reflectionMethod) {
6464
$propertyName =$this->getPropertyName($reflectionMethod->name);
65-
if ($propertyName) {
66-
$properties[$propertyName] =true;
65+
if (!$propertyName ||isset($properties[$propertyName])) {
66+
continue;
6767
}
68+
if (!preg_match('/^[A-Z]{2,}/',$propertyName)) {
69+
$propertyName =lcfirst($propertyName);
70+
}
71+
$properties[$propertyName] =true;
6872
}
6973

7074
returnarray_keys($properties);

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,19 @@ public function testGetProperties()
3636
'bal',
3737
'parent',
3838
'collection',
39+
'B',
3940
'foo',
4041
'foo2',
4142
'foo3',
4243
'foo4',
4344
'foo5',
4445
'files',
45-
'A',
46-
'B',
47-
'C',
48-
'D',
49-
'E',
50-
'F',
46+
'a',
47+
'DOB',
48+
'c',
49+
'd',
50+
'e',
51+
'f',
5152
),
5253
$this->extractor->getProperties('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy')
5354
);

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ class Dummy extends ParentDummy
4646
*/
4747
public$collection;
4848

49+
/**
50+
* @var ParentDummy
51+
*/
52+
public$B;
53+
4954
/**
5055
* A.
5156
*
@@ -63,4 +68,13 @@ public function getA()
6368
publicfunctionsetB(ParentDummy$parent =null)
6469
{
6570
}
71+
72+
/**
73+
* Date of Birth.
74+
*
75+
* @return \DateTime
76+
*/
77+
publicfunctiongetDOB()
78+
{
79+
}
6680
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp