Assert that each leaf is an UploadedFileInterface

@param array  $uploadedFiles
@param string $groupKey
@throws \InvalidArgumentException if an invalid structure is provided.
189272
protected function assertUploadedFilesStructure(array $uploadedFiles, $groupKey = null)
    {
        foreach ($uploadedFiles as $key => $item) {
            $parameterKey = isset($groupKey) ? "{$groupKey}[{$key}]" : $key;
            
            if (is_array($item)) {
                $this->assertUploadedFilesStructure($item, $parameterKey);
            } elseif (!$item instanceof UploadedFileInterface) {
                throw new \InvalidArgumentException("'$parameterKey' is not an UploadedFileInterface object, but a "
                    . (is_object($item) ? get_class($item) . ' ' : '') . gettype($item));
            }
        }
    }
890493
private function validateFilesPaths(array $definitionFileDirectories): bool
    {
        if (count($definitionFileDirectories) < 1) {
            throw new InvalidConfigurationException(
                'The "schema_paths" config value is empty, it should contain a value with a valid path for the following keys: mutations, queries, types'
            );
        }

        if (array_diff(array_keys($definitionFileDirectories), $this->requiredSchemaFileKeys)) {
            throw new InvalidConfigurationException(
                'The "schema_paths" config value is incomplete, it should contain a value with a valid path for the following keys: mutations, queries, types'
            );
        }
        foreach ($definitionFileDirectories as $key => $path) {
            if (empty($path)) {
                throw new InvalidConfigurationException(
                    sprintf(
                        'The "schema_paths" config value for key "%s" is empty, it should contain a value with a valid path',
                        $key
                    )
                );
            }

            if (! file_exists($path)) {
                throw new InvalidConfigurationException(
                    sprintf('The "schema_paths" config value for key "%s" contains a path that does not exist', $key)
                );
            }
        }

        return true;
    }
1047013
public function groupby($groupBy = null): Select
    {
        if (!\is_string($groupBy) && !\is_array($groupBy)) {
            throw new InvalidArgumentException('$groupBy has to be an array or a string');
        }
        $this->groupBy = $this->namesClass->parse($groupBy);

        return $this;
    }
826449
public function setShardKey(array $keys, array $options = []) : void
    {
        if ($this->inheritanceType === self::INHERITANCE_TYPE_SINGLE_COLLECTION && $this->shardKey !== []) {
            throw MappingException::shardKeyInSingleCollInheritanceSubclass($this->getName());
        }

        if ($this->isEmbeddedDocument) {
            throw MappingException::embeddedDocumentCantHaveShardKey($this->getName());
        }

        foreach (array_keys($keys) as $field) {
            if (! isset($this->fieldMappings[$field])) {
                continue;
            }

            if (in_array($this->fieldMappings[$field]['type'], ['many', 'collection'])) {
                throw MappingException::noMultiKeyShardKeys($this->getName(), $field);
            }

            if ($this->fieldMappings[$field]['strategy'] !== static::STORAGE_STRATEGY_SET) {
                throw MappingException::onlySetStrategyAllowedInShardKey($this->getName(), $field);
            }
        }

        $this->shardKey = [
            'keys' => array_map(static function ($value) {
                if ($value === 1 || $value === -1) {
                    return $value;
                }
                if (is_string($value)) {
                    $lower = strtolower($value);
                    if ($lower === 'asc') {
                        return 1;
                    }

                    if ($lower === 'desc') {
                        return -1;
                    }
                }
                return $value;
            }, $keys),
            'options' => $options,
        ];
    }
1213636
public static function isValidUploadFile(string $uploadField, array $arrMimeType = array(), Request $request) : bool
    {
        $uploadedFile = self::getFileSafe($uploadField, $request);

        if (!is_a($uploadedFile, UploadedFile::class)) {
            return false;
        }

        return UploadedFileHelper::isValidUploadFile($uploadedFile, $arrMimeType);
    }
1236860
private function getFiles(array $uploadedFiles)
    {
        $files = [];

        foreach ($uploadedFiles as $key => $value) {
            if (null === $value) {
                $files[$key] = $this->uploadedFileFactory->createUploadedFile($this->streamFactory->createStream(), 0, UPLOAD_ERR_NO_FILE);
                continue;
            }
            if ($value instanceof UploadedFile) {
                $files[$key] = $this->createUploadedFile($value);
            } else {
                $files[$key] = $this->getFiles($value);
            }
        }

        return $files;
    }
