protected function matchExtendsSingle($single, &$outOrigin)
{
$counts = array();
foreach ($single as $part) {
if (!is_string($part)) {
return false;
}
// hmm
if (isset($this->extendsMap[$part])) {
foreach ($this->extendsMap[$part] as $idx) {
$counts[$idx] = isset($counts[$idx]) ? $counts[$idx] + 1 : 1;
}
}
}
$outOrigin = array();
$found = false;
foreach ($counts as $idx => $count) {
list($target, $origin) = $this->extends[$idx];
// check count
if ($count != count($target)) {
continue;
}
// check if target is subset of single
if (array_diff(array_intersect($single, $target), $target)) {
continue;
}
$rem = array_diff($single, $target);
foreach ($origin as $j => $new) {
// prevent infinite loop when target extends itself
foreach ($new as $new_selector) {
if (!array_diff($single, $new_selector)) {
continue 2;
}
}
$origin[$j][count($origin[$j]) - 1] = $this->combineSelectorSingle(end($new), $rem);
}
$outOrigin = array_merge($outOrigin, $origin);
$found = true;
}
return $found;
}