• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
Yoast SEO a2z

Yoast SEO a2z

WordPress SEO a2z

  • Home
  • Plugins
  • Blocks
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / ParameterBag::resolveString() – Resolves parameters inside a string.

You appear to be a bot. Output may be restricted

Description

Resolves parameters inside a string.

Usage

$string = ParameterBag::resolveString( $value, $resolving );

Parameters

$value
( string ) required – The string to resolve
$resolving
( array ) optional – An array of keys that are being resolved (used internally to detect circular references)

Returns

string The resolved string

Source

File name: wordpress-seo/vendor_prefixed/symfony/dependency-injection/ParameterBag/ParameterBag.php


Lines:

1 to 36 of 36
    public function resolveString($value, array $resolving = [])
    {
        // we do this to deal with non string values (Boolean, integer, ...)
        // as the preg_replace_callback throw an exception when trying
        // a non-string in a parameter value
        if (\preg_match('/^%([^%\\s]+)%$/', $value, $match)) {
            $key = $match[1];
            $lcKey = \strtolower($key);
            // strtolower() to be removed in 4.0
            if (isset($resolving[$lcKey])) {
                throw new \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\ParameterCircularReferenceException(\array_keys($resolving));
            }
            $resolving[$lcKey] = \true;
            return $this->resolved ? $this->get($key) : $this->resolveValue($this->get($key), $resolving);
        }
        return \preg_replace_callback('/%%|%([^%\\s]+)%/', function ($match) use($resolving, $value) {
            // skip %%
            if (!isset($match[1])) {
                return '%%';
            }
            $key = $match[1];
            $lcKey = \strtolower($key);
            // strtolower() to be removed in 4.0
            if (isset($resolving[$lcKey])) {
                throw new \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\ParameterCircularReferenceException(\array_keys($resolving));
            }
            $resolved = $this->get($key);
            if (!\is_string($resolved) && !\is_numeric($resolved)) {
                throw new \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('A string value must be composed of strings and/or numbers, but found parameter "%s" of type %s inside string value "%s".', $key, \gettype($resolved), $value));
            }
            $resolved = (string) $resolved;
            $resolving[$lcKey] = \true;
            return $this->isResolved() ? $resolved : $this->resolveString($resolved, $resolving);
        }, $value);
    }
 

 View on GitHub View on Trac

Published: 27th November 2019 | Last updated: 27th November 2019

Primary Sidebar

Information

Function name: ParameterBag::resolveString
Class ref: ParameterBag
Plugin ref: Yoast SEO
Version: 15.4
Sourcefile: vendor_prefixed/symfony/dependency-injection/ParameterBag/ParameterBag.php
File ref: vendor_prefixed/symfony/dependency-injection/ParameterBag/ParameterBag.php
Deprecated?: No
API Letters: P,R

Footer

Yoast SEO a2z
Yoast SEO a2z
WordPress SEO a2z
WordPress 5.6
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  wordpress-seo.wp-a2z.org
© Copyright Yoast SEO a2z 2017-2021. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites