Prints an object inheritance

@param ReflectionClass $object class/interface instance
@param string          $parentName Fully qualified name of the parent

@return void
766634
protected function writeObjectInheritance($object, $parentName)
    {
        try {
            $parent      = $this->reflector->getClass($parentName);
            $longName    = $parent->getName();

            $this->writeObjectElement($parent);

        } catch (\Exception $e) {
            // object is undeclared in data source
            $parts       = explode('\\', $parentName);
            $shortName   = array_pop($parts);
            $longName    = $parentName;
            $ns          = implode($this->namespaceSeparator, $parts);

            if (!isset($this->objects[$ns])) {
                $this->objects[$ns] = array();
            }

            if (!array_key_exists($shortName, $this->objects[$ns])) {
                $type = $object->isInterface() ? 'interface' : 'class';
                $this->pushObject($ns, $shortName, $longName, $type);
            }
        }

        $this->pushEdge(array($object->getName(), $longName));
    }
683740
protected function getClassDistance(
        string $childClass,
        string $parentClass
    ): int {
        if ($childClass === $parentClass) {
            return 0;
        }

        $result = 0;
        $childParents = class_parents($childClass, true);
        foreach($childParents as $childParent) {
            $result++;
            if ($childParent === $parentClass) {
                return $result;
            }
        }

        // We'll treat implementing an interface as having a greater class
        // distance. This because we want a concrete implementation to be more
        // specific than an interface. For example, suppose we have:
        // - FooInterface
        // - FooClass, implementing the above interface
        // If a mapping has been registered for both of these, we want the
        // mapper to pick the mapping registered for FooClass, since this is
        // more specific.
        $interfaces = class_implements($childClass);
        if (\in_array($parentClass, $interfaces, true)) {
            return ++$result;
        }

        // @todo: use a domain specific exception.
        throw new \Exception(
            'This error should have never be thrown.
            This could only happen if given childClass is not a child of the given parentClass'
        );
    }
177834
protected static function executeFieldsSerially(ExecutionContext $context, ObjectType $parent, $source, $fields)
    {
        $results = [];
        foreach ($fields as $response => $asts) {
            $result = self::resolveField($context, $parent, $source, $asts);

            if ($result !== self::$UNDEFINED) {
                // Undefined means that field is not defined in schema.
                $results[$response] = $result;
            }
        }

        return $results;
    }
594332
private function unserializeObject($object, &$data, string $className = null) : array
    {
        $reflectionClass = new \ReflectionClass($className ? $className : $object);
        unset($data['@type']);

        // parent class
        $parent = $reflectionClass->getParentClass();
        if ($parent) {
            $this->unserializeObject($object, $data, $parent->getName());
        }

        foreach ($reflectionClass->getProperties() as $property) {
            $name = $property->getName();

            if (array_key_exists($name, $data)) {
                $currentValue = $data[$name];

                if (isset($data[$name]['@ref'])) {
                    $currentValue = $this->references[$data[$name]['@ref']];
                } elseif (isset($data[$name]['@type'])) {
                    $reflection = new \ReflectionClass($data[$name]['@type']);

                    $parent = $reflection;
                    $internal = false;

                    while ($parent !== false) {
                        $internal = $parent->isInternal() ? true : $internal;
                        $parent = $parent->getParentClass();
                    }

                    if ($internal) {
                        $currentData = $data[$name];
                        $currentType = $data[$name]['@type'];
                        unset($currentData['@type']);

                        $serialize = preg_replace(
                            '`^a:`',
                            'O:' . strlen($currentType) . ':"' . $currentType . '":',
                            serialize($currentData)
                        );
                        $currentValue = unserialize($serialize);
                    } else {
                        $currentValue = $reflection->newInstanceWithoutConstructor();
                        $this->unserializeObject($currentValue, $data[$name]);
                    }
                } elseif (is_array($currentValue)) {
                    $currentValue = [];
                    foreach ($data[$name] as $key => $value) {
                        if (isset($value['@type'])) {
                            $reflection = new \ReflectionClass($value['@type']);
                            $currentValue[$key] = $reflection->newInstanceWithoutConstructor();
                            $this->unserializeObject($currentValue[$key], $value);
                        } else {
                            $currentValue[$key] = $value;
                        }
                    }
                }

                $property->setAccessible(true);
                $property->setValue($object, $currentValue);

                unset($data[$name]);
            }
        }

        return $data;
    }