1270218
public function detachPersistor($key)
    {
        if (empty($this->persistors[$key])) {

            throw new \InvalidArgumentException(
                'No registered persistor found.',
                DataAggregatorException::PERSISTOR_NOT_FOUND
            );
        }

        unset($this->persistors[$key]);
    }
361799
protected static function normalize(array $files)
    {
        $normalized = [];
        foreach ($files as $key => $value) {
            if ($value instanceof UploadedFileInterface) {
                $normalized[$key] = $value;

                continue;
            }

            if (! is_array($value)) {
                throw new InvalidArgumentException(
                    'Invalid value in files specification.'
                );
            }

            if (isset($value['tmp_name'])) {
                $normalized[$key] = static::build($value);

                continue;
            }

            $normalized[$key] = static::normalize($value);
        }

        return $normalized;
    }
779190
private static function convertUploadedFiles(array $uploadedFiles)
    {
        $files = [];
        foreach ($uploadedFiles as $name => $uploadedFile) {
            if (!is_array($uploadedFile)) {
                $files[$name] = self::convertUploadedFile($uploadedFile);
                continue;
            }

            $files[$name] = [];
            foreach ($uploadedFile as $file) {
                $files[$name][] = self::convertUploadedFile($file);
            }
        }

        return $files;
    }
418582
public static function addJoin($query, $parentAlias, $schema, $relName, $nested=array(), $joinType='inner')
    {
        if (!in_array($joinType, array('inner','left','right'))) {
            throw new \InvalidArgumentException("Unsupported join type: $joinType");
        }

        list($relName, $alias) = self::parseRelName($relName);
        $rel = $schema->relationship($relName);

        // look up schema and table for both sides of join
        $instance = \Pheasant::instance();
        $localTable = $instance->mapperFor($schema->className())->table();
        $remoteSchema = $instance->schema($rel->class);
        $remoteTable = $instance->mapperFor($rel->class)->table();

        $joinMethod = $joinType.'Join';
        $query->$joinMethod($remoteTable->name()->table, sprintf(
            'ON `%s`.`%s`=`%s`.`%s`',
            $parentAlias,
            $rel->local,
            $alias,
            $rel->foreign
            ),
            $alias
        );

        foreach (self::normalizeMap($nested) as $relName=>$nested) {
            self::addJoin($query, $alias, $remoteSchema, $relName, $nested, $joinType);
        }
    }
326892
private function useWizard(UploadedFileSource $uploadFileSource)
    {
        $newType = $this->mediaTypeManager->findByMimetype($uploadFileSource->getMimeType());

        if (!$newType) {
            return false;
        }

        if ($this->mediaTypeMatcher->match($newType)) {
            return true;
        }

        return false;
    }
503977
public function prepareCustomFieldArray($fields, $groupID)
    {
        $fieldsQuery = [];
        $count = 0;
        foreach($fields as $field){
            $fieldsQuery[$count]['customFieldGroupID'] = $groupID;
            $fieldsQuery[$count]['tmpID'] = $field['id'];
            $fieldsQuery[$count]['label'] = json_encode($field['label']);
            $fieldsQuery[$count]['placeholder'] = json_encode($field['placeholder']);
            $fieldsQuery[$count]['note'] = json_encode($field['note']);
            $fieldsQuery[$count]['slug'] = $this->generateFieldSlug('', $field['slug'], $field['id'], $fields);
            $fieldsQuery[$count]['type'] = $field['type']['inputType'];
            $fieldsQuery[$count]['order'] = $field['order'];
            $fieldsQuery[$count]['isMultiple'] = $field['isMultiple'];
            $fieldsQuery[$count]['parentID'] = $field['parent'];
            $fieldsQuery[$count]['optionsValues'] = $field['multioptionValues'];
            $fieldsQuery[$count]['isRequired'] = $field['isRequired'];
            $fieldsQuery[$count]['isTranslatable'] = $field['isTranslatable'];
            $fieldsQuery[$count]['isActive'] = $field['isActive'];
            $fieldsQuery[$count]['defaultValue'] = $field['defaultValue'];
            $fieldsQuery[$count]['wrapperStyle'] = json_encode($field['wrapperStyle']);
            $fieldsQuery[$count]['fieldStyle'] = json_encode($field['fieldStyle']);
            $fieldsQuery[$count]['layout'] = $field['layout'];
            $fieldsQuery[$count]['conditions'] = json_encode($field['rules']);

            $properties = [
                'maxWidth' => $field['properties']['maxWidth'],
                'maxHeight' => $field['properties']['maxHeight'],
                'minWidth' => $field['properties']['minWidth'],
                'minHeight' => $field['properties']['minHeight'],
                'maxUploadSize' => $field['properties']['maxUploadSize'],
                'max' => $field['properties']['max'],
                'min' => $field['properties']['min'],
                'dbTable' => $field['properties']['dbTable'],
                'rangeLabel' => $field['properties']['rangeLabel'],
                'rows' => $field['properties']['rows'],
                'allowHTML' => $field['properties']['allowHTML'],
                'allowOther' => $field['properties']['allowOther'],
                'allowParagraphs' => $field['properties']['allowParagraphs'],
                'characterLimit' => $field['properties']['characterLimit'],
                'toolbar' => $field['properties']['toolbar'],
            ];
            $fieldsQuery[$count]['properties'] = json_encode($properties);
            $count++;
        }
        $customFieldsArr = $this->emptyFields($fieldsQuery);
        return $this->divideParentFromChildren($customFieldsArr);
    }
