src/Compiler.php
protected function joinSelectors($parent, $child, $selfParentSelectors = null)
    {
        $setSelf = false;
        $out = [];

        foreach ($child as $part) {
            $newPart = [];

            foreach ($part as $p) {
                if ($p === static::$selfSelector) {
                    $setSelf = true;

                    if (is_null($selfParentSelectors)) {
                        $selfParentSelectors = $parent;
                    }

                    foreach ($selfParentSelectors as $i => $parentPart) {
                        if ($i > 0) {
                            $out[] = $newPart;
                            $newPart = [];
                        }

                        foreach ($parentPart as $pp) {
                            if (is_array($pp)) {
                                $flatten = [];
                                array_walk_recursive($pp, function ($a) use (&$flatten) {
                                    $flatten[] = $a;
                                });
                                $pp = implode($flatten);
                            }
                            $newPart[] = $pp;
                        }
                    }
                } else {
                    $newPart[] = $p;
                }
            }

            $out[] = $newPart;
        }

        return $setSelf ? $out : array_merge($parent, $child);
    }
protected function joinSelectors($parent, $child, $selfParentSelectors = null)
    {
        $setSelf = false;
        $out = [];

        foreach ($child as $part) {
            $newPart = [];

            foreach ($part as $p) {
                if ($p === static::$selfSelector) {
                    $setSelf = true;

                    if (is_null($selfParentSelectors)) {
                        $selfParentSelectors = $parent;
                    }

                    foreach ($selfParentSelectors as $i => $parentPart) {
                        if ($i > 0) {
                            $out[] = $newPart;
                            $newPart = [];
                        }

                        foreach ($parentPart as $pp) {
                            if (is_array($pp)) {
                                $flatten = [];
                                array_walk_recursive($pp, function ($a) use (&$flatten) {
                                    $flatten[] = $a;
                                });
                                $pp = implode($flatten);
                            }
                            $newPart[] = $pp;
                        }
                    }
                } else {
                    $newPart[] = $p;
                }
            }

            $out[] = $newPart;
        }

        return $setSelf ? $out : array_merge($parent, $child);
    }
protected function joinSelectors ( $ parent , $ child , $ selfParentSelectors = null ) { $ setSelf = false ; $ out = [ ] ; foreach ( $ child as $ part ) { $ newPart = [ ] ; foreach ( $ part as $ p ) { if ( $ p === static :: $ selfSelector ) { $ setSelf = true ; if ( is_null ( $ selfParentSelectors ) ) { $ selfParentSelectors = $ parent ; } foreach ( $ selfParentSelectors as $ i => $ parentPart ) { if ( $ i > 0 ) { $ out [ ] = $ newPart ; $ newPart = [ ] ; } foreach ( $ parentPart as $ pp ) { if ( is_array ( $ pp ) ) { $ flatten = [ ] ; array_walk_recursive ( $ pp , function ( $ a ) use ( & $ flatten ) { $ flatten [ ] = $ a ; } ) ; $ pp = implode ( $ flatten ) ; } $ newPart [ ] = $ pp ; } } } else { $ newPart [ ] = $ p ; } } $ out [ ] = $ newPart ; } return $ setSelf ? $ out : array_merge ( $ parent , $ child ) ; }
Join selectors; looks for & to replace, or append parent before child

@param array $parent
@param array $child
@param array $selfParentSelectors

@return array
Join selectors ; looks for & to replace or append parent before child