src/FACTFinder/Core/ParametersConverter.php
protected function applyWhitelist($parameters, $whitelistRules)
    {
        //do not apply empty whitelist as this means no whitelist desired
        if(empty($whitelistRules)) {
            return;
        }
        //collect all keys of parameters that pass any whitelist rule
        $allowedKeys = array();
        $keys = array_keys($parameters->getArray());
        foreach ($whitelistRules as $rule => $v) {
            if(strpos($rule, '/') === 0) {
                $allowedKeys = array_merge($allowedKeys, preg_grep($rule, $keys));
            } else {
                $allowedKeys[] = $rule;
            }
        }
        $allowedKeys = array_flip($allowedKeys);
        //unset any parameters that did not pass any whitelist rule
        foreach($parameters->getArray() as $k => $v) {
            if(!isset($allowedKeys[$k])) {
                unset($parameters[$k]);
            }
        }
    }
protected function applyWhitelist($parameters, $whitelistRules)
    {
        //do not apply empty whitelist as this means no whitelist desired
        if(empty($whitelistRules)) {
            return;
        }
        //collect all keys of parameters that pass any whitelist rule
        $allowedKeys = array();
        $keys = array_keys($parameters->getArray());
        foreach ($whitelistRules as $rule => $v) {
            if(strpos($rule, '/') === 0) {
                $allowedKeys = array_merge($allowedKeys, preg_grep($rule, $keys));
            } else {
                $allowedKeys[] = $rule;
            }
        }
        $allowedKeys = array_flip($allowedKeys);
        //unset any parameters that did not pass any whitelist rule
        foreach($parameters->getArray() as $k => $v) {
            if(!isset($allowedKeys[$k])) {
                unset($parameters[$k]);
            }
        }
    }
Removes keys from a Parameters object according to the given whitelist rules.
An empty whitelist means do NOT apply any whitelist (anything is allowed).
It removes any keys that are not keys in the given whitelist array aswell.
If the key of any rule starts with '/' the key is interpreted as a regular expression to be matched against.
@param type $parameters
@param bool[] $whitelistRules Array of parameters to be allowed. The keys
are the parameter names, the values are simply "true", but could
technically have any value.