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

Breadcrumb

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

function Data::seek

Seeks to a specific key in nested data structures.

2 calls to Data::seek()
Data::__get in vendor/symfony/var-dumper/Cloner/Data.php
Data::__isset in vendor/symfony/var-dumper/Cloner/Data.php

File

vendor/symfony/var-dumper/Cloner/Data.php, line 222

Class

Data
@author Nicolas Grekas <p@tchwork.com>

Namespace

Symfony\Component\VarDumper\Cloner

Code

public function seek(string|int $key) : ?static {
    $item = $this->data[$this->position][$this->key];
    if ($item instanceof Stub && Stub::TYPE_REF === $item->type && !$item->position) {
        $item = $item->value;
    }
    if (!($item = $this->getStub($item)) instanceof Stub || !$item->position) {
        return null;
    }
    $keys = [
        $key,
    ];
    switch ($item->type) {
        case Stub::TYPE_OBJECT:
            $keys[] = Caster::PREFIX_DYNAMIC . $key;
            $keys[] = Caster::PREFIX_PROTECTED . $key;
            $keys[] = Caster::PREFIX_VIRTUAL . $key;
            $keys[] = "\x00{$item->class}\x00{$key}";
        // no break
        case Stub::TYPE_ARRAY:
        case Stub::TYPE_RESOURCE:
            break;
        default:
            return null;
    }
    $data = null;
    $children = $this->data[$item->position];
    foreach ($keys as $key) {
        if (isset($children[$key]) || \array_key_exists($key, $children)) {
            $data = clone $this;
            $data->key = $key;
            $data->position = $item->position;
            break;
        }
    }
    return $data;
}
RSS feed
Powered by Drupal