Skip to content

[DomCrawler] Removed deprecated code #41355

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
May 23, 2021
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
5 changes: 5 additions & 0 deletions src/Symfony/Component/DomCrawler/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

6.0
---

* Remove `Crawler::parents()` method, use `ancestors()` instead

5.3
---

Expand Down
14 changes: 0 additions & 14 deletions src/Symfony/Component/DomCrawler/Crawler.php
Original file line number Diff line number Diff line change
Expand Up @@ -493,20 +493,6 @@ public function previousAll()
return $this->createSubCrawler($this->sibling($this->getNode(0), 'previousSibling'));
}

/**
* Returns the parent nodes of the current selection.
*
* @return static
*
* @throws \InvalidArgumentException When current node is empty
*/
public function parents()
{
trigger_deprecation('symfony/dom-crawler', '5.3', 'The %s() method is deprecated, use ancestors() instead.', __METHOD__);

return $this->ancestors();
}

/**
* Returns the ancestors of the current selection.
*
Expand Down
25 changes: 0 additions & 25 deletions src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1088,31 +1088,6 @@ public function testFilteredChildren()
$this->assertEquals(1, $foo->children('.ipsum')->count());
}

/**
* @group legacy
*/
public function testParents()
{
$this->expectDeprecation('Since symfony/dom-crawler 5.3: The Symfony\Component\DomCrawler\Crawler::parents() method is deprecated, use ancestors() instead.');

$crawler = $this->createTestCrawler()->filterXPath('//li[1]');
$this->assertNotSame($crawler, $crawler->parents(), '->parents() returns a new instance of a crawler');
$this->assertInstanceOf(Crawler::class, $crawler->parents(), '->parents() returns a new instance of a crawler');

$nodes = $crawler->parents();
$this->assertEquals(3, $nodes->count());

$nodes = $this->createTestCrawler()->filterXPath('//html')->parents();
$this->assertEquals(0, $nodes->count());

try {
$this->createTestCrawler()->filterXPath('//ol')->parents();
$this->fail('->parents() throws an \InvalidArgumentException if the node list is empty');
} catch (\InvalidArgumentException $e) {
$this->assertTrue(true, '->parents() throws an \InvalidArgumentException if the node list is empty');
}
}

public function testAncestors()
{
$crawler = $this->createTestCrawler()->filterXPath('//li[1]');
Expand Down