SimpleReflection::onlyParents PHP Method

onlyParents() protected method

Whittles a list of interfaces down to only the necessary top level parents.
protected onlyParents ( array $interfaces ) : array
$interfaces array Reflection API interfaces to reduce.
return array List of parent interface names.
    protected function onlyParents($interfaces)
    {
        $parents = array();
        $blacklist = array();
        foreach ($interfaces as $interface) {
            foreach ($interfaces as $possible_parent) {
                if ($interface->getName() == $possible_parent->getName()) {
                    continue;
                }
                if ($interface->isSubClassOf($possible_parent)) {
                    $blacklist[$possible_parent->getName()] = true;
                }
            }
            if (!isset($blacklist[$interface->getName()])) {
                $parents[] = $interface->getName();
            }
        }
        return $parents;
    }