Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d0e88ca

Browse files
committed
minor #16310 Remove dead code in the PropertyPath constructor (stof)
This PR was merged into the 2.3 branch. Discussion ---------- Remove dead code in the PropertyPath constructor | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Custom singulars have been removed from the component before merging it in Symfony, but the code parsing them was only removed partially. Commits ------- ad4d0eb Remove dead code in the PropertyPath constructor
2 parents 594d8be + ad4d0eb commit d0e88ca

File tree

3 files changed

+0
-66
lines changed

3 files changed

+0
-66
lines changed

src/Symfony/Component/PropertyAccess/PropertyPath.php

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@ class PropertyPath implements \IteratorAggregate, PropertyPathInterface
3636
*/
3737
private $elements = array();
3838

39-
/**
40-
* The singular forms of the elements in the property path.
41-
*
42-
* @var array
43-
*/
44-
private $singulars = array();
45-
4639
/**
4740
* The number of elements in the property path.
4841
*
@@ -79,7 +72,6 @@ public function __construct($propertyPath)
7972
if ($propertyPath instanceof self) {
8073
/* @var PropertyPath $propertyPath */
8174
$this->elements = $propertyPath->elements;
82-
$this->singulars = $propertyPath->singulars;
8375
$this->length = $propertyPath->length;
8476
$this->isIndex = $propertyPath->isIndex;
8577
$this->pathAsString = $propertyPath->pathAsString;
@@ -110,16 +102,7 @@ public function __construct($propertyPath)
110102
$this->isIndex[] = true;
111103
}
112104

113-
$pos = false;
114-
$singular = null;
115-
116-
if (false !== $pos) {
117-
$singular = substr($element, $pos + 1);
118-
$element = substr($element, 0, $pos);
119-
}
120-
121105
$this->elements[] = $element;
122-
$this->singulars[] = $singular;
123106

124107
$position += strlen($matches[1]);
125108
$remaining = $matches[4];
@@ -168,7 +151,6 @@ public function getParent()
168151
--$parent->length;
169152
$parent->pathAsString = substr($parent->pathAsString, 0, max(strrpos($parent->pathAsString, '.'), strrpos($parent->pathAsString, '[')));
170153
array_pop($parent->elements);
171-
array_pop($parent->singulars);
172154
array_pop($parent->isIndex);
173155

174156
return $parent;

src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,6 @@ public function getAxes()
4646
}
4747
}
4848

49-
class PropertyAccessorCollectionTest_CarCustomSingular
50-
{
51-
public function addFoo($axis)
52-
{
53-
}
54-
55-
public function removeFoo($axis)
56-
{
57-
}
58-
59-
public function getAxes()
60-
{
61-
}
62-
}
63-
6449
class PropertyAccessorCollectionTest_Engine
6550
{
6651
}
@@ -237,30 +222,6 @@ public function testSetValueCallsAdderAndRemoverForNestedCollections()
237222
$this->propertyAccessor->setValue($car, 'structure.axes', $axesAfter);
238223
}
239224

240-
public function testSetValueCallsCustomAdderAndRemover()
241-
{
242-
$this->markTestSkipped('This feature is temporarily disabled as of 2.1');
243-
244-
$car = $this->getMock(__CLASS__.'_CarCustomSingular');
245-
$axesBefore = $this->getCollection(array(1 => 'second', 3 => 'fourth'));
246-
$axesAfter = $this->getCollection(array(0 => 'first', 1 => 'second', 2 => 'third'));
247-
248-
$car->expects($this->at(0))
249-
->method('getAxes')
250-
->will($this->returnValue($axesBefore));
251-
$car->expects($this->at(1))
252-
->method('removeFoo')
253-
->with('fourth');
254-
$car->expects($this->at(2))
255-
->method('addFoo')
256-
->with('first');
257-
$car->expects($this->at(3))
258-
->method('addFoo')
259-
->with('third');
260-
261-
$this->propertyAccessor->setValue($car, 'axes|foo', $axesAfter);
262-
}
263-
264225
/**
265226
* @expectedException \Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException
266227
*/

src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,6 @@ public function testGetValueNotModifyObject()
112112
$this->assertSame(array('Bernhard'), $object->firstName);
113113
}
114114

115-
public function testGetValueIgnoresSingular()
116-
{
117-
$this->markTestSkipped('This feature is temporarily disabled as of 2.1');
118-
119-
$object = (object) array('children' => 'Many');
120-
121-
$this->assertEquals('Many', $this->propertyAccessor->getValue($object, 'children|child'));
122-
}
123-
124115
public function testGetValueReadsPropertyWithSpecialCharsExceptDot()
125116
{
126117
$array = (object) array('%!@$§' => 'Bernhard');

0 commit comments

Comments
 (0)