From ad4d0eb79ab5ec006f9ae68bacdf43d2ee855e97 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Wed, 21 Oct 2015 14:43:04 +0200 Subject: [PATCH] Remove dead code in the PropertyPath constructor Custom singulars have been removed from the component before merging it in Symfony, but the code parsing them was only removed partially. --- .../Component/PropertyAccess/PropertyPath.php | 18 --------- .../Tests/PropertyAccessorCollectionTest.php | 39 ------------------- .../Tests/PropertyAccessorTest.php | 9 ----- 3 files changed, 66 deletions(-) diff --git a/src/Symfony/Component/PropertyAccess/PropertyPath.php b/src/Symfony/Component/PropertyAccess/PropertyPath.php index 9e44d8b752dfa..4d964c2d8a383 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyPath.php +++ b/src/Symfony/Component/PropertyAccess/PropertyPath.php @@ -36,13 +36,6 @@ class PropertyPath implements \IteratorAggregate, PropertyPathInterface */ private $elements = array(); - /** - * The singular forms of the elements in the property path. - * - * @var array - */ - private $singulars = array(); - /** * The number of elements in the property path. * @@ -79,7 +72,6 @@ public function __construct($propertyPath) if ($propertyPath instanceof self) { /* @var PropertyPath $propertyPath */ $this->elements = $propertyPath->elements; - $this->singulars = $propertyPath->singulars; $this->length = $propertyPath->length; $this->isIndex = $propertyPath->isIndex; $this->pathAsString = $propertyPath->pathAsString; @@ -110,16 +102,7 @@ public function __construct($propertyPath) $this->isIndex[] = true; } - $pos = false; - $singular = null; - - if (false !== $pos) { - $singular = substr($element, $pos + 1); - $element = substr($element, 0, $pos); - } - $this->elements[] = $element; - $this->singulars[] = $singular; $position += strlen($matches[1]); $remaining = $matches[4]; @@ -168,7 +151,6 @@ public function getParent() --$parent->length; $parent->pathAsString = substr($parent->pathAsString, 0, max(strrpos($parent->pathAsString, '.'), strrpos($parent->pathAsString, '['))); array_pop($parent->elements); - array_pop($parent->singulars); array_pop($parent->isIndex); return $parent; diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php index 08e6e5e6d04b9..9f10b95e438c8 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php @@ -46,21 +46,6 @@ public function getAxes() } } -class PropertyAccessorCollectionTest_CarCustomSingular -{ - public function addFoo($axis) - { - } - - public function removeFoo($axis) - { - } - - public function getAxes() - { - } -} - class PropertyAccessorCollectionTest_Engine { } @@ -237,30 +222,6 @@ public function testSetValueCallsAdderAndRemoverForNestedCollections() $this->propertyAccessor->setValue($car, 'structure.axes', $axesAfter); } - public function testSetValueCallsCustomAdderAndRemover() - { - $this->markTestSkipped('This feature is temporarily disabled as of 2.1'); - - $car = $this->getMock(__CLASS__.'_CarCustomSingular'); - $axesBefore = $this->getCollection(array(1 => 'second', 3 => 'fourth')); - $axesAfter = $this->getCollection(array(0 => 'first', 1 => 'second', 2 => 'third')); - - $car->expects($this->at(0)) - ->method('getAxes') - ->will($this->returnValue($axesBefore)); - $car->expects($this->at(1)) - ->method('removeFoo') - ->with('fourth'); - $car->expects($this->at(2)) - ->method('addFoo') - ->with('first'); - $car->expects($this->at(3)) - ->method('addFoo') - ->with('third'); - - $this->propertyAccessor->setValue($car, 'axes|foo', $axesAfter); - } - /** * @expectedException \Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException */ diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php index 87287048a7752..5b127e1bc403d 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php @@ -112,15 +112,6 @@ public function testGetValueNotModifyObject() $this->assertSame(array('Bernhard'), $object->firstName); } - public function testGetValueIgnoresSingular() - { - $this->markTestSkipped('This feature is temporarily disabled as of 2.1'); - - $object = (object) array('children' => 'Many'); - - $this->assertEquals('Many', $this->propertyAccessor->getValue($object, 'children|child')); - } - public function testGetValueReadsPropertyWithSpecialCharsExceptDot() { $array = (object) array('%!@$ยง' => 'Bernhard');