Tokenize the HTTP field for subsequent processing.

Note: we don't need to worry about multi-byte characters; HTTP fields must be ISO-8859-1 encoded.

@param string $httpField
@param string $fromField

@return array<string>
328037
public function tokenize($httpField, $fromField)
    {
        $quoteSeparators = array('"', "'");
        $tokenList = array();
        $stringAccumulator = '';
        $lastQuote = '';

        // Iterate through field, character-by-character
        for ($i = 0; $i < strlen($httpField); $i++) {
            $chr = substr($httpField, $i, 1);

            switch (true) {

                // We are at the end of a quoted string
                case $chr === $lastQuote:
                    $tokenList[] = $stringAccumulator;
                    $stringAccumulator = '';
                    $lastQuote = '';
                    break;

                // We have found the beginning of a quoted string
                case in_array($chr, $quoteSeparators):
                    $lastQuote = $chr;
                    break;

                // We are already within a quoted string, but not yet at the end
                case strlen($lastQuote):
                    $stringAccumulator .= $chr;
                    break;

                // Separators found, add previously accumulated string & separator to token list
                case Tokens::isSeparator($chr, Preference::MIME === $fromField):
                    if (strlen($stringAccumulator)) {
                        $tokenList[] = $stringAccumulator;
                        $stringAccumulator = '';
                    }

                    $tokenList[] = $chr;
                    break;

                // Simply accumulate characters
                default:
                    $stringAccumulator .= $chr;
                    break;
            }
        }

        // Handle final component
        if (strlen($stringAccumulator)) {
            $tokenList[] = $stringAccumulator;
        }

        // Remove any padding whitespace from token list
        $tokenList = array_map('trim', $tokenList);

        return $tokenList;
    }
815905
private function parseRuleParameters($field, $parameters)
    {
        // Make sure parameters is an array
        $parameters = (strpos($parameters, ',') > 0) ? explode(',', $parameters) : [$parameters];

        // Process each parameter
        foreach ($parameters as $key => $parameter)
        {
            // Replace ~table and ~field if they exist
            $parameter = str_ireplace(['~table', '~field'], [$this->getTable(), $field], $parameter);

            // Replace with attribute
            if (strpos($parameter, '~') !== false) $parameter = $this->{str_replace('~', '', $parameter)};
        }

        return $parameters;
    }
946123
public function alphaNumeric($field)
    {
        return (ctype_alnum((string)$this->get($field)) === true) ?: $this->error($field, __FUNCTION__);
    }
602596
public function localizeField($field) {
        $re = "/(?:[-])(".$this->multilingual_parameters['default_language'].")(?:[-])/";
        $language = "-".$this->languageDetection()."-";
        $field = preg_replace($re, $language,$field);
        return $field;
    }
854978
public void out2field(Object from, String from_out, Object o, String field) {
        controller.mapOutField(from, from_out, o, field);
    }
60023
def encode_field(self, field, value):
    
    # Override the handling of 64-bit integers, so they're always encoded
    # as strings.
    if (isinstance(field, messages.IntegerField) and
        field.variant in (messages.Variant.INT64,
                          messages.Variant.UINT64,
                          messages.Variant.SINT64)):
      if value not in (None, [], ()):
        # Convert and replace the value.
        if isinstance(value, list):
          value = [str(subvalue) for subvalue in value]
        else:
          value = str(value)
        return value

    return super(EndpointsProtoJson, self).encode_field(field, value)
22662
protected function provideFromRequest(RequestInterface $request, string $field) : string
    {
        Assert::isInstanceOf($request, ServerRequest::class);

        $data = $request->getData();

        $result = is_array($data) && array_key_exists($field, $data) ? (string)$data[$field] : '';

        return $result;
    }
97197
public function map($field, $context = null)
    {
        if (array_key_exists('hidden', $field)) {
            $field['hidden'] = (bool) $field['hidden'];
        } else {
            $field['hidden'] = false;
        }

        if (!array_key_exists('restrictions', $field)) {
            $field['restrictions'] = [];
        }

        return $field;
    }
182348
private function genericAll($clientField, $serverField, $fromField)
    {
        $clientPrefList = $this->parsePreferences(false, $clientField, $fromField);
        $serverPrefList = $this->parsePreferences(true, $serverField, $fromField);

        return $this->negotiator->negotiateAll($clientPrefList, $serverPrefList, $fromField);
    }
851097
public function mbstring($fromOverride = null)
    {
        try {
            $converted = mb_convert_encoding($this->string, self::ENCODING, $fromOverride === null ? $this->encoding : $fromOverride);
        } catch (\Exception $e) {
            return false;
        }
        return $converted;
    }
1164278
private function genericBest($clientField, $serverField, $fromField)
    {
        $clientPrefList = $this->parsePreferences(false, $clientField, $fromField);
        $serverPrefList = $this->parsePreferences(true, $serverField, $fromField);

        return $this->negotiator->negotiateBest($clientPrefList, $serverPrefList, $fromField)->getVariant();
    }
448497
public static byte[] get(Object from, Field field)
    {
        PropertyAccessor<?> accessor = PropertyAccessorFactory.getPropertyAccessor(field);
        return accessor.toBytes(getObject(from, field));
    }
795378
static String toAnnotation(Map<String, ?> fields) {
    // special-case the "event" field which is similar to the semantics of a zipkin annotation
    Object event = fields.get("event");
    if (event != null && fields.size() == 1) return event.toString();

    return joinOnEqualsSpace(fields);
  }
354635
protected function _getTokenFromSqlWhere($from, $fieldName)
    {
        $lsDb = $this->getSourceDatabase();
        $tokField = $lsDb->quoteIdentifier($fieldName);

        foreach (str_split($from) as $check) {
            $checks[] = 'LOCATE(' . $lsDb->quote($check) . ', ' . $tokField . ')';
        }

        return '(' . implode(' OR ', $checks) . ')';
    }
897254
public function withoutHeader(string $field): self {
        $lower = \strtolower($field);

        $clone = clone $this;

        unset(
            $clone->headerCaseMap[$lower],
            $clone->headers[$lower]
        );

        return $clone;
    }
100809
protected function initializeField($field)
    {
        $field->setParentContext($this);
        $this->getFieldManager()->pushField($field);
        return $field;
    }
872432
private function parseBundle(array $tokenBundle, $serverField, $fromField)
    {
        $pref = null;
        try {
            list($variantTokenList, $paramTokenList) = $this->splitVariantAndParamTokens($tokenBundle, $fromField);

            $paramBundleList = $this->bundleTokens($paramTokenList, Tokens::PARAMS_SEPARATOR);
            $this->validateParamBundleList($paramBundleList, $serverField);

            $pref = $this->createPreference($variantTokenList, $paramBundleList, $serverField, $fromField);

        } catch (InvalidVariantException $e) {
            if ($serverField) {
                throw $e;
            }
        }

        return $pref;
    }