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

Skip to content

Remove dead code in the PropertyPath constructor #16310

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions src/Symfony/Component/PropertyAccess/PropertyPath.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,6 @@ public function getAxes()
}
}

class PropertyAccessorCollectionTest_CarCustomSingular
{
public function addFoo($axis)
{
}

public function removeFoo($axis)
{
}

public function getAxes()
{
}
}

class PropertyAccessorCollectionTest_Engine
{
}
Expand Down Expand Up @@ -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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down