Complex types and groups may contain nested elements
The purpose of this function is to retrieve such nested elements
@param array|string $type The name of a type or an array representing a type
968314
public function gatherElementsFromType( $type )
	{
		if ( is_string( $type ) )
		{
			$type = $this->getType( $type );
		}

		if ( ! is_array( $type ) ) return false;

		$elements = array();

		foreach ( array( 'elements', 'sequence', 'choice', 'group' ) as $typeComponent )
		{
			if ( ! isset( $type[ $typeComponent ] ) )
			{
				continue;
			}

			foreach ( $type[ $typeComponent ] as $id => $element )
			{
				if ( $id == 'restrictionType')
				{
					continue;
				}

				if ( $id == 'elements' )
				{
					$elements += $element;
					continue;
				}

				$result = $this->gatherElementsFromType( $element );
				if ( ! $result )
				{
					$elements[ "{$element['prefix']}:{$element['name']}" ] = $element;
				}

				$elements += $result;
			}

		}

		return $elements;
	}
7555
public static function items($type)
	{
		if(!isset(self::$_items[$type]))
			self::loadItems($type);
		return self::$_items[$type];
	}
628621
private function hasRelation($type)
    {
        return in_array(
            $type,
            [
                ClassMetadataInfo::MANY_TO_MANY,
                ClassMetadataInfo::MANY_TO_ONE,
                ClassMetadataInfo::ONE_TO_ONE,
            ],
            true
        );
    }
871766
public function process_children( $type ) {
		$this->struct[ $type ] = array_filter( $this->struct[ $type ], 'is_array' );
		foreach ( $this->struct[ $type ] as $sub_slug => $sub_structure ) {
			if ( ! empty( $sub_structure['id'] ) ) {
				$sub_slug = $sub_structure['id'];
			}

			$this->{$type}( $sub_slug, $sub_structure );
		}

	}
473363
public function setType($type)
    {
        if ($type instanceof Type) {
            $this->setIndex($type->getIndex());
            $type = $type->getName();
        }

        return $this->setParam('_type', $type);
    }
1234483
public function visitAndType(AndType $type)
    {
        $subTypes = array();

        foreach ($type->types() as $subType) {
            $subTypes[] = $subType->accept($this);
        }

        return implode('+', $subTypes);
    }
1140810
public function setType($type)
    {
        if (is_string($type) && in_array($type, self::$types)) {
            $this->type = $type;
        } else {
            throw new InvalidArgumentException;
        }
    }
1100864
public function setType($types)
    {
        if (!is_array($types)) {
            $types = [$types];
        }

        $typesToSet = [];
        foreach ($types as $type) {
            if ($type === 'int') {
                $type = 'integer';
            }
            if ($type === 'hash') {
                $type = 'object';
            }

            // handle non-primitive types
            if (!in_array($type, $this->primitiveTypes)) {
                $setType = 'string';
                if (isset($this->specialTypeMapping[$type])) {
                    $setType = $this->specialTypeMapping[$type];
                }
                $typesToSet[] = $setType;

                if (isset($this->formatOverrides[$type])) {
                    $type = $this->formatOverrides[$type];
                }

                $this->setFormat($type);
            } else {
                $typesToSet[] = $type;
            }
        }

        $this->type = new SchemaType($typesToSet);
    }
572565
private function resolveTypes($type)
    {
        $columnTypes = [];

        do {
            $columnTypes[] = $columnType = $this->columnRegistry[$type];
        } while (($type = $columnType->getParent()) !== null);

        return $columnTypes;
    }
282011
public function ElementsByItemType( $types )
	{
		if ( is_string( $types ) )
			$types = array_map( 'trim', explode( ",", $types ) );

		if ( ! is_array( $types ) )
			throw new Exception( 'InstanceElementsFilter::ElementsByName $types must be a string or array' );

		$types = array_flip( array_map( 'strtolower', $types ) );

		// In PHP 7.0 $this is passed to closure functions automatically but not in earlier versions
		$elements = &$this->elements;

		$filtered = array_reduce( array_keys( $this->elements ), function( $carry, $elementName ) use( &$elements, $types  ) {

			$namespaceElements = array_filter( $elements[ $elementName ], function( $entry ) use( $types ) {
				$type = $entry['taxonomy_element']['type'];
				return isset( $types[ strtolower( $type ) ] );
			} );

			if ( ! $namespaceElements ) return $carry;

			$carry[ $elementName ] = $namespaceElements;

			return $carry;

		}, array() );

		return new InstanceElementsFilter( $this->instance, $filtered );
	}
628584
public function fetch($type = 'num')
    {
        $row = parent::fetch($type);
        if ($type == 'assoc' && is_array($row) && !empty($this->_driver->autoShortenedIdentifiers)) {
            //Need to preserve order of row results
            $translatedRow = [];
            foreach ($row as $key => $val) {
                if (array_key_exists($key, $this->_driver->autoShortenedIdentifiers)) {
                    $translatedRow[$this->_driver->autoShortenedIdentifiers[$key]] = $val;
                } else {
                    $translatedRow[$key] = $val;
                }
            }
            $row = $translatedRow;
        }
        return $row;
    }
373742
public static function isKnownType(string $type): bool
    {
        return self::isInternalPhpType($type) || self::isClassType($type);
    }
396145
public function getNodesOfType(string $type): array
    {
        return isset($this->nodesByType[$type]) ? $this->nodesByType[$type] : [];
    }
1137848
private function isRelation($type)
    {
        return in_array(
            $type,
            [
                ClassMetadataInfo::MANY_TO_MANY,
                ClassMetadataInfo::ONE_TO_MANY,
                ClassMetadataInfo::ONE_TO_ONE,
            ],
            true
        );
    }
915713
protected static function listTypedURL(&$array, $type=null) {
		if( $type ) {
			if( !isset($array[$type]) ) {
				return array();
			}
			$r = $array[$type];
			unset($array[$type]);
			return $r;
		}
		$r = array();
		foreach( $array as $type => $typeURLs ) {
			$r = array_merge($r, $typeURLs);
		}
		$array = array();
		return $r;
	}
1147266
public function setType($type)
    {
        if (in_array($type, array_keys($this->devices))) {
            $this->type = $type;
        }
    }
175774
public function addElementToContentSet($element, $type)
    {
        if (!isset($this->content_sets[$type])) {
            $this->content_sets[$type] = '';
        } else {
            $this->content_sets[$type] .= ' | ';
        }
        $this->content_sets[$type] .= $element;
    }