Get the filter config for the supplied whitelist and excludelist configuration.

@param   array[] $whitelists The list of files/folders in the whitelist.
@param   array[] $excludelists The list of files/folders in the excludelist.
@return  string
17527
protected static function get_filter_config(array $whitelists, array $excludelists) : string {
        $filters = '';
        if (!empty($whitelists)) {
            $filters .= self::pad("<whitelist>", 2);
            foreach ($whitelists as $line) {
                $filters .= self::pad($line, 3);
            }
            if (!empty($excludelists)) {
                $filters .= self::pad("<exclude>", 3);
                foreach ($excludelists as $line) {
                    $filters .= self::pad($line, 4);
                }
                $filters .= self::pad("</exclude>", 3);
            }
            $filters .= self::pad("</whitelist>", 2);
        }

        return $filters;
    }
1071346
private static function checkPruneFilter(array $filters)
    {
        $filters_array = [];
        if ($filters) {
            foreach ($filters as $k => $v) {
                if (!\in_array($k, ['label', 'until'], true)) {
                    throw new Exception('Network Prune Filters '.$k.' Not Found', 404);
                }

                if (\is_array($v)) {
                    $filters_array[$k] = $v;
                } else {
                    $filters_array[$k] = [$v];
                }
            }
        } else {
            $filters_array = null;
        }

        return json_encode($filters_array);
    }
329026
private function filterBundleList(array $bundleList)
    {
        $groups = [];
        foreach ($_ENV as $name => $val) {
            if (substr($name, 0, strlen($this->envDynGroupPrefix)) == $this->envDynGroupPrefix) {
                $groups[substr($name, strlen($this->envDynGroupPrefix))] = $val;
            }
        }

        if (empty($groups)) {
            // no groups.. exit
            return $bundleList;
        }

        foreach ($groups as $groupName => $filter) {
            if (isset($_ENV[$this->envDynSettingPrefix.$groupName]) &&
                $_ENV[$this->envDynSettingPrefix.$groupName] == 'false'
            ) {
                $bundleList = array_filter(
                    $bundleList,
                    function ($value) use ($filter) {
                        if (preg_match('/'.$filter.'/i', $value) || empty(trim($value))) {
                            return false;
                        }
                        return true;
                    }
                );
            }
        }

        return $bundleList;
    }
977724
private function mergeLists(array $blacklist, array $whitelist) : array
    {
        if (count(array_intersect($blacklist, $whitelist)) !== 0) {
            throw new LogicException('Directories can\'t be black- and whitelisted at the same time', 1553780055);
        }

        return array_merge(
            array_fill_keys($blacklist, false),
            array_fill_keys($whitelist, true)
        );
    }
87772
public function getOptions(array $excludes = null): array
    {
        $options = parent::getOptions($excludes);

        /*
         * Let's add the choices in a readable format as
         * well as the layout property.
         */
        $choices = $this->getOption('choices', []);

        if ($choices instanceof ChoiceListInterface) {
            $choices = $choices->format()->get();
        }

        return array_merge($options, [
            'choices' => $choices,
            'layout' => $this->getLayout()
        ]);
    }
666988
protected function iterateOverFiles(string $filter, array $files, array $list) : array
    {
        $result = [];
        foreach ($files as $filePath) {
            //Filter by filter.
            if ($filter !== '' && substr($filePath, -strlen($filter)) !== $filter) {
                continue;
            }
            //Filter by black/white List
            $directory = dirname($filePath);
            $lastDirectoryPath = $filePath;
            while (!in_array($directory, [$this->environment->getRootDirectory(), '', $lastDirectoryPath], true)
            ) {
                if (array_key_exists($directory, $list)) {
                    if ($list[$directory] === true) {
                        $result[] = $filePath;
                    }
                    continue 2;
                }
                $lastDirectoryPath = $directory;
                $directory = dirname($directory);
            }
            $result[] = $filePath;
        }
        return $result;
    }
443536
protected function excludes($excludes)
    {
        $excludes = \is_array($excludes) ? $excludes : \func_get_args();

        $this->excludes = $excludes;

        return $this;
    }
718417
public static function in($data, $whiteList)
    {
        if ($data) {
            if (is_object($data)) {
                $data = get_object_vars($data);
            }
            $whiteList = array_flip($whiteList);

            //Filter
            foreach ($data as $key => $value) {
                if (is_object($value)) {
                    $value = get_object_vars($value);
                }
                $data[$key] = array_intersect_key($value, $whiteList);
            }
        }
        return $data;
    }
374058
private function sanitizeFilters(array $filters): array
    {
        $sanitized = array_filter($filters, function (string $name): bool {
            return isset($this->loaders[$name]);
        }, ARRAY_FILTER_USE_KEY);

        if (\count($filters) !== \count($sanitized)) {
            throw new \InvalidArgumentException(sprintf('Could not find filter(s): %s', implode(', ', array_map(function (string $name): string {
                return sprintf('"%s"', $name);
            }, array_diff(array_keys($filters), array_keys($sanitized))))));
        }

        return $sanitized;
    }
