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

Breadcrumb

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

function GPBUtil::checkRepeatedField

105 calls to GPBUtil::checkRepeatedField()
Annotation::setPath in vendor/google/protobuf/src/Google/Protobuf/Internal/GeneratedCodeInfo/Annotation.php
Identifies the element in the original source .proto file. This field is formatted the same as SourceCodeInfo.Location.path.
Api::setMethods in vendor/google/protobuf/src/Google/Protobuf/Api.php
The methods of this interface, in unspecified order.
Api::setMixins in vendor/google/protobuf/src/Google/Protobuf/Api.php
Included interfaces. See [Mixin][].
Api::setOptions in vendor/google/protobuf/src/Google/Protobuf/Api.php
Any metadata attached to the interface.
ArrayValue::setValues in vendor/open-telemetry/gen-otlp-protobuf/Opentelemetry/Proto/Common/V1/ArrayValue.php
Array of values. The array may be empty (contain 0 elements).

... See full list

File

vendor/google/protobuf/src/Google/Protobuf/Internal/GPBUtil.php, line 179

Class

GPBUtil

Namespace

Google\Protobuf\Internal

Code

public static function checkRepeatedField(&$var, $type, $klass = null) {
    if (!$var instanceof RepeatedField && !is_array($var)) {
        throw new \Exception("Expect array.");
    }
    if (is_array($var)) {
        $tmp = new RepeatedField($type, $klass);
        foreach ($var as $value) {
            $tmp[] = $value;
        }
        return $tmp;
    }
    else {
        if ($var->getType() != $type) {
            throw new \Exception("Expect repeated field of different type.");
        }
        if ($var->getType() === GPBType::MESSAGE && $var->getClass() !== $klass && $var->getLegacyClass() !== $klass) {
            throw new \Exception("Expect repeated field of " . $klass . ".");
        }
        return $var;
    }
}

API Navigation

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