1161789
private function convertClassAnnotationsToMappedSuperClassMetadata(
        array $classAnnotations,
        ReflectionClass $reflectionClass,
        Mapping\ClassMetadata $parent
    ) {
        /** @var Annotation\MappedSuperclass $mappedSuperclassAnnot */
        $mappedSuperclassAnnot = $classAnnotations[Annotation\MappedSuperclass::class];
        $classMetadata         = new Mapping\MappedSuperClassMetadata($reflectionClass->getName(), $parent);

        if ($mappedSuperclassAnnot->repositoryClass !== null) {
            $classMetadata->setCustomRepositoryClassName($mappedSuperclassAnnot->repositoryClass);
        }

        return $classMetadata;
    }
366816
public function populateParent(DataObject $object, $data)
    {
        // Define Parent:
        
        if (isset($data['ParentID'])) {
            $object->ParentID = $data['ParentID'];
        }
        
        // Answer Object:
        
        return $object;
    }
1136448
protected function validateRuntimeMetadata($class, $parent)
    {
        if (!$class->reflClass) {
            // only validate if there is a reflection class instance
            return;
        }

        $class->validateIdentifier();
        $class->validateReferenceable();
        $class->validateReferences();
        $class->validateChildClasses();
        $class->validateLifecycleCallbacks($this->getReflectionService());
        $class->validateTranslatables();

        // verify inheritance
        // TODO
    }
1112402
public function autowireObject($className, $objectName = '', $pattern = 'Singleton')
    {

        if($objectName == '') $objectName = $className;
        if(!$this->objectAlreadyLoaded($objectName) && !$this->objectExistsInContext($objectName)) {
            $instantiator = new Instantiator(array('id'=>$objectName, 'class'=>$className),$this);
            $this->addObjectContext($instantiator->getNewDefinition());

            $pClass = $pattern.'Pattern';

            $cp = new ObjectService($objectName);
            $cp->setPattern(new $pClass($instantiator));

            $this->addObject($cp);
        }
        return $this->object($objectName);
    }
28121
public function apply(object $object, ReflectionProperty $reflectionProperty, callable $objectCopier): void
    {
        $reflectionProperty->setAccessible(true);

        $value = ($this->callback)($reflectionProperty->getValue($object));

        $reflectionProperty->setValue($object, $value);
    }