1222845
public function listGroupsAliases($groupKey, $optParams = array())
  {
    $params = array('groupKey' => $groupKey);
    $params = array_merge($params, $optParams);
    return $this->call('list', array($params), "Directory_Aliases");
  }
1220903
private function checkFiles(array $files) : void
    {
        foreach ($files as $value) {
            if (is_array($value)) {
                $this->checkFiles($value);
            } elseif (! $value instanceof UploadedFile) {
                $type = is_object($value) ? get_class($value) : gettype($value);

                throw new \InvalidArgumentException('Expected ' . UploadedFile::class . ' or array, got ' . $type);
            }
        }
    }
1091237
public function addHeader($headerKey, $headerValue)
    {
        if (!is_string($headerKey)) {
            throw new \InvalidArgumentException('Expected headerKey to be a string');
        }

        if (!is_scalar($headerValue)) {
            throw new \InvalidArgumentException('Expected headerValue to be a scalar');
        }

        $oldValue = null;
        if (array_key_exists($headerKey, $this->headers)) {
            $oldValue = $this->headers[$headerKey];
        }

        $this->headers[$headerKey] = $headerValue;

        return $oldValue;
    }
216832
public function upload(string $projectKey, string $ext, string $filename, array $params)
    {
        if (!file_exists($filename)) {
            throw new Exception\InvalidArgumentException('file '.$filename.' not found');
        }

        if (!isset($params['locale_id'])) {
            throw new Exception\InvalidArgumentException('locale_id is missing in params');
        }

        $postData = [
            ['name' => 'file', 'content' => file_get_contents($filename), 'filename' => basename($filename)],
            ['name' => 'file_format', 'content' => $ext],
            ['name' => 'locale_id', 'content' => $params['locale_id']],
        ];

        if (isset($params['update_translations'])) {
            $postData[] = ['name' => 'update_translations', 'content' => $params['update_translations']];
        }

        if (isset($params['tags'])) {
            $postData[] = ['name' => 'tags', 'content' => $params['tags']];
        }

        $response = $this->httpPostRaw(sprintf('/api/v2/projects/%s/uploads', $projectKey), $postData, [
            'Content-Type' => 'application/x-www-form-urlencoded',
        ]);

        if (!$this->hydrator) {
            return $response;
        }

        if ($response->getStatusCode() !== 200 && $response->getStatusCode() !== 201) {
            $this->handleErrors($response);
        }

        return $this->hydrator->hydrate($response, Uploaded::class);
    }
1162608
public function buildLeaf($uniqueKey = null, $parentKey = null)
    {
        if (isset($this->crown[$uniqueKey])) {
            throw new InvalidArgumentException(sprintf(
                'The leaf with key "%s" is already exists.',
                $uniqueKey
            ));
        }
        if ($parentKey && ! isset($this->crown[$parentKey])) {
            throw new InvalidArgumentException(sprintf(
                'Unknown leaf "%s" specified as parent.',
                $parentKey
            ));
        }
        $leaf = clone $this->getLeafPrototype();
        $this->injectInCrown($leaf, $uniqueKey);

        if ($parentKey) {
            $parent = $this->crown[$parentKey];
            $parent->addChild($leaf);
        } else {
            $this->branch[$leaf->getUniqueKey()] = $leaf;
            $leaf->setDepth(0);
        }

        return $leaf;
    }