Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Preg.php

function Preg::replaceCallback

@param-out int<0, max> $count

Parameters

string|string[] $pattern:

($flags is PREG_OFFSET_CAPTURE ? (callable(array<int|string, array{string|null, int<-1, max>}>): string) : callable(array<int|string, string|null>): string) $replacement:

string $subject:

int $count Set by method:

int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set:

17 calls to Preg::replaceCallback()
AutoloadGenerator::parseAutoloadsType in vendor/composer/composer/src/Composer/Autoload/AutoloadGenerator.php
BufferIO::getOutput in vendor/composer/composer/src/Composer/IO/BufferIO.php
ClassMapGenerator::normalizePath in vendor/composer/class-map-generator/src/ClassMapGenerator.php
Normalize a path. This replaces backslashes with slashes, removes ending slash and collapses redundant separators and up-level references.
Config::process in vendor/composer/composer/src/Composer/Config.php
Replaces {$refs} inside a config string
EventDispatcher::doDispatch in vendor/composer/composer/src/Composer/EventDispatcher/EventDispatcher.php
Triggers the listeners of an event.

... See full list

File

vendor/composer/pcre/src/Preg.php, line 177

Class

Preg

Namespace

Composer\Pcre

Code

public static function replaceCallback($pattern, callable $replacement, $subject, int $limit = -1, ?int &$count = null, int $flags = 0) : string {
    if (!is_scalar($subject)) {
        if (is_array($subject)) {
            throw new \InvalidArgumentException(static::ARRAY_MSG);
        }
        throw new \TypeError(sprintf(static::INVALID_TYPE_MSG, gettype($subject)));
    }
    $result = preg_replace_callback($pattern, $replacement, $subject, $limit, $count, $flags | PREG_UNMATCHED_AS_NULL);
    if ($result === null) {
        throw PcreException::fromFunction('preg_replace_callback', $pattern);
    }
    return $result;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal