Check whether or not $class extends $parent, and throw an exception if
it does not.

@param string|object $class
Class name or object.
@param string $parent
Expected parent class of $class.
@throws InvalidClassException If $class does not extend $parent.
179102
public static function isSubclassOf($class, $parent)
    {
        if (! is_subclass_of($class, $parent)) {
            if (is_object($class)) {
                $class = get_class($class);
            }
            self::isString($class);
            if ($class === $parent) {
                return;
            }
            if (! class_exists($class)) {
                throw new InvalidArgumentException('Class not found: ' . $class);
            }
            throw new InvalidArgumentException('Class ' . $class . ' should extend ' . $parent);
        }
    }
69810
public function hasParent($parentClassName)
    {
        $found = false;

        $this->alongParents(function ($parent) use ($parentClassName, &$found) {
            if ($parent instanceof $parentClassName) {
                $found = true;

                return false;
            }

            return true;
        });

        return $found;
    }
1250233
public function assertValidChildClass(self $class)
    {
        if ($this->isLeaf()) {
            throw new OutOfBoundsException(sprintf(
                'Document "%s" has been mapped as a leaf. It cannot have children',
                $this->name
            ));
        }

        $childClasses = $this->getChildClasses();

        if (0 === count($childClasses)) {
            return;
        }

        foreach ($childClasses as $childClass) {
            if ($class->name === $childClass || $class->reflClass->isSubclassOf($childClass)) {
                return;
            }
        }

        throw new OutOfBoundsException(sprintf(
            'Document "%s" does not allow children of type "%s". Allowed child classes "%s"',
            $this->name,
            $class->name,
            implode('", "', $childClasses)
        ));
    }
882153
private static function ensurePropertyExists($class, $name)
    {
        if (!array_key_exists($name, self::$properties[$class])) {
            throw new Exceptions\UnknownPropertyException(get_called_class(), $name);
        }
    }
281290
public static function doesClassExtendClass($childClassName, $parentClassName) {

        $reflectionClass = new \ReflectionClass ($childClassName);

        do {
            if ($reflectionClass->getName() == $parentClassName)
                return true;
            $reflectionClass = $reflectionClass->getParentClass();
        } while ($reflectionClass);

        // Assume false if we get this far
        return false;
    }
1240655
protected static function checkInternalClass($instance, $class, array $args = [])
    {
        if (null !== $instance) {
            return;
        }

        $messages = [];
        foreach ($args as $name => $value) {
            $messages[] = sprintf('%s => %s', $name, $value);
        }

        throw new \RuntimeException(sprintf(
            'Unable to create internal class: %s, with params: %s',
            $class,
            implode(', ', $messages)
        ));
    }
156807
private function handleParentClassNotFound(ParentClassNotFoundException $exception, &$classMap)
    {
        // Now collect all parent classes and display them then.
        $classes = array();
        while ($exception) {
            $parentClass = $exception->getParentClass();
            $classes[]   = $parentClass;
            $exception   = $exception->getPrevious();

            unset($classMap[$parentClass]);
        }
        $classes     = array_reverse($classes);
        $parentClass = array_shift($classes);
        // Check if the parent class is known in the class map.
        if (isset($this->classMap[$parentClass])) {
            // It is known, nothing we can do anymore. Next one.
            $this->logger->error(
                'Could not load class.' . "\n" .
                'class:  {class}' . "\n" .
                'file:   {file}',
                array('class' => $parentClass, 'parent' => $this->classMap[$parentClass])
            );
        }
        $logLine = '{class0}<Missing parent class!>';
        $args    = array('class0' => $parentClass);
        // Ok, top most parent is somewhere lost, log this incident.
        foreach ($classes as $class) {
            $parName        = sprintf('class%1$d', count($args));
            $logLine       .= sprintf(' <= {%1$s}', $parName);
            $args[$parName] = $class;
        }

        $this->logger->warning($logLine, $args);
    }
