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

Breadcrumb

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

function FFICaster::castFFIStringValue

File

vendor/symfony/var-dumper/Caster/FFICaster.php, line 115

Class

FFICaster
Casts FFI extension classes to array representation.

Namespace

Symfony\Component\VarDumper\Caster

Code

private static function castFFIStringValue(CData $data) : string|CutStub {
    $result = [];
    $ffi = \FFI::cdef(<<<C
    size_t zend_get_page_size(void);
C
);
    $pageSize = $ffi->zend_get_page_size();
    // get cdata address
    $start = $ffi->cast('uintptr_t', $ffi->cast('char*', $data))->cdata;
    // accessing memory in the same page as $start is safe
    $max = min(self::MAX_STRING_LENGTH, ($start | $pageSize - 1) - $start);
    for ($i = 0; $i < $max; ++$i) {
        $result[$i] = $data[$i];
        if ("\x00" === $data[$i]) {
            return implode('', $result);
        }
    }
    $string = implode('', $result);
    $stub = new CutStub($string);
    $stub->cut = -1;
    $stub->value = $string;
    return $stub;
}

API Navigation

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