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

Breadcrumb

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

function FFICaster::castFFIStructLike

File

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

Class

FFICaster
Casts FFI extension classes to array representation.

Namespace

Symfony\Component\VarDumper\Caster

Code

private static function castFFIStructLike(CType $type, ?CData $data = null) : array {
    $isUnion = ($type->getAttributes() & CType::ATTR_UNION) === CType::ATTR_UNION;
    $result = [];
    foreach ($type->getStructFieldNames() as $name) {
        $field = $type->getStructFieldType($name);
        // Retrieving the value of a field from a union containing
        // a pointer is not a safe operation, because may contain
        // incorrect data.
        $isUnsafe = $isUnion && CType::TYPE_POINTER === $field->getKind();
        if ($isUnsafe) {
            $result[Caster::PREFIX_VIRTUAL . $name . '?'] = $field;
        }
        elseif (null === $data) {
            $result[Caster::PREFIX_VIRTUAL . $name] = $field;
        }
        else {
            $fieldName = $data->{$name} instanceof CData ? '' : $field->getName() . ' ';
            $result[Caster::PREFIX_VIRTUAL . $fieldName . $name] = $data->{$name};
        }
    }
    return $result;
}

API Navigation

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