780167
public static function printOutput($title, $objectName, $objectId = null, $request = null, $response = null, $errorMessage = null)
    {
        if (PHP_SAPI == 'cli') {
            self::$printResultCounter++;
            printf("\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
            printf("(%d) %s", self::$printResultCounter, strtoupper($title));
            printf("\n-------------------------------------------------------------\n\n");
            if ($objectId) {
                printf("Object with ID: %s \n", $objectId);
            }
            printf("-------------------------------------------------------------\n");
            printf("\tREQUEST:\n");
            self::printConsoleObject($request);
            printf("\n\n\tRESPONSE:\n");
            self::printConsoleObject($response, $errorMessage);
            printf("\n-------------------------------------------------------------\n\n");
        } else {
            if (self::$printResultCounter == 0) {
                include "header.html";
                echo '
                  <div class="row header"><div class="col-md-5 pull-left"><br /><a href="../../index.php"><h1 class="home">&#10094;&#10094; Back to Samples</h1></a><br /></div> <br />
                  <div class="col-md-4 pull-right"><img src="https://static.payu.co.za/sites/all/themes/regionwithwalletNew/public/images/global/payu@2x.png" class="logo" width="300"/></div> </div>';
                echo '<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">';
            }
            self::$printResultCounter++;
            echo '
            <div class="panel panel-default">
                <div class="panel-heading ' . ($errorMessage ? 'error' : '') . '" role="tab" id="heading-' . self::$printResultCounter . '">
                    <h4 class="panel-title">
                        <a data-toggle="collapse" data-parent="#accordion" href="#step-' . self::$printResultCounter . '" aria-expanded="false" aria-controls="step-' . self::$printResultCounter . '">
                    ' . self::$printResultCounter . '. ' . $title . ($errorMessage ? ' (Failed)' : '') . '</a>
                    </h4>
                </div>
            <div id="step-' . self::$printResultCounter . '" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-' . self::$printResultCounter . '">
                <div class="panel-body">
            ';

            if ($objectId) {
                echo "<div>" . ($objectName ? $objectName : "Object") . " with ID: $objectId </div>";
            }

            echo '<div class="row hidden-xs hidden-sm hidden-md"><div class="col-xs-12 col-sm-6 col-md-6"><h4>Request Object</h4>';
            self::printObject($request);
            echo '</div><div class="col-xs-12 col-sm-6 col-md-6"><h4 class="' . ($errorMessage ? 'error' : '') . '">Response Object</h4>';
            self::printObject($response, $errorMessage);
            echo '</div></div>';

            echo '<div class="hidden-lg"><ul class="nav nav-tabs" role="tablist">
                        <li role="presentation" ><a href="#step-' . self::$printResultCounter . '-request" role="tab" data-toggle="tab">Request</a></li>
                        <li role="presentation" class="active"><a href="#step-' . self::$printResultCounter . '-response" role="tab" data-toggle="tab">Response</a></li>
                    </ul>
                    <div class="tab-content">
                        <div role="tabpanel" class="tab-pane" id="step-' . self::$printResultCounter . '-request"><h4>Request Object</h4>';
            self::printObject($request);
            echo '</div><div role="tabpanel" class="tab-pane active" id="step-' . self::$printResultCounter . '-response"><h4>Response Object</h4>';
            self::printObject($response, $errorMessage);
            echo '</div></div></div></div>
            </div>
        </div>';
        }
        flush();
    }
288495
public static function register( $slug, $object, $parent = null ) {

		$caller = get_called_class();
		// get the current instance
		if ( empty( $object['type'] ) || ! uix()->is_callable( 'control\\' . $object['type'] ) ) {
			$object['type'] = 'text';
		}

		$caller = $caller . '\\' . $object['type'];

		return new $caller( $slug, $object, $parent );

	}
942856
static void print(Object object,java.io.PrintWriter printWriter) {
    if (object instanceof Printable) {
      ((Printable)object).print(printWriter);
    } else {
      printWriter.print(object);
    } // if (object instanceof Printable).

  }
725613
private function handleProperties($data, $object, \ReflectionClass $reflection, $fields)
    {
        foreach ($fields as $field) {
            $property = $reflection->getProperty($field);
            $name     = $property->getName();

            if (property_exists($data, $name) === false ) {
                continue;
            }
            $property->setAccessible(true);
            $type  = $this->propertyHandler->propertyTypeOverride(null, $property);
            $value = $this->propertyHandler->handleTypeConversion($type, $data->$name);

            $property->setValue($object, $value);
        }
    }
339997
protected static function executeFields(ExecutionContext $context, ObjectType $parent, $source, $fields)
    {
        return self::executeFieldsSerially($context, $parent, $source, $fields);
    }
639458
private function getParentClasses(string $class, $parentClass = []) : array
    {
        if (!$parentClass) {
            $parentClass[] = $class;
        }

        $parent = get_parent_class($class);
        if ($parent) {
            $parentClass[] = $parent;
            $parentClass = self::getParentClasses($parent, $parentClass);
        }

        return $parentClass;
    }
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);
    }
1114257
protected function compileStaticMethods($className, ProxyClass $proxyClass)
    {
        $methodNames = $this->reflectionService->getMethodsAnnotatedWith($className, Flow\CompileStatic::class);
        foreach ($methodNames as $methodName) {
            if (!$this->reflectionService->isMethodStatic($className, $methodName)) {
                throw new ObjectException(sprintf('The method %s:%s() is annotated CompileStatic so it must be static', $className, $methodName), 1476348303);
            }
            if ($this->reflectionService->isMethodPrivate($className, $methodName)) {
                throw new ObjectException(sprintf('The method %s:%s() is annotated CompileStatic so it must not be private', $className, $methodName), 1476348306);
            }
            $reflectedMethod = new MethodReflection($className, $methodName);
            $reflectedMethod->setAccessible(true);
            $value = $reflectedMethod->invoke(null, $this->objectManager);
            $compiledResult = var_export($value, true);

            $compiledMethod = $proxyClass->getMethod($methodName);
            $compiledMethod->setMethodBody('return ' . $compiledResult . ';');
        }
    }