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

Breadcrumb

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

function UnicodeString::indexOfLast

Overrides AbstractString::indexOfLast

File

vendor/symfony/string/UnicodeString.php, line 158

Class

UnicodeString
Represents a string of Unicode grapheme clusters encoded as UTF-8.

Namespace

Symfony\Component\String

Code

public function indexOfLast(string|iterable|AbstractString $needle, int $offset = 0) : ?int {
    if ($needle instanceof AbstractString) {
        $needle = $needle->string;
    }
    elseif (!\is_string($needle)) {
        return parent::indexOfLast($needle, $offset);
    }
    $form = null === $this->ignoreCase ? \Normalizer::NFD : \Normalizer::NFC;
    normalizer_is_normalized($needle, $form) ?: ($needle = normalizer_normalize($needle, $form));
    if ('' === $needle || false === $needle) {
        return null;
    }
    $string = $this->string;
    if (0 > $offset) {
        // workaround https://bugs.php.net/74264
        if (0 > ($offset += grapheme_strlen($needle))) {
            $string = grapheme_substr($string, 0, $offset);
        }
        $offset = 0;
    }
    $i = $this->ignoreCase ? grapheme_strripos($string, $needle, $offset) : grapheme_strrpos($string, $needle, $offset);
    return false === $i ? null : $i;
}

API Navigation

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