Symfony\Component\DomCrawler\Crawler::siblings PHP Method

siblings() public method

Returns the siblings nodes of the current selection.
public siblings ( ) : Crawler
return Crawler A Crawler instance with the sibling nodes
    public function siblings()
    {
        if (!$this->nodes) {
            throw new \InvalidArgumentException('The current node list is empty.');
        }
        return $this->createSubCrawler($this->sibling($this->getNode(0)->parentNode->firstChild));
    }

Usage Example

 /**
  * @param Crawler $block
  */
 public function climbToHighestParent(Crawler &$block)
 {
     while ($block->siblings()->getNode(0) == null) {
         $block = $block->parents()->first();
     }
 }