private function findUsedTypes($service, Type $type)
    {
        if ($type instanceof Enum) {
            return array($type);
        }
        if (!$type instanceof ComplexType) {
            return array();
        }

        $foundTypes = array($type);

        // Process Base type
        $baseType = $type->getBaseType();
        if ($baseType) {
            $foundTypes = array_merge($foundTypes, $this->findUsedTypes($service, $baseType));
        }

        $members = $type->getMembers();
        foreach ($members as $member) {
            /** @var Variable $member */
            // Remove array mark from type name
            $memberTypeName = str_replace('[]', '', $member->getType());
            $memberType = $service->getType($memberTypeName);
            if (!$memberType) {
                continue;
            }

            $foundTypes = array_merge($foundTypes, $this->findUsedTypes($service, $memberType));
        }

        return $foundTypes;
    }
private function findUsedTypes($service, Type $type)
    {
        if ($type instanceof Enum) {
            return array($type);
        }
        if (!$type instanceof ComplexType) {
            return array();
        }

        $foundTypes = array($type);

        // Process Base type
        $baseType = $type->getBaseType();
        if ($baseType) {
            $foundTypes = array_merge($foundTypes, $this->findUsedTypes($service, $baseType));
        }

        $members = $type->getMembers();
        foreach ($members as $member) {
            /** @var Variable $member */
            // Remove array mark from type name
            $memberTypeName = str_replace('[]', '', $member->getType());
            $memberType = $service->getType($memberTypeName);
            if (!$memberType) {
                continue;
            }

            $foundTypes = array_merge($foundTypes, $this->findUsedTypes($service, $memberType));
        }

        return $foundTypes;
    }
private function findUsedTypes ( $ service , Type $ type ) { if ( $ type instanceof Enum ) { return array ( $ type ) ; } if ( ! $ type instanceof ComplexType ) { return array ( ) ; } $ foundTypes = array ( $ type ) ; // Process Base type $ baseType = $ type -> getBaseType ( ) ; if ( $ baseType ) { $ foundTypes = array_merge ( $ foundTypes , $ this -> findUsedTypes ( $ service , $ baseType ) ) ; } $ members = $ type -> getMembers ( ) ; foreach ( $ members as $ member ) { /** @var Variable $member */ // Remove array mark from type name $ memberTypeName = str_replace ( '[]' , '' , $ member -> getType ( ) ) ; $ memberType = $ service -> getType ( $ memberTypeName ) ; if ( ! $ memberType ) { continue ; } $ foundTypes = array_merge ( $ foundTypes , $ this -> findUsedTypes ( $ service , $ memberType ) ) ; } return $ foundTypes ; }
Function to find all needed types.

@param Service $service Source service with all types and operations
@param Type $type Type to extract types from.

@return Type[]
All identified types referred to including the current type.
Function to find all needed types .