Converts the given source parameter to an array.

@param array|ArrayAccess $source

@return array
13961
protected function getSourceAsArray($source)
    {
        if (!is_array($source) && !($source instanceof ArrayAccess)) {
            user_error('$source passed in as invalid type', E_USER_ERROR);
        }
        
        if ($source instanceof SS_List || $source instanceof Map) {
            $source = $source->toArray();
        }
        
        return $source;
    }
820419
public function tokens($source, $offset)
    {
        $tokens = array();

        $rawTokens = token_get_all('<?php ' . substr($source, $offset));
        array_shift($rawTokens);

        foreach ($rawTokens as $token) {
            $tokens = array_merge($tokens, $this->normalizeToken($token));
        }

        $tokens = $this->collapseQuotedStrings($tokens);
        $tokens = $this->collapseConsecutiveStrings($tokens);

        return $tokens;
    }
931368
protected function getFiles(array $source)
    {
        $fileSet = [];
        foreach ($source as $set) {
            if (!array_key_exists('files', $set)) {
                throw new \Exception("`src` must have a `files` option");
            }

            if (!array_key_exists('path', $set)) {
                $set['path'] = getcwd();
            }

            if (!array_key_exists('recursive', $set)) {
                $set['recursive'] = false;
            }

            $paths = is_array($set['path']) ? $set['path'] : [$set['path']];
            $files = is_array($set['files']) ? $set['files'] : [$set['files']];
            foreach ($paths as $path) {
                foreach ($files as $file) {
                    $finder = new Finder();
                    $finder->files()->in($path)->name($file);
                    if (!$set['recursive']) {
                        $finder->depth('== 0');
                    }

                    $fileSet = $this->appendFileSet($finder, $fileSet);
                }
            }
        }

        return $fileSet;
    }
655321
protected function toConfigArray($source, $nodeName)
    {
        $items = [];
        $config = $source->getElementsByTagName($nodeName);
        
        foreach($config as $configNode) {
            $item = [];
            foreach($configNode->attributes as $attribute) {
                $item[$attribute->name] = $attribute->value;
            }
            $items []= $item;
        }

        return $items;
    }
654487
protected function parse($source): array
    {
        $path = null;
        list($alias, $path) = explode(':', $source, 2);

        $path = ltrim($path, "\\/");
        $paths = $this->resolvePaths($alias);

        return [$alias, $paths, $path];
    }
706925
public function getSourceChildPropertiesToBeConverted($source)
    {
        if (is_string($source)) {
            return [];
        }
        if (isset($source['__identity'])) {
            unset($source['__identity']);
        }
        return parent::getSourceChildPropertiesToBeConverted($source);
    }
822282
private function sourceOptions(Source $source): array
    {
        $name = strip_tags($source->fullName());

        return [
            'only'   => strip_tags($source->fullName()),
            'linked' => I18N::translate('%s and the individuals that reference it.', $name),
        ];
    }
218133
private static function cloneArray(array $source): array
    {
        $ret = [];
        foreach ($source as $key => $value) {
            if (is_array($value)) {
                $ret[$key] = self::cloneArray($value);
            } else if (is_object($value)) {
                $ret[$key] = clone $value;
            } else {
                $ret[$key] = $value;
            }
        }
        return $ret;
    }
1148561
protected function getListMap($source)
    {
        // Extract Map from ID / Text Fields:
        
        if ($source instanceof SS_List) {
            $source = $source->map($this->getIDField(), $this->getTextField());
        }
        
        // Convert Map to Array:
        
        if ($source instanceof Map) {
            $source = $source->toArray();
        }
        
        // Determine Invalid Types:
        
        if (!is_array($source) && !($source instanceof ArrayAccess)) {
            user_error('$source passed in as invalid type', E_USER_ERROR);
        }
        
        // Answer Data Source:
        
        return $source;
    }
294412
public function parse($source, Input $input)
    {
        if (! $this->sourceAllowed()) {
            return $source;
        }

        if ($this->hasMatches($source)) {
            $matches   = $this->getMatches($source);
            $variables = synapse()->memory->variables();

            foreach ($matches as $match) {
                $source = str_replace($match[0], $variables[$match[1]], $source);
            }
        }

        return $source;
    }
