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

Breadcrumb

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

function JsonDecoder::decodeNode

1 call to JsonDecoder::decodeNode()
JsonDecoder::decodeRecursive in vendor/nikic/php-parser/lib/PhpParser/JsonDecoder.php

File

vendor/nikic/php-parser/lib/PhpParser/JsonDecoder.php, line 44

Class

JsonDecoder

Namespace

PhpParser

Code

private function decodeNode(array $value) : Node {
    $nodeType = $value['nodeType'];
    if (!\is_string($nodeType)) {
        throw new \RuntimeException('Node type must be a string');
    }
    $reflectionClass = $this->reflectionClassFromNodeType($nodeType);
    $node = $reflectionClass->newInstanceWithoutConstructor();
    if (isset($value['attributes'])) {
        if (!\is_array($value['attributes'])) {
            throw new \RuntimeException('Attributes must be an array');
        }
        $node->setAttributes($this->decodeArray($value['attributes']));
    }
    foreach ($value as $name => $subNode) {
        if ($name === 'nodeType' || $name === 'attributes') {
            continue;
        }
        $node->{$name} = $this->decodeRecursive($subNode);
    }
    return $node;
}

API Navigation

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