1052485
public function filter(array $filters)
	{
		foreach ($filters as $filter) {
			if ($filter->isValueSet()) {
				if ($filter->hasConditionCallback()) {
					Callback::invokeArgs(
						$filter->getConditionCallback(),
						[$this->data_source, $filter->getValue()]
					);
				} else {
					if ($filter instanceof Filter\FilterText) {
						$this->applyFilterText($filter);
					} elseif ($filter instanceof Filter\FilterMultiSelect) {
						$this->applyFilterMultiSelect($filter);
					} elseif ($filter instanceof Filter\FilterSelect) {
						$this->applyFilterSelect($filter);
					} elseif ($filter instanceof Filter\FilterDate) {
						$this->applyFilterDate($filter);
					} elseif ($filter instanceof Filter\FilterDateRange) {
						$this->applyFilterDateRange($filter);
					} elseif ($filter instanceof Filter\FilterRange) {
						$this->applyFilterRange($filter);
					}
				}
			}
		}

		return $this;
	}
674380
public function getOptions(array $excludes = null): array
    {
        if (! is_null($excludes)) {
            return array_filter($this->options, function ($key) use ($excludes) {
                return ! in_array($key, $excludes, true);
            }, ARRAY_FILTER_USE_KEY);
        }

        return $this->options;
    }
962135
protected function getExcludedURLSegments()
    {
        $excludes = [];

        // Build from rules
        foreach (Director::config()->get('rules') as $pattern => $rule) {
            $route = explode('/', $pattern);
            if (!empty($route) && strpos($route[0], '$') === false) {
                $excludes[] = strtolower($route[0]);
            }
        }

        // Build from base folders
        foreach (glob(Director::publicFolder() . '/*', GLOB_ONLYDIR) as $folder) {
            $excludes[] = strtolower(basename($folder));
        }

        $this->extend('updateExcludedURLSegments', $excludes);
        return $excludes;
    }
1257721
public static function get_include_files( $directory, $exclude_underscore = false ) {
		$return = [
			'files'       => [],
			'directories' => [],
		];

		if ( ! is_dir( $directory ) ) {
			return $return;
		}

		$directory_iterator = new \DirectoryIterator( $directory );

		foreach ( $directory_iterator as $file ) {
			if ( $file->isDot() ) {
				continue;
			}

			if ( $file->isDir() ) {
				$return['directories'][] = $file->getPathname();
				continue;
			}

			if ( 'php' !== $file->getExtension() ) {
				continue;
			}

			if ( $exclude_underscore ) {
				if ( 0 === strpos( $file->getBasename(), '_' ) ) {
					continue;
				}
			}

			$return['files'][] = $file->getPathname();
		}

		return $return;
	}
116890
def remove_excluded_files(files)
      return files if @exclude.empty?
      files.reject do |file|
        @exclude.any? { |exclude| File.fnmatch(exclude, file) }
      end
    end
1184262
public static function filterFieldList($fieldsList, $filters = array())
    {
        $result = array();

        foreach ($fieldsList as $field) {
            if (in_array($field->id, $filters, true)) {
                $result[] = $field;
            }
        }

        return $result;
    }
382322
function merge(config, extension, separator, whitelist) {
    whitelist = whitelist || [];
    separator = separator || ":";

    Object
        .keys(extension)
        .filter(function (key) {
            return !whitelist.length || whitelist.indexOf(key) !== -1;
        })
        .forEach(function (key) {
            applyKey(config, key.split(separator), extension[key]);
        });

    return config;
}
599761
private function initFilters(array $filters)
    {
    	$result = array();
    
    	$fm = $this->getFilterManager();
    
    	foreach ($filters as $alias => $options) {
    		$option = null;
    		if (is_array($options)) {
    			if (!isset($options['name'])) {
    				throw new Exception\InvalidArgumentException(
    						'Filter "' . $alias . '" required option "name"'
    				);
    			}
    
    			$name = $options['name'];
    			$option = isset($options['option']) ? $options['option'] : null;
    		} elseif (is_string($options)) {
    			$name = $options;
    			unset($options);
    		}
    
    		if (is_numeric($alias)) {
    			$alias = $name;
    		}
    
    		// Filter Id should have optional filter indicator "?"
    		$filterId = ltrim($alias, '?');
    
    		if (!$fm->has($filterId)) {
    			if (is_array($option) && !empty($option)) {
    				$r = new \ReflectionClass($name);
    				$filter = $r->newInstanceArgs($option);
    			} else if ($option) {
    				$filter = new $name($option);
    			} else {
    				$filter = new $name();
    			}
    
    			$fm->set($filterId, $filter);
    		}
    
    		$result[] = $alias;
    	}
    
    	return $result;
    }