PMA\libraries\config\FormDisplay::_validateSelect PHP Method

_validateSelect() private method

Validates select field and casts $value to correct type
private _validateSelect ( &$value, array $allowed ) : boolean
$allowed array List of allowed values
return boolean
    private function _validateSelect(&$value, array $allowed)
    {
        $value_cmp = is_bool($value) ? (int) $value : $value;
        foreach ($allowed as $vk => $v) {
            // equality comparison only if both values are numeric or not numeric
            // (allows to skip 0 == 'string' equalling to true)
            // or identity (for string-string)
            if ($vk == $value && !(is_numeric($value_cmp) xor is_numeric($vk)) || $vk === $value) {
                // keep boolean value as boolean
                if (!is_bool($value)) {
                    settype($value, gettype($vk));
                }
                return true;
            }
        }
        return false;
    }