972026
private function loadWithSource($Source)
    {
        if (empty ($Source)) {
            return array();
        }
        if ($this->settingUseSyckIsPossible && function_exists ('syck_load')) {
            $array = syck_load (implode ('', $Source));

            return is_array($array) ? $array : array();
        }

        $this->path = array();
        $this->result = array();
        $cnt = count($Source);

        for ($i = 0; $i < $cnt; $i++) {
            $line = $Source[$i];

            $this->indent = strlen($line) - strlen(ltrim($line));
            $tempPath = $this->getParentPathByIndent($this->indent);
            $line = self::stripIndent($line, $this->indent);

            if (self::isComment($line)) {
                continue;
            }
            if (self::isEmpty($line)) {
                continue;
            }

            $this->path = $tempPath;
            $literalBlockStyle = self::startsLiteralBlock($line);

            if ($literalBlockStyle) {
                $line = rtrim ($line, $literalBlockStyle . " \n");
                $literalBlock = '';
                $line .= $this->LiteralPlaceHolder;
                $literal_block_indent = strlen($Source[$i+1]) - strlen(ltrim($Source[$i+1]));

                while (++$i < $cnt && $this->literalBlockContinues($Source[$i], $this->indent)) {
                    $literalBlock = $this->addLiteralLine(
                        $literalBlock, $Source[$i], $literalBlockStyle, $literal_block_indent
                    );
                }

                $i--;
            }

            while (++$i < $cnt && self::greedilyNeedNextLine($line)) {
                $line = rtrim($line, " \n\t\r") . ' ' . ltrim($Source[$i], " \t");
            }

            $i--;

            if (strpos($line, '#')) {
                if (strpos($line, '"') === false && strpos($line, "'") === false) {
                    $line = preg_replace('/\s+#(.+)$/','',$line);
                }
            }

            $lineArray = $this->parseLine($line);

            if ($literalBlockStyle) {
                $lineArray = $this->revertLiteralPlaceHolder ($lineArray, $literalBlock);
            }

            $this->addArray($lineArray, $this->indent);

            foreach ($this->delayedPath as $indent => $delayedPath) {
                $this->path[$indent] = $delayedPath;
            }

            $this->delayedPath = array();

        }

        return $this->result;
    }
1221944
public static function toArrayFrom($source, $firstLevel = false, $excludeClasses = [], $propertyPattern = null)
    {
        // Prepare the source object type
        $object = new SerializerObject($source);
        $object->setStopFirstLevel($firstLevel);
        $object->setDoNotParse($excludeClasses);
        if (!is_null($propertyPattern)) {
            if (!is_array($propertyPattern)) {
                throw new InvalidArgumentException(
                    'Property pattern must be an array with 2 regex elements (Search and Replace)'
                );
            }
            $object->setMethodPattern($propertyPattern[0], $propertyPattern[1]);
        }
        return $object->build();
    }
786270
private function getDeletedFields(Source $source)
    {
        $fields = array();
        $fields += array(
            'undelete' => array(
                'type' => 'button',
                'value' => $this->t('undelete'),
                'ajax' => array(
                    'service' => 'entry_deletestatus_set',
                    'parent_type' => $this->source->getType(),
                    'parent_source' => $this->source->getId(),
                    'type' => $source->getType(),
                    'source' => $source->getId(),
                    'value' => API::Entry_Delete,
                ),
            ),
            'send' => array(
                'type' => 'button',
                'value' => $this->t('send_again'),
                'ajax' => array(
                    'service' => 'invoice_add',
                    'parent_type' => $this->source->getType(),
                    'parent_source' => $this->source->getId(),
                    'type' => $source->getType(),
                    'source' => $source->getId(),
                    'value' => 1,
                ),
            ),
        );
        return $fields;
    }
89493
protected function lowercase( array $source )
    {
    	$result = array();

    	foreach ($source as $key => $value )
    		$result[strtolower($key)] = $value;

    	return $result;
    }
84412
public function findAllBySource($source, array $arrOptions = [])
    {
        /** @var CfgTagModel $adapter */
        if (null === ($adapter = $this->framework->getAdapter(self::class))) {
            return null;
        }

        return $adapter->findBy('source', $source, $arrOptions);
    }
368062
private function reformatArray($source)
    {
        $result = array();

        foreach ($source as $data) {
            $result[$data[0]] = (isset($data[1])) ? $data[1] : '';
        }

        return $result;
    }
1249233
protected function mapParty(array $source) {
		if (!isset($source['__type'])) {
			throw new Exception('Cannot map party without explicit type (server should return "__type" in party account data):' . json_encode($source), 1354111717);
		}
		$partyType = $source['__type'];
		unset($source['__type']);
		if (isset($this->typeMapping[$partyType])) {
			$partyType = $this->typeMapping[$partyType];
		}
		$configuration = new TrustedPropertyMappingConfiguration();

		// TODO Deal with mapping errors from property mapper

		return $this->propertyMapper->convert($source, $partyType, $configuration);
	}