Configures features in a way the API expects.

@param array $features An array of features to normalize.
@return array
181625
private function normalizeFeatures(array $features)
    {
        $results = [];

        foreach ($features as $feature) {
            $featureName = array_key_exists($feature, $this->featureShortNames)
                ? $this->featureShortNames[$feature]
                : $feature;

            $results[$featureName] = true;
        }

        return $results;
    }
683188
public function filtered_features_with_tags($features = '', $tags = '') {

        // This is for BC. Features if not passed then we already have a list in this object.
        if (empty($features)) {
            $features = $this->features;
        }

        // If no tags defined then return full list.
        if (empty($tags) && empty($this->tags)) {
            return $features;
        }

        // If no tags passed by the caller, then it's already set.
        if (empty($tags)) {
            $tags = $this->tags;
        }

        $newfeaturelist = array();
        // Split tags in and and or.
        $tags = explode('&&', $tags);
        $andtags = array();
        $ortags = array();
        foreach ($tags as $tag) {
            // Explode all tags seperated by , and add it to ortags.
            $ortags = array_merge($ortags, explode(',', $tag));
            // And tags will be the first one before comma(,).
            $andtags[] = preg_replace('/,.*/', '', $tag);
        }

        foreach ($features as $key => $featurefile) {
            $contents = file_get_contents($featurefile);
            $includefeature = true;
            foreach ($andtags as $tag) {
                // If negitive tag, then ensure it don't exist.
                if (strpos($tag, '~') !== false) {
                    $tag = substr($tag, 1);
                    if ($contents && strpos($contents, $tag) !== false) {
                        $includefeature = false;
                        break;
                    }
                } else if ($contents && strpos($contents, $tag) === false) {
                    $includefeature = false;
                    break;
                }
            }

            // If feature not included then check or tags.
            if (!$includefeature && !empty($ortags)) {
                foreach ($ortags as $tag) {
                    if ($contents && (strpos($tag, '~') === false) && (strpos($contents, $tag) !== false)) {
                        $includefeature = true;
                        break;
                    }
                }
            }

            if ($includefeature) {
                $newfeaturelist[$key] = $featurefile;
            }
        }
        return $newfeaturelist;
    }
503039
public function presetProperties(array &$properties)
    {
        $definitions = Config::getCommonDefinitions();
		
        foreach ($definitions as $definition) {
            $patterns = $this->getArrayByKey($definition, 'match');

            if (Helpers::strIs($patterns, $properties['name'])) {
                //auto add any config from the master config
                $settings = $this->getArrayByKey($definition, 'set');
				
                foreach ($settings as $key => $setting) {
					
                    if (!Helpers::isKeyExists($properties, $key) || empty($properties[$key])) {
                        $properties[$key] = $setting;
                    }
                }
            }
        }

        return $this;
    }
159022
public function setPatterns(array $patterns)
    {
        $patternValues = implode("", $patterns);
        if (mb_strlen($patternValues) < strlen($patternValues)) {
            $this->options['multibytePattern'] = true;
        }
        $this->options = array_merge($this->options, $patterns);

        return $this;
    }
231441
private function configure(array $options = []): array
    {
        $resolver = new OptionsResolver();
        $resolver->setDefaults([
            'max_restarts' => 10,
        ]);

        $resolver->setAllowedTypes('max_restarts', 'int');

        return $resolver->resolve($options);
    }
765954
public function setProperties(array $properties) {
		foreach ($this->properties as $prop) {
			$prop->setParent(null);
		}

		$this->properties->clear();

		foreach ($properties as $prop) {
			$this->setProperty($prop);
		}

		return $this;
	}
390376
public function setPolicies(array $policies)
    {
        $this->policies = [];
        
        foreach ($policies as $policy) {
            $this->policies[] = $this->policyFactory($policy);
        }
        
        return $this;
    }
148276
protected function fieldsToConfig(array $fields)
    {
        $config = [];
        foreach ($fields as $field) {
            $config[$field['name']] = $field['default'];
        }

        return $config;
    }
1040710
public function setProperties(array $properties)
    {
        if (isset($properties[ 'presets' ])) {
            $this->setPresets($properties[ 'presets' ]);

            unset($properties[ 'presets' ]);
        }

        $this->properties = $properties;

        return $this;
    }
181189
public static function normalizeFilesArray(array $files): array
    {
        $return = [];
        foreach ($files as $i => $file) {
            foreach ($file as $key => $value) {
                $return[$key][$i] = $value;
            }
        }

        return $return;
    }
1132597
protected function normalizeOptions(array $options): array
    {
        $options = array_replace($this->getDefaultOptions(), $options);

        $options['cacheDir'] = PathResolver::realpath($options['cacheDir']);

        if (!$options['cacheDir']) {
            throw new \RuntimeException('You need to provide valid cache directory for Go! AOP framework.');
        }

        $options['excludePaths'][] = $options['cacheDir'];
        $options['excludePaths'][] = __DIR__ . '/../';
        $options['appDir']         = PathResolver::realpath($options['appDir']);
        $options['cacheFileMode']  = (int) $options['cacheFileMode'];
        $options['includePaths']   = PathResolver::realpath($options['includePaths']);
        $options['excludePaths']   = PathResolver::realpath($options['excludePaths']);

        return $options;
    }
239534
protected function normalizeConfig(array $config)
    {
        foreach ($this->configModel as $elmt => $settings) {
            if (!isset($config[$elmt])) {
                $config[$elmt] = $settings['default'];
            }
        }

        foreach ($config as $elmtName => $value) {
            if (!isset($this->configModel[$elmtName])) {
                unset($config[$elmtName]);
            }
        }

        return $config;
    }
431566
protected static function normalizeNested(array $files)
    {
        $normalized = [];
        foreach (array_keys($files['tmp_name']) as $key) {
            $spec = [
                'name'     => $files['name'][$key],
                'tmp_name' => $files['tmp_name'][$key],
                'type'     => $files['type'][$key],
                'size'     => $files['size'][$key],
                'error'    => $files['error'][$key],
            ];
            $normalized[$key] = static::build($spec);
        }

        return $normalized;
    }
102242
protected function transformConstraintArray(array $constraints)
    {
        $self = $this;

        return array_map(
            function (ConstraintInterface $constraint) use ($self) {
                return $constraint->accept($self);
            },
            $constraints
        );
    }
440923
public function normalizeKeys($keys)
    {
        if ($keys === true) {
            $keys = $this->keys();
        }

        if (empty($keys)) {
            return [];
        }

        return $this->_normalizeAssociations($keys);
    }
120974
public static function get_supported_features(array $configuration = array()) {
        $supports = self::SUPPORTS_DATA_GUARANTEE + self::DEREFERENCES_OBJECTS;
        if (array_key_exists('extendedmode', $configuration) && $configuration['extendedmode']) {
            $supports += self::SUPPORTS_MULTIPLE_IDENTIFIERS;
        }
        return $supports;
    }
788151
public static function normalizeEach(array $expressions)
    {
        foreach ($expressions as $i => $expression) {
            $expressions[$i] = self::normalize($expression);
        }

        return $expressions;
    }