WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

YoastSEO_Vendor\GuzzleHttp

UriTemplate::expandMatch() private Yoast 1.0

Process an expansion

{} Это метод класса: UriTemplate{}

Хуков нет.

Возвращает

Строку. Returns the replacement string

Использование

// private - только в коде основоного (родительского) класса
$result = $this->expandMatch( $matches );
$matches(массив) (обязательный)
Matches met in the preg_replace_callback

Код UriTemplate::expandMatch() Yoast 15.6.2

<?php
private function expandMatch(array $matches)
{
    static $rfc1738to3986 = ['+' => '%20', '%7e' => '~'];
    $replacements = [];
    $parsed = self::parseExpression($matches[1]);
    $prefix = self::$operatorHash[$parsed['operator']]['prefix'];
    $joiner = self::$operatorHash[$parsed['operator']]['joiner'];
    $useQuery = self::$operatorHash[$parsed['operator']]['query'];
    foreach ($parsed['values'] as $value) {
        if (!isset($this->variables[$value['value']])) {
            continue;
        }
        $variable = $this->variables[$value['value']];
        $actuallyUseQuery = $useQuery;
        $expanded = '';
        if (\is_array($variable)) {
            $isAssoc = $this->isAssoc($variable);
            $kvp = [];
            foreach ($variable as $key => $var) {
                if ($isAssoc) {
                    $key = \rawurlencode($key);
                    $isNestedArray = \is_array($var);
                } else {
                    $isNestedArray = \false;
                }
                if (!$isNestedArray) {
                    $var = \rawurlencode($var);
                    if ($parsed['operator'] === '+' || $parsed['operator'] === '#') {
                        $var = $this->decodeReserved($var);
                    }
                }
                if ($value['modifier'] === '*') {
                    if ($isAssoc) {
                        if ($isNestedArray) {
                            // Nested arrays must allow for deeply nested
                            // structures.
                            $var = \strtr(\http_build_query([$key => $var]), $rfc1738to3986);
                        } else {
                            $var = $key . '=' . $var;
                        }
                    } elseif ($key > 0 && $actuallyUseQuery) {
                        $var = $value['value'] . '=' . $var;
                    }
                }
                $kvp[$key] = $var;
            }
            if (empty($variable)) {
                $actuallyUseQuery = \false;
            } elseif ($value['modifier'] === '*') {
                $expanded = \implode($joiner, $kvp);
                if ($isAssoc) {
                    // Don't prepend the value name when using the explode
                    // modifier with an associative array.
                    $actuallyUseQuery = \false;
                }
            } else {
                if ($isAssoc) {
                    // When an associative array is encountered and the
                    // explode modifier is not set, then the result must be
                    // a comma separated list of keys followed by their
                    // respective values.
                    foreach ($kvp as $k => &$v) {
                        $v = $k . ',' . $v;
                    }
                }
                $expanded = \implode(',', $kvp);
            }
        } else {
            if ($value['modifier'] === ':') {
                $variable = \substr($variable, 0, $value['position']);
            }
            $expanded = \rawurlencode($variable);
            if ($parsed['operator'] === '+' || $parsed['operator'] === '#') {
                $expanded = $this->decodeReserved($expanded);
            }
        }
        if ($actuallyUseQuery) {
            if (!$expanded && $joiner !== '&') {
                $expanded = $value['value'];
            } else {
                $expanded = $value['value'] . '=' . $expanded;
            }
        }
        $replacements[] = $expanded;
    }
    $ret = \implode($joiner, $replacements);
    if ($ret && $prefix) {
        return $prefix . $ret;
    }
    return $ret;
}