1002308
public function setParent($parent)
    {
        if (!$parent instanceof ClassDescriptor && !$parent instanceof InterfaceDescriptor && $parent !== null) {
            throw new \InvalidArgumentException('Constants can only have an interface or class as parent');
        }

        $fqsen = $parent !== null
            ? $parent->getFullyQualifiedStructuralElementName() . '::' . $this->getName()
            : $this->getName();

        $this->setFullyQualifiedStructuralElementName($fqsen);

        $this->parent = $parent;
    }
1215006
protected function validateClassImplementation($class)
    {
        $str_class = is_string($class);

        $valid_implementation = (is_a($class, $this->basic_interface, $str_class)
                                    || is_a($class, $this->dynamic_interface, $str_class));

        if (!$valid_implementation) {
            throw new InvalidArgumentException('Class must implement either '
                                    . $this->basic_interface . ' or ' . $this->dynamic_interface);
        }
    }
431906
final public function parent(string $parent)
    {
        if (!$this->allowParent) {
            throw new InvalidArgumentException(sprintf('A parent cannot be defined when either "_instanceof" or "_defaults" are also defined for service prototype "%s".', $this->id));
        }

        if ($this->definition instanceof ChildDefinition) {
            $this->definition->setParent($parent);
        } elseif ($this->definition->isAutoconfigured()) {
            throw new InvalidArgumentException(sprintf('The service "%s" cannot have a "parent" and also have "autoconfigure". Try disabling autoconfiguration for the service.', $this->id));
        } elseif ($this->definition->getBindings()) {
            throw new InvalidArgumentException(sprintf('The service "%s" cannot have a "parent" and also "bind" arguments.', $this->id));
        } else {
            // cast Definition to ChildDefinition
            $definition = serialize($this->definition);
            $definition = substr_replace($definition, '53', 2, 2);
            $definition = substr_replace($definition, 'Child', 44, 0);
            $definition = unserialize($definition);

            $this->definition = $definition->setParent($parent);
        }

        return $this;
    }
661447
private function throwExceptionIfNotInstantiable($class, $reflectionClass)
    {
        /*
         * Check if reflection class is not instantiable then throw ContainerException
         */
        if (!$reflectionClass->isInstantiable()) {
            $type = ($this->reflection->getReflectionClass()->isInterface() ? 'interface' : 'class');
            throw new ContainerException("Cannot instantiate $type $class");
        }
    }
117354
public function addClass($class, $extends = null, $implements = [])
    {
        $classId = $this->registerClass($class);
        if ($extends) {
            $parentClassId = $this->registerClass($extends);
            $this->extends[$classId] = [$parentClassId];
        }
        if (!empty($implements)) {
            $interfaceIds = [];
            foreach ($implements as $interface) {
                $interfaceIds[] = $this->registerInterface($interface);
            }
            $this->implements[$classId] = $interfaceIds;
        }
    }
81585
public function autoload($class)
    {
        if (!static::$initialized) {
            $this->initialize();
            if ($this->classExists($class)) {
                return TRUE;
            }
        }
        if (\Staq\Util::isStack($class)) {
            $this->loadStackClass($class);
        } else if (\Staq\Util::isParentStack($class)) {
            $this->loadStackParentClass($class);
        }
    }
567230
public function type(string $classType)
    {
        $baseType = $this->class ? $this->class->getClassName() : TypedObject::class;
        if (!is_a($classType, $baseType, true)) {
            throw InvalidArgumentException::format(
                'Invalid call to %s: class type must be an subclass of %s, %s given',
                __METHOD__, $baseType, $classType
            );
        }

        /** @var TypedObject $classType */
        $this->class = $classType::definition();
    }
960105
public function addClass(PhpClass $class)
    {
        if ($this->classExists($class->getIdentifier())) {
            throw new Exception('A class of the name (' . $class->getIdentifier() . ') does already exist.');
        }

        $this->classes[$class->getIdentifier()] = $class;
    }
791307
private function isValidClass(PhpClass $class)
    {
        $classNames = $this->config->get('classNames');
        return (empty($classNames) || in_array(
            $class->getIdentifier(),
            $classNames
        ));
    }
106588
public function setParent($object) {
		
		if (! is_object($object)) {
			throw new \InvalidArgumentException("Expecting object, given: ".gettype($object));
		}
		
		$this->parent = $object;
		return $this;
	}