protected function extractRelationshipFromFragment(array $fragment)
    {
        $parents = [];
        $children = [];
        $j = $i = count($fragment);

        for (;;) {
            $children = $j != $i ? array_slice($fragment, $j, $i - $j) : [];
            $parents = array_slice($fragment, 0, $j);
            $slice = end($parents);

            if (empty($slice) || ! $this->isImmediateRelationshipCombinator($slice[0])) {
                break;
            }

            $j -= 2;
        }

        return [$parents, $children];
    }
protected function extractRelationshipFromFragment(array $fragment)
    {
        $parents = [];
        $children = [];
        $j = $i = count($fragment);

        for (;;) {
            $children = $j != $i ? array_slice($fragment, $j, $i - $j) : [];
            $parents = array_slice($fragment, 0, $j);
            $slice = end($parents);

            if (empty($slice) || ! $this->isImmediateRelationshipCombinator($slice[0])) {
                break;
            }

            $j -= 2;
        }

        return [$parents, $children];
    }
protected function extractRelationshipFromFragment ( array $ fragment ) { $ parents = [ ] ; $ children = [ ] ; $ j = $ i = count ( $ fragment ) ; for ( ; ; ) { $ children = $ j != $ i ? array_slice ( $ fragment , $ j , $ i - $ j ) : [ ] ; $ parents = array_slice ( $ fragment , 0 , $ j ) ; $ slice = end ( $ parents ) ; if ( empty ( $ slice ) || ! $ this -> isImmediateRelationshipCombinator ( $ slice [ 0 ] ) ) { break ; } $ j -= 2 ; } return [ $ parents , $ children ] ; }
Extract a relationship from the fragment.

When extracting the last portion of a selector we will be left with a
fragment which may end with a direction relationship combinator. This
method will extract the relationship fragment and return it along side
the rest.

@param array $fragment The selector fragment maybe ending with a direction relationship combinator.
@return array The selector without the relationship fragment if any, the relationship fragment.
Extract a relationship from the fragment .