<?hh
/**
 * Autogenerated by Thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */

class A implements IThriftShapishStruct {
  public static array $_TSPEC = array(
    1 => array(
      'var' => 'a',
      'type' => TType::STRING,
      ),
    );
  public static Map<string, int> $_TFIELDMAP = Map {
    'a' => 1,
  };
  const type TShape = shape(
    'a' => string,
  );
  const int STRUCTURAL_ID = 7939807933046472325;
  public string $a;

  public function __construct(?string $a = null  ) {
    if ($a === null) {
      $this->a = '';
    } else {
      $this->a = $a;
    }
  }

  public function getName(): string {
    return 'A';
  }

  public static function __fromShape(self::TShape $shape): this {
    $me = /* HH_IGNORE_ERROR[4060] */ new static();
    $me->a = $shape['a'];
    return $me;
  }

  public function __toShape(): self::TShape {
    return shape(
      'a' => $this->a,
    );
  }
  public function read(TProtocol $input): int {
    $xfer = 0;
    $fname = '';
    $ftype = 0;
    $fid = 0;
    $xfer += $input->readStructBegin($fname);
    while (true)
    {
      $xfer += $input->readFieldBegin($fname, $ftype, $fid);
      if ($ftype == TType::STOP) {
        break;
      }
      if (!$fid && $fname !== null) {
        $fid = (int) self::$_TFIELDMAP->get($fname);
        if ($fid !== 0) {
          $ftype = self::$_TSPEC[$fid]['type'];
        }
      }
      switch ($fid)
      {
        case 1:
          if ($ftype == TType::STRING) {
            $xfer += $input->readString($this->a);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        default:
          $xfer += $input->skip($ftype);
          break;
      }
      $xfer += $input->readFieldEnd();
    }
    $xfer += $input->readStructEnd();
    return $xfer;
  }

  public function write(TProtocol $output): int {
    $xfer = 0;
    $xfer += $output->writeStructBegin('A');
    if ($this->a !== null) {
      $_val0 = $this->a;
      $xfer += $output->writeFieldBegin('a', TType::STRING, 1);
      $xfer += $output->writeString($_val0);
      $xfer += $output->writeFieldEnd();
    }
    $xfer += $output->writeFieldStop();
    $xfer += $output->writeStructEnd();
    return $xfer;
  }

}

class B implements IThriftShapishStruct {
  public static array $_TSPEC = array(
    1 => array(
      'var' => 'just_an_A',
      'type' => TType::STRUCT,
      'class' => 'A',
      ),
    2 => array(
      'var' => 'set_of_i32',
      'type' => TType::SET,
      'etype' => TType::I32,
      'elem' => array(
        'type' => TType::I32,
        ),
        'format' => 'collection',
      ),
    3 => array(
      'var' => 'list_of_i32',
      'type' => TType::LST,
      'etype' => TType::I32,
      'elem' => array(
        'type' => TType::I32,
        ),
        'format' => 'collection',
      ),
    4 => array(
      'var' => 'list_of_i32',
      'type' => TType::LST,
      'etype' => TType::STRING,
      'elem' => array(
        'type' => TType::STRING,
        ),
        'format' => 'collection',
      ),
    5 => array(
      'var' => 'map_of_string_to_i32',
      'type' => TType::MAP,
      'ktype' => TType::STRING,
      'vtype' => TType::I32,
      'key' => array(
        'type' => TType::STRING,
      ),
      'val' => array(
        'type' => TType::I32,
        ),
        'format' => 'collection',
      ),
    6 => array(
      'var' => 'map_of_string_to_A',
      'type' => TType::MAP,
      'ktype' => TType::STRING,
      'vtype' => TType::STRUCT,
      'key' => array(
        'type' => TType::STRING,
      ),
      'val' => array(
        'type' => TType::STRUCT,
        'class' => 'A',
        ),
        'format' => 'collection',
      ),
    7 => array(
      'var' => 'map_of_string_to_list_of_i32',
      'type' => TType::MAP,
      'ktype' => TType::STRING,
      'vtype' => TType::LST,
      'key' => array(
        'type' => TType::STRING,
      ),
      'val' => array(
        'type' => TType::LST,
        'etype' => TType::I32,
        'elem' => array(
          'type' => TType::I32,
          ),
          'format' => 'collection',
        ),
        'format' => 'collection',
      ),
    8 => array(
      'var' => 'map_of_string_to_list_of_A',
      'type' => TType::MAP,
      'ktype' => TType::STRING,
      'vtype' => TType::LST,
      'key' => array(
        'type' => TType::STRING,
      ),
      'val' => array(
        'type' => TType::LST,
        'etype' => TType::STRUCT,
        'elem' => array(
          'type' => TType::STRUCT,
          'class' => 'A',
          ),
          'format' => 'collection',
        ),
        'format' => 'collection',
      ),
    9 => array(
      'var' => 'map_of_string_to_set_of_i32',
      'type' => TType::MAP,
      'ktype' => TType::STRING,
      'vtype' => TType::SET,
      'key' => array(
        'type' => TType::STRING,
      ),
      'val' => array(
        'type' => TType::SET,
        'etype' => TType::I32,
        'elem' => array(
          'type' => TType::I32,
          ),
          'format' => 'collection',
        ),
        'format' => 'collection',
      ),
    10 => array(
      'var' => 'map_of_string_to_map_of_string_to_i32',
      'type' => TType::MAP,
      'ktype' => TType::STRING,
      'vtype' => TType::MAP,
      'key' => array(
        'type' => TType::STRING,
      ),
      'val' => array(
        'type' => TType::MAP,
        'ktype' => TType::STRING,
        'vtype' => TType::I32,
        'key' => array(
          'type' => TType::STRING,
        ),
        'val' => array(
          'type' => TType::I32,
          ),
          'format' => 'collection',
        ),
        'format' => 'collection',
      ),
    11 => array(
      'var' => 'map_of_string_to_map_of_string_to_A',
      'type' => TType::MAP,
      'ktype' => TType::STRING,
      'vtype' => TType::MAP,
      'key' => array(
        'type' => TType::STRING,
      ),
      'val' => array(
        'type' => TType::MAP,
        'ktype' => TType::STRING,
        'vtype' => TType::STRUCT,
        'key' => array(
          'type' => TType::STRING,
        ),
        'val' => array(
          'type' => TType::STRUCT,
          'class' => 'A',
          ),
          'format' => 'collection',
        ),
        'format' => 'collection',
      ),
    12 => array(
      'var' => 'list_of_set_of_i32',
      'type' => TType::LST,
      'etype' => TType::SET,
      'elem' => array(
        'type' => TType::SET,
        'etype' => TType::I32,
        'elem' => array(
          'type' => TType::I32,
          ),
          'format' => 'collection',
        ),
        'format' => 'collection',
      ),
    13 => array(
      'var' => 'list_of_map_of_string_to_list_of_A',
      'type' => TType::LST,
      'etype' => TType::MAP,
      'elem' => array(
        'type' => TType::MAP,
        'ktype' => TType::STRING,
        'vtype' => TType::LST,
        'key' => array(
          'type' => TType::STRING,
        ),
        'val' => array(
          'type' => TType::LST,
          'etype' => TType::STRUCT,
          'elem' => array(
            'type' => TType::STRUCT,
            'class' => 'A',
            ),
            'format' => 'collection',
          ),
          'format' => 'collection',
        ),
        'format' => 'collection',
      ),
    14 => array(
      'var' => 'list_of_map_of_string_to_A',
      'type' => TType::LST,
      'etype' => TType::MAP,
      'elem' => array(
        'type' => TType::MAP,
        'ktype' => TType::STRING,
        'vtype' => TType::STRUCT,
        'key' => array(
          'type' => TType::STRING,
        ),
        'val' => array(
          'type' => TType::STRUCT,
          'class' => 'A',
          ),
          'format' => 'collection',
        ),
        'format' => 'collection',
      ),
    15 => array(
      'var' => 'list_of_self',
      'type' => TType::LST,
      'etype' => TType::STRUCT,
      'elem' => array(
        'type' => TType::STRUCT,
        'class' => 'B',
        ),
        'format' => 'collection',
      ),
    16 => array(
      'var' => 'map_of_string_to_self',
      'type' => TType::MAP,
      'ktype' => TType::STRING,
      'vtype' => TType::STRUCT,
      'key' => array(
        'type' => TType::STRING,
      ),
      'val' => array(
        'type' => TType::STRUCT,
        'class' => 'B',
        ),
        'format' => 'collection',
      ),
    51 => array(
      'var' => 'optional_just_an_A',
      'type' => TType::STRUCT,
      'class' => 'A',
      ),
    52 => array(
      'var' => 'optional_set_of_i32',
      'type' => TType::SET,
      'etype' => TType::I32,
      'elem' => array(
        'type' => TType::I32,
        ),
        'format' => 'collection',
      ),
    53 => array(
      'var' => 'optional_list_of_i32',
      'type' => TType::LST,
      'etype' => TType::I32,
      'elem' => array(
        'type' => TType::I32,
        ),
        'format' => 'collection',
      ),
    54 => array(
      'var' => 'optional_list_of_i32',
      'type' => TType::LST,
      'etype' => TType::STRING,
      'elem' => array(
        'type' => TType::STRING,
        ),
        'format' => 'collection',
      ),
    55 => array(
      'var' => 'optional_map_of_string_to_i32',
      'type' => TType::MAP,
      'ktype' => TType::STRING,
      'vtype' => TType::I32,
      'key' => array(
        'type' => TType::STRING,
      ),
      'val' => array(
        'type' => TType::I32,
        ),
        'format' => 'collection',
      ),
    56 => array(
      'var' => 'optional_map_of_string_to_A',
      'type' => TType::MAP,
      'ktype' => TType::STRING,
      'vtype' => TType::STRUCT,
      'key' => array(
        'type' => TType::STRING,
      ),
      'val' => array(
        'type' => TType::STRUCT,
        'class' => 'A',
        ),
        'format' => 'collection',
      ),
    57 => array(
      'var' => 'optional_map_of_string_to_list_of_i32',
      'type' => TType::MAP,
      'ktype' => TType::STRING,
      'vtype' => TType::LST,
      'key' => array(
        'type' => TType::STRING,
      ),
      'val' => array(
        'type' => TType::LST,
        'etype' => TType::I32,
        'elem' => array(
          'type' => TType::I32,
          ),
          'format' => 'collection',
        ),
        'format' => 'collection',
      ),
    58 => array(
      'var' => 'optional_map_of_string_to_list_of_A',
      'type' => TType::MAP,
      'ktype' => TType::STRING,
      'vtype' => TType::LST,
      'key' => array(
        'type' => TType::STRING,
      ),
      'val' => array(
        'type' => TType::LST,
        'etype' => TType::STRUCT,
        'elem' => array(
          'type' => TType::STRUCT,
          'class' => 'A',
          ),
          'format' => 'collection',
        ),
        'format' => 'collection',
      ),
    59 => array(
      'var' => 'optional_map_of_string_to_set_of_i32',
      'type' => TType::MAP,
      'ktype' => TType::STRING,
      'vtype' => TType::SET,
      'key' => array(
        'type' => TType::STRING,
      ),
      'val' => array(
        'type' => TType::SET,
        'etype' => TType::I32,
        'elem' => array(
          'type' => TType::I32,
          ),
          'format' => 'collection',
        ),
        'format' => 'collection',
      ),
    );
  public static Map<string, int> $_TFIELDMAP = Map {
    'just_an_A' => 1,
    'set_of_i32' => 2,
    'list_of_i32' => 3,
    'list_of_i32' => 4,
    'map_of_string_to_i32' => 5,
    'map_of_string_to_A' => 6,
    'map_of_string_to_list_of_i32' => 7,
    'map_of_string_to_list_of_A' => 8,
    'map_of_string_to_set_of_i32' => 9,
    'map_of_string_to_map_of_string_to_i32' => 10,
    'map_of_string_to_map_of_string_to_A' => 11,
    'list_of_set_of_i32' => 12,
    'list_of_map_of_string_to_list_of_A' => 13,
    'list_of_map_of_string_to_A' => 14,
    'list_of_self' => 15,
    'map_of_string_to_self' => 16,
    'optional_just_an_A' => 51,
    'optional_set_of_i32' => 52,
    'optional_list_of_i32' => 53,
    'optional_list_of_i32' => 54,
    'optional_map_of_string_to_i32' => 55,
    'optional_map_of_string_to_A' => 56,
    'optional_map_of_string_to_list_of_i32' => 57,
    'optional_map_of_string_to_list_of_A' => 58,
    'optional_map_of_string_to_set_of_i32' => 59,
  };
  const type TShape = shape(
    'just_an_A' => ?A::TShape,
    'set_of_i32' => array<int, bool>,
    'list_of_i32' => array<int>,
    'list_of_i32' => array<string>,
    'map_of_string_to_i32' => array<arraykey, int>,
    'map_of_string_to_A' => array<arraykey, A::TShape>,
    'map_of_string_to_list_of_i32' => array<arraykey, array<int>>,
    'map_of_string_to_list_of_A' => array<arraykey, array<A::TShape>>,
    'map_of_string_to_set_of_i32' => array<arraykey, array<int, bool>>,
    'map_of_string_to_map_of_string_to_i32' => array<arraykey, array<arraykey, int>>,
    'map_of_string_to_map_of_string_to_A' => array<arraykey, array<arraykey, A::TShape>>,
    'list_of_set_of_i32' => array<array<int, bool>>,
    'list_of_map_of_string_to_list_of_A' => array<array<arraykey, array<A::TShape>>>,
    'list_of_map_of_string_to_A' => array<array<arraykey, A::TShape>>,
    'list_of_self' => array<B::TShape>,
    'map_of_string_to_self' => array<arraykey, B::TShape>,
    'optional_just_an_A' => ?A::TShape,
    'optional_set_of_i32' => ?array<int, bool>,
    'optional_list_of_i32' => ?array<int>,
    'optional_list_of_i32' => ?array<string>,
    'optional_map_of_string_to_i32' => ?array<arraykey, int>,
    'optional_map_of_string_to_A' => ?array<arraykey, A::TShape>,
    'optional_map_of_string_to_list_of_i32' => ?array<arraykey, array<int>>,
    'optional_map_of_string_to_list_of_A' => ?array<arraykey, array<A::TShape>>,
    'optional_map_of_string_to_set_of_i32' => ?array<arraykey, array<int, bool>>,
  );
  const int STRUCTURAL_ID = 3764140012764052683;
  public ?A $just_an_A;
  public Set<int> $set_of_i32;
  public Vector<int> $list_of_i32;
  public Vector<string> $list_of_i32;
  public Map<string, int> $map_of_string_to_i32;
  public Map<string, A> $map_of_string_to_A;
  public Map<string, Vector<int>> $map_of_string_to_list_of_i32;
  public Map<string, Vector<A>> $map_of_string_to_list_of_A;
  public Map<string, Set<int>> $map_of_string_to_set_of_i32;
  public Map<string, Map<string, int>> $map_of_string_to_map_of_string_to_i32;
  public Map<string, Map<string, A>> $map_of_string_to_map_of_string_to_A;
  public Vector<Set<int>> $list_of_set_of_i32;
  public Vector<Map<string, Vector<A>>> $list_of_map_of_string_to_list_of_A;
  public Vector<Map<string, A>> $list_of_map_of_string_to_A;
  public Vector<B> $list_of_self;
  public Map<string, B> $map_of_string_to_self;
  public ?A $optional_just_an_A;
  public ?Set<int> $optional_set_of_i32;
  public ?Vector<int> $optional_list_of_i32;
  public ?Vector<string> $optional_list_of_i32;
  public ?Map<string, int> $optional_map_of_string_to_i32;
  public ?Map<string, A> $optional_map_of_string_to_A;
  public ?Map<string, Vector<int>> $optional_map_of_string_to_list_of_i32;
  public ?Map<string, Vector<A>> $optional_map_of_string_to_list_of_A;
  public ?Map<string, Set<int>> $optional_map_of_string_to_set_of_i32;

  public function __construct(?A $just_an_A = null, ?Set<int> $set_of_i32 = null, ?Vector<int> $list_of_i32 = null, ?Vector<string> $list_of_i32 = null, ?Map<string, int> $map_of_string_to_i32 = null, ?Map<string, A> $map_of_string_to_A = null, ?Map<string, Vector<int>> $map_of_string_to_list_of_i32 = null, ?Map<string, Vector<A>> $map_of_string_to_list_of_A = null, ?Map<string, Set<int>> $map_of_string_to_set_of_i32 = null, ?Map<string, Map<string, int>> $map_of_string_to_map_of_string_to_i32 = null, ?Map<string, Map<string, A>> $map_of_string_to_map_of_string_to_A = null, ?Vector<Set<int>> $list_of_set_of_i32 = null, ?Vector<Map<string, Vector<A>>> $list_of_map_of_string_to_list_of_A = null, ?Vector<Map<string, A>> $list_of_map_of_string_to_A = null, ?Vector<B> $list_of_self = null, ?Map<string, B> $map_of_string_to_self = null, ?A $optional_just_an_A = null, ?Set<int> $optional_set_of_i32 = null, ?Vector<int> $optional_list_of_i32 = null, ?Vector<string> $optional_list_of_i32 = null, ?Map<string, int> $optional_map_of_string_to_i32 = null, ?Map<string, A> $optional_map_of_string_to_A = null, ?Map<string, Vector<int>> $optional_map_of_string_to_list_of_i32 = null, ?Map<string, Vector<A>> $optional_map_of_string_to_list_of_A = null, ?Map<string, Set<int>> $optional_map_of_string_to_set_of_i32 = null  ) {
    $this->just_an_A = $just_an_A;
    if ($set_of_i32 === null) {
      $this->set_of_i32 = Set {};
    } else {
      $this->set_of_i32 = $set_of_i32;
    }
    if ($list_of_i32 === null) {
      $this->list_of_i32 = Vector {};
    } else {
      $this->list_of_i32 = $list_of_i32;
    }
    if ($list_of_i32 === null) {
      $this->list_of_i32 = Vector {};
    } else {
      $this->list_of_i32 = $list_of_i32;
    }
    if ($map_of_string_to_i32 === null) {
      $this->map_of_string_to_i32 = Map {};
    } else {
      $this->map_of_string_to_i32 = $map_of_string_to_i32;
    }
    if ($map_of_string_to_A === null) {
      $this->map_of_string_to_A = Map {};
    } else {
      $this->map_of_string_to_A = $map_of_string_to_A;
    }
    if ($map_of_string_to_list_of_i32 === null) {
      $this->map_of_string_to_list_of_i32 = Map {};
    } else {
      $this->map_of_string_to_list_of_i32 = $map_of_string_to_list_of_i32;
    }
    if ($map_of_string_to_list_of_A === null) {
      $this->map_of_string_to_list_of_A = Map {};
    } else {
      $this->map_of_string_to_list_of_A = $map_of_string_to_list_of_A;
    }
    if ($map_of_string_to_set_of_i32 === null) {
      $this->map_of_string_to_set_of_i32 = Map {};
    } else {
      $this->map_of_string_to_set_of_i32 = $map_of_string_to_set_of_i32;
    }
    if ($map_of_string_to_map_of_string_to_i32 === null) {
      $this->map_of_string_to_map_of_string_to_i32 = Map {};
    } else {
      $this->map_of_string_to_map_of_string_to_i32 = $map_of_string_to_map_of_string_to_i32;
    }
    if ($map_of_string_to_map_of_string_to_A === null) {
      $this->map_of_string_to_map_of_string_to_A = Map {};
    } else {
      $this->map_of_string_to_map_of_string_to_A = $map_of_string_to_map_of_string_to_A;
    }
    if ($list_of_set_of_i32 === null) {
      $this->list_of_set_of_i32 = Vector {};
    } else {
      $this->list_of_set_of_i32 = $list_of_set_of_i32;
    }
    if ($list_of_map_of_string_to_list_of_A === null) {
      $this->list_of_map_of_string_to_list_of_A = Vector {};
    } else {
      $this->list_of_map_of_string_to_list_of_A = $list_of_map_of_string_to_list_of_A;
    }
    if ($list_of_map_of_string_to_A === null) {
      $this->list_of_map_of_string_to_A = Vector {};
    } else {
      $this->list_of_map_of_string_to_A = $list_of_map_of_string_to_A;
    }
    if ($list_of_self === null) {
      $this->list_of_self = Vector {};
    } else {
      $this->list_of_self = $list_of_self;
    }
    if ($map_of_string_to_self === null) {
      $this->map_of_string_to_self = Map {};
    } else {
      $this->map_of_string_to_self = $map_of_string_to_self;
    }
    $this->optional_just_an_A = $optional_just_an_A;
    $this->optional_set_of_i32 = $optional_set_of_i32;
    $this->optional_list_of_i32 = $optional_list_of_i32;
    $this->optional_list_of_i32 = $optional_list_of_i32;
    $this->optional_map_of_string_to_i32 = $optional_map_of_string_to_i32;
    $this->optional_map_of_string_to_A = $optional_map_of_string_to_A;
    $this->optional_map_of_string_to_list_of_i32 = $optional_map_of_string_to_list_of_i32;
    $this->optional_map_of_string_to_list_of_A = $optional_map_of_string_to_list_of_A;
    $this->optional_map_of_string_to_set_of_i32 = $optional_map_of_string_to_set_of_i32;
  }

  public function getName(): string {
    return 'B';
  }

  public static function __fromShape(self::TShape $shape): this {
    $me = /* HH_IGNORE_ERROR[4060] */ new static();
    $me->just_an_A = $shape['just_an_A'] === null ? null : A::__fromShape(nullthrows($shape['just_an_A']));
    $me->set_of_i32 = new Set(array_keys($shape['set_of_i32']));
    $me->list_of_i32 = (new Vector($shape['list_of_i32']));
    $me->list_of_i32 = (new Vector($shape['list_of_i32']));
    $me->map_of_string_to_i32 = (new Map($shape['map_of_string_to_i32']));
    $me->map_of_string_to_A = (new Map($shape['map_of_string_to_A']))->map(
      $val0 ==> A::__fromShape($val0),
    );
    $me->map_of_string_to_list_of_i32 = (new Map($shape['map_of_string_to_list_of_i32']))->map(
      $val1 ==> (new Vector($val1)),
    );
    $me->map_of_string_to_list_of_A = (new Map($shape['map_of_string_to_list_of_A']))->map(
      $val2 ==> (new Vector($val2))->map(
        $val3 ==> A::__fromShape($val3),
      ),
    );
    $me->map_of_string_to_set_of_i32 = (new Map($shape['map_of_string_to_set_of_i32']))->map(
      $val4 ==> new Set(array_keys($val4)),
    );
    $me->map_of_string_to_map_of_string_to_i32 = (new Map($shape['map_of_string_to_map_of_string_to_i32']))->map(
      $val5 ==> (new Map($val5)),
    );
    $me->map_of_string_to_map_of_string_to_A = (new Map($shape['map_of_string_to_map_of_string_to_A']))->map(
      $val6 ==> (new Map($val6))->map(
        $val7 ==> A::__fromShape($val7),
      ),
    );
    $me->list_of_set_of_i32 = (new Vector($shape['list_of_set_of_i32']))->map(
      $val8 ==> new Set(array_keys($val8)),
    );
    $me->list_of_map_of_string_to_list_of_A = (new Vector($shape['list_of_map_of_string_to_list_of_A']))->map(
      $val9 ==> (new Map($val9))->map(
        $val10 ==> (new Vector($val10))->map(
          $val11 ==> A::__fromShape($val11),
        ),
      ),
    );
    $me->list_of_map_of_string_to_A = (new Vector($shape['list_of_map_of_string_to_A']))->map(
      $val12 ==> (new Map($val12))->map(
        $val13 ==> A::__fromShape($val13),
      ),
    );
    $me->list_of_self = (new Vector($shape['list_of_self']))->map(
      $val14 ==> B::__fromShape($val14),
    );
    $me->map_of_string_to_self = (new Map($shape['map_of_string_to_self']))->map(
      $val15 ==> B::__fromShape($val15),
    );
    $me->optional_just_an_A = $shape['optional_just_an_A'] === null ? null : A::__fromShape(nullthrows($shape['optional_just_an_A']));
    $me->optional_set_of_i32 = $shape['optional_set_of_i32'] === null ? null : new Set(array_keys(nullthrows($shape['optional_set_of_i32'])));
    $me->optional_list_of_i32 = $shape['optional_list_of_i32'] === null ? null : 
      (new Vector($shape['optional_list_of_i32']));
    $me->optional_list_of_i32 = $shape['optional_list_of_i32'] === null ? null : 
      (new Vector($shape['optional_list_of_i32']));
    $me->optional_map_of_string_to_i32 = $shape['optional_map_of_string_to_i32'] === null ? null : 
      (new Map($shape['optional_map_of_string_to_i32']));
    $me->optional_map_of_string_to_A = $shape['optional_map_of_string_to_A'] === null ? null : 
      (new Map($shape['optional_map_of_string_to_A']))->map(
        $val16 ==> A::__fromShape($val16),
      );
    $me->optional_map_of_string_to_list_of_i32 = $shape['optional_map_of_string_to_list_of_i32'] === null ? null : 
      (new Map($shape['optional_map_of_string_to_list_of_i32']))->map(
        $val17 ==> (new Vector($val17)),
      );
    $me->optional_map_of_string_to_list_of_A = $shape['optional_map_of_string_to_list_of_A'] === null ? null : 
      (new Map($shape['optional_map_of_string_to_list_of_A']))->map(
        $val18 ==> (new Vector($val18))->map(
          $val19 ==> A::__fromShape($val19),
        ),
      );
    $me->optional_map_of_string_to_set_of_i32 = $shape['optional_map_of_string_to_set_of_i32'] === null ? null : 
      (new Map($shape['optional_map_of_string_to_set_of_i32']))->map(
        $val20 ==> new Set(array_keys($val20)),
      );
    return $me;
  }

  public function __toShape(): self::TShape {
    return shape(
      'just_an_A' => $this->just_an_A?->__toShape(),
      'set_of_i32' => array_fill_keys($this->set_of_i32->toValuesArray(), true),
      'list_of_i32' => $this->list_of_i32->toArray(),
      'list_of_i32' => $this->list_of_i32->toArray(),
      'map_of_string_to_i32' => $this->map_of_string_to_i32->toArray(),
      'map_of_string_to_A' => $this->map_of_string_to_A->map(
        $_val0 ==> $_val0->__toShape(),
      )->toArray(),
      'map_of_string_to_list_of_i32' => $this->map_of_string_to_list_of_i32->map(
        $_val0 ==> $_val0->toArray(),
      )->toArray(),
      'map_of_string_to_list_of_A' => $this->map_of_string_to_list_of_A->map(
        $_val0 ==> $_val0->map(
          $_val1 ==> $_val1->__toShape(),
        )->toArray(),
      )->toArray(),
      'map_of_string_to_set_of_i32' => $this->map_of_string_to_set_of_i32->map(
        $_val0 ==> array_fill_keys($_val0, true),
      )->toArray(),
      'map_of_string_to_map_of_string_to_i32' => $this->map_of_string_to_map_of_string_to_i32->map(
        $_val0 ==> $_val0->toArray(),
      )->toArray(),
      'map_of_string_to_map_of_string_to_A' => $this->map_of_string_to_map_of_string_to_A->map(
        $_val0 ==> $_val0->map(
          $_val1 ==> $_val1->__toShape(),
        )->toArray(),
      )->toArray(),
      'list_of_set_of_i32' => $this->list_of_set_of_i32->map(
        $_val0 ==> array_fill_keys($_val0, true),
      )->toArray(),
      'list_of_map_of_string_to_list_of_A' => $this->list_of_map_of_string_to_list_of_A->map(
        $_val0 ==> $_val0->map(
          $_val1 ==> $_val1->map(
            $_val2 ==> $_val2->__toShape(),
          )->toArray(),
        )->toArray(),
      )->toArray(),
      'list_of_map_of_string_to_A' => $this->list_of_map_of_string_to_A->map(
        $_val0 ==> $_val0->map(
          $_val1 ==> $_val1->__toShape(),
        )->toArray(),
      )->toArray(),
      'list_of_self' => $this->list_of_self->map(
        $_val0 ==> $_val0->__toShape(),
      )->toArray(),
      'map_of_string_to_self' => $this->map_of_string_to_self->map(
        $_val0 ==> $_val0->__toShape(),
      )->toArray(),
      'optional_just_an_A' => $this->optional_just_an_A?->__toShape(),
      'optional_set_of_i32' => $this->optional_set_of_i32 === null ? null : array_fill_keys(nullthrows($this->optional_set_of_i32->toValuesArray()), true),
      'optional_list_of_i32' => $this->optional_list_of_i32?->toArray(),
      'optional_list_of_i32' => $this->optional_list_of_i32?->toArray(),
      'optional_map_of_string_to_i32' => $this->optional_map_of_string_to_i32?->toArray(),
      'optional_map_of_string_to_A' => $this->optional_map_of_string_to_A?->map(
        $_val0 ==> $_val0->__toShape(),
      )?->toArray(),
      'optional_map_of_string_to_list_of_i32' => $this->optional_map_of_string_to_list_of_i32?->map(
        $_val0 ==> $_val0->toArray(),
      )?->toArray(),
      'optional_map_of_string_to_list_of_A' => $this->optional_map_of_string_to_list_of_A?->map(
        $_val0 ==> $_val0->map(
          $_val1 ==> $_val1->__toShape(),
        )->toArray(),
      )?->toArray(),
      'optional_map_of_string_to_set_of_i32' => $this->optional_map_of_string_to_set_of_i32?->map(
        $_val0 ==> array_fill_keys($_val0, true),
      )?->toArray(),
    );
  }
  public function read(TProtocol $input): int {
    $xfer = 0;
    $fname = '';
    $ftype = 0;
    $fid = 0;
    $xfer += $input->readStructBegin($fname);
    while (true)
    {
      $xfer += $input->readFieldBegin($fname, $ftype, $fid);
      if ($ftype == TType::STOP) {
        break;
      }
      if (!$fid && $fname !== null) {
        $fid = (int) self::$_TFIELDMAP->get($fname);
        if ($fid !== 0) {
          $ftype = self::$_TSPEC[$fid]['type'];
        }
      }
      switch ($fid)
      {
        case 1:
          if ($ftype == TType::STRUCT) {
            $this->just_an_A = new A();
            $xfer += $this->just_an_A->read($input);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 2:
          if ($ftype == TType::SET) {
            $_size1 = 0;
            $_etype4 = 0;
            $_val0 = Set{};
            $xfer += $input->readSetBegin($_etype4, $_size1);
            for ($_i5 = 0; $_size1 === null || $_i5 < $_size1; ++$_i5)
            {
              if ($_size1 === null && !$input->readSetHasNext()) {
                break;
              }
              $elem6 = null;
              $xfer += $input->readI32($elem6);
              if ($elem6 !== null) {
                $_val0->add($elem6);
              }
            }
            $xfer += $input->readSetEnd();
            $this->set_of_i32 = $_val0;
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 3:
          if ($ftype == TType::LST) {
            $_size8 = 0;
            $_val7 = Vector {};
            $_etype11 = 0;
            $xfer += $input->readListBegin($_etype11, $_size8);
            for ($_i12 = 0; $_size8 === null || $_i12 < $_size8; ++$_i12)
            {
              if ($_size8 === null && !$input->readListHasNext()) {
                break;
              }
              $elem13 = null;
              $xfer += $input->readI32($elem13);
              if ($elem13 !== null) {
                $_val7 []= $elem13;
              }
            }
            $xfer += $input->readListEnd();
            $this->list_of_i32 = $_val7;
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 4:
          if ($ftype == TType::LST) {
            $_size15 = 0;
            $_val14 = Vector {};
            $_etype18 = 0;
            $xfer += $input->readListBegin($_etype18, $_size15);
            for ($_i19 = 0; $_size15 === null || $_i19 < $_size15; ++$_i19)
            {
              if ($_size15 === null && !$input->readListHasNext()) {
                break;
              }
              $elem20 = null;
              $xfer += $input->readString($elem20);
              if ($elem20 !== null) {
                $_val14 []= $elem20;
              }
            }
            $xfer += $input->readListEnd();
            $this->list_of_i32 = $_val14;
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 5:
          if ($ftype == TType::MAP) {
            $_size22 = 0;
            $_val21 = Map {};
            $_ktype23 = 0;
            $_vtype24 = 0;
            $xfer += $input->readMapBegin($_ktype23, $_vtype24, $_size22);
            for ($_i26 = 0; $_size22 === null || $_i26 < $_size22; ++$_i26)
            {
              if ($_size22 === null && !$input->readMapHasNext()) {
                break;
              }
              $key27 = '';
              $val28 = 0;
              $xfer += $input->readString($key27);
              $xfer += $input->readI32($val28);
              if ($key27 !== null && $val28 !== null) {
                $_val21[$key27] = $val28;
              }
            }
            $xfer += $input->readMapEnd();
            $this->map_of_string_to_i32 = $_val21;
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 6:
          if ($ftype == TType::MAP) {
            $_size30 = 0;
            $_val29 = Map {};
            $_ktype31 = 0;
            $_vtype32 = 0;
            $xfer += $input->readMapBegin($_ktype31, $_vtype32, $_size30);
            for ($_i34 = 0; $_size30 === null || $_i34 < $_size30; ++$_i34)
            {
              if ($_size30 === null && !$input->readMapHasNext()) {
                break;
              }
              $key35 = '';
              $val36 = new A();
              $xfer += $input->readString($key35);
              $val36 = new A();
              $xfer += $val36->read($input);
              if ($key35 !== null && $val36 !== null) {
                $_val29[$key35] = $val36;
              }
            }
            $xfer += $input->readMapEnd();
            $this->map_of_string_to_A = $_val29;
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 7:
          if ($ftype == TType::MAP) {
            $_size38 = 0;
            $_val37 = Map {};
            $_ktype39 = 0;
            $_vtype40 = 0;
            $xfer += $input->readMapBegin($_ktype39, $_vtype40, $_size38);
            for ($_i42 = 0; $_size38 === null || $_i42 < $_size38; ++$_i42)
            {
              if ($_size38 === null && !$input->readMapHasNext()) {
                break;
              }
              $key43 = '';
              $val44 = Vector {};
              $xfer += $input->readString($key43);
              $_size46 = 0;
              $_val45 = Vector {};
              $_etype49 = 0;
              $xfer += $input->readListBegin($_etype49, $_size46);
              for ($_i50 = 0; $_size46 === null || $_i50 < $_size46; ++$_i50)
              {
                if ($_size46 === null && !$input->readListHasNext()) {
                  break;
                }
                $elem51 = null;
                $xfer += $input->readI32($elem51);
                if ($elem51 !== null) {
                  $_val45 []= $elem51;
                }
              }
              $xfer += $input->readListEnd();
              $val44 = $_val45;
              if ($key43 !== null && $val44 !== null) {
                $_val37[$key43] = $val44;
              }
            }
            $xfer += $input->readMapEnd();
            $this->map_of_string_to_list_of_i32 = $_val37;
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 8:
          if ($ftype == TType::MAP) {
            $_size53 = 0;
            $_val52 = Map {};
            $_ktype54 = 0;
            $_vtype55 = 0;
            $xfer += $input->readMapBegin($_ktype54, $_vtype55, $_size53);
            for ($_i57 = 0; $_size53 === null || $_i57 < $_size53; ++$_i57)
            {
              if ($_size53 === null && !$input->readMapHasNext()) {
                break;
              }
              $key58 = '';
              $val59 = Vector {};
              $xfer += $input->readString($key58);
              $_size61 = 0;
              $_val60 = Vector {};
              $_etype64 = 0;
              $xfer += $input->readListBegin($_etype64, $_size61);
              for ($_i65 = 0; $_size61 === null || $_i65 < $_size61; ++$_i65)
              {
                if ($_size61 === null && !$input->readListHasNext()) {
                  break;
                }
                $elem66 = null;
                $elem66 = new A();
                $xfer += $elem66->read($input);
                if ($elem66 !== null) {
                  $_val60 []= $elem66;
                }
              }
              $xfer += $input->readListEnd();
              $val59 = $_val60;
              if ($key58 !== null && $val59 !== null) {
                $_val52[$key58] = $val59;
              }
            }
            $xfer += $input->readMapEnd();
            $this->map_of_string_to_list_of_A = $_val52;
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 9:
          if ($ftype == TType::MAP) {
            $_size68 = 0;
            $_val67 = Map {};
            $_ktype69 = 0;
            $_vtype70 = 0;
            $xfer += $input->readMapBegin($_ktype69, $_vtype70, $_size68);
            for ($_i72 = 0; $_size68 === null || $_i72 < $_size68; ++$_i72)
            {
              if ($_size68 === null && !$input->readMapHasNext()) {
                break;
              }
              $key73 = '';
              $val74 = Set {};
              $xfer += $input->readString($key73);
              $_size76 = 0;
              $_etype79 = 0;
              $_val75 = Set{};
              $xfer += $input->readSetBegin($_etype79, $_size76);
              for ($_i80 = 0; $_size76 === null || $_i80 < $_size76; ++$_i80)
              {
                if ($_size76 === null && !$input->readSetHasNext()) {
                  break;
                }
                $elem81 = null;
                $xfer += $input->readI32($elem81);
                if ($elem81 !== null) {
                  $_val75->add($elem81);
                }
              }
              $xfer += $input->readSetEnd();
              $val74 = $_val75;
              if ($key73 !== null && $val74 !== null) {
                $_val67[$key73] = $val74;
              }
            }
            $xfer += $input->readMapEnd();
            $this->map_of_string_to_set_of_i32 = $_val67;
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 10:
          if ($ftype == TType::MAP) {
            $_size83 = 0;
            $_val82 = Map {};
            $_ktype84 = 0;
            $_vtype85 = 0;
            $xfer += $input->readMapBegin($_ktype84, $_vtype85, $_size83);
            for ($_i87 = 0; $_size83 === null || $_i87 < $_size83; ++$_i87)
            {
              if ($_size83 === null && !$input->readMapHasNext()) {
                break;
              }
              $key88 = '';
              $val89 = Map {};
              $xfer += $input->readString($key88);
              $_size91 = 0;
              $_val90 = Map {};
              $_ktype92 = 0;
              $_vtype93 = 0;
              $xfer += $input->readMapBegin($_ktype92, $_vtype93, $_size91);
              for ($_i95 = 0; $_size91 === null || $_i95 < $_size91; ++$_i95)
              {
                if ($_size91 === null && !$input->readMapHasNext()) {
                  break;
                }
                $key96 = '';
                $val97 = 0;
                $xfer += $input->readString($key96);
                $xfer += $input->readI32($val97);
                if ($key96 !== null && $val97 !== null) {
                  $_val90[$key96] = $val97;
                }
              }
              $xfer += $input->readMapEnd();
              $val89 = $_val90;
              if ($key88 !== null && $val89 !== null) {
                $_val82[$key88] = $val89;
              }
            }
            $xfer += $input->readMapEnd();
            $this->map_of_string_to_map_of_string_to_i32 = $_val82;
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 11:
          if ($ftype == TType::MAP) {
            $_size99 = 0;
            $_val98 = Map {};
            $_ktype100 = 0;
            $_vtype101 = 0;
            $xfer += $input->readMapBegin($_ktype100, $_vtype101, $_size99);
            for ($_i103 = 0; $_size99 === null || $_i103 < $_size99; ++$_i103)
            {
              if ($_size99 === null && !$input->readMapHasNext()) {
                break;
              }
              $key104 = '';
              $val105 = Map {};
              $xfer += $input->readString($key104);
              $_size107 = 0;
              $_val106 = Map {};
              $_ktype108 = 0;
              $_vtype109 = 0;
              $xfer += $input->readMapBegin($_ktype108, $_vtype109, $_size107);
              for ($_i111 = 0; $_size107 === null || $_i111 < $_size107; ++$_i111)
              {
                if ($_size107 === null && !$input->readMapHasNext()) {
                  break;
                }
                $key112 = '';
                $val113 = new A();
                $xfer += $input->readString($key112);
                $val113 = new A();
                $xfer += $val113->read($input);
                if ($key112 !== null && $val113 !== null) {
                  $_val106[$key112] = $val113;
                }
              }
              $xfer += $input->readMapEnd();
              $val105 = $_val106;
              if ($key104 !== null && $val105 !== null) {
                $_val98[$key104] = $val105;
              }
            }
            $xfer += $input->readMapEnd();
            $this->map_of_string_to_map_of_string_to_A = $_val98;
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 12:
          if ($ftype == TType::LST) {
            $_size115 = 0;
            $_val114 = Vector {};
            $_etype118 = 0;
            $xfer += $input->readListBegin($_etype118, $_size115);
            for ($_i119 = 0; $_size115 === null || $_i119 < $_size115; ++$_i119)
            {
              if ($_size115 === null && !$input->readListHasNext()) {
                break;
              }
              $elem120 = null;
              $_size122 = 0;
              $_etype125 = 0;
              $_val121 = Set{};
              $xfer += $input->readSetBegin($_etype125, $_size122);
              for ($_i126 = 0; $_size122 === null || $_i126 < $_size122; ++$_i126)
              {
                if ($_size122 === null && !$input->readSetHasNext()) {
                  break;
                }
                $elem127 = null;
                $xfer += $input->readI32($elem127);
                if ($elem127 !== null) {
                  $_val121->add($elem127);
                }
              }
              $xfer += $input->readSetEnd();
              $elem120 = $_val121;
              if ($elem120 !== null) {
                $_val114 []= $elem120;
              }
            }
            $xfer += $input->readListEnd();
            $this->list_of_set_of_i32 = $_val114;
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 13:
          if ($ftype == TType::LST) {
            $_size129 = 0;
            $_val128 = Vector {};
            $_etype132 = 0;
            $xfer += $input->readListBegin($_etype132, $_size129);
            for ($_i133 = 0; $_size129 === null || $_i133 < $_size129; ++$_i133)
            {
              if ($_size129 === null && !$input->readListHasNext()) {
                break;
              }
              $elem134 = null;
              $_size136 = 0;
              $_val135 = Map {};
              $_ktype137 = 0;
              $_vtype138 = 0;
              $xfer += $input->readMapBegin($_ktype137, $_vtype138, $_size136);
              for ($_i140 = 0; $_size136 === null || $_i140 < $_size136; ++$_i140)
              {
                if ($_size136 === null && !$input->readMapHasNext()) {
                  break;
                }
                $key141 = '';
                $val142 = Vector {};
                $xfer += $input->readString($key141);
                $_size144 = 0;
                $_val143 = Vector {};
                $_etype147 = 0;
                $xfer += $input->readListBegin($_etype147, $_size144);
                for ($_i148 = 0; $_size144 === null || $_i148 < $_size144; ++$_i148)
                {
                  if ($_size144 === null && !$input->readListHasNext()) {
                    break;
                  }
                  $elem149 = null;
                  $elem149 = new A();
                  $xfer += $elem149->read($input);
                  if ($elem149 !== null) {
                    $_val143 []= $elem149;
                  }
                }
                $xfer += $input->readListEnd();
                $val142 = $_val143;
                if ($key141 !== null && $val142 !== null) {
                  $_val135[$key141] = $val142;
                }
              }
              $xfer += $input->readMapEnd();
              $elem134 = $_val135;
              if ($elem134 !== null) {
                $_val128 []= $elem134;
              }
            }
            $xfer += $input->readListEnd();
            $this->list_of_map_of_string_to_list_of_A = $_val128;
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 14:
          if ($ftype == TType::LST) {
            $_size151 = 0;
            $_val150 = Vector {};
            $_etype154 = 0;
            $xfer += $input->readListBegin($_etype154, $_size151);
            for ($_i155 = 0; $_size151 === null || $_i155 < $_size151; ++$_i155)
            {
              if ($_size151 === null && !$input->readListHasNext()) {
                break;
              }
              $elem156 = null;
              $_size158 = 0;
              $_val157 = Map {};
              $_ktype159 = 0;
              $_vtype160 = 0;
              $xfer += $input->readMapBegin($_ktype159, $_vtype160, $_size158);
              for ($_i162 = 0; $_size158 === null || $_i162 < $_size158; ++$_i162)
              {
                if ($_size158 === null && !$input->readMapHasNext()) {
                  break;
                }
                $key163 = '';
                $val164 = new A();
                $xfer += $input->readString($key163);
                $val164 = new A();
                $xfer += $val164->read($input);
                if ($key163 !== null && $val164 !== null) {
                  $_val157[$key163] = $val164;
                }
              }
              $xfer += $input->readMapEnd();
              $elem156 = $_val157;
              if ($elem156 !== null) {
                $_val150 []= $elem156;
              }
            }
            $xfer += $input->readListEnd();
            $this->list_of_map_of_string_to_A = $_val150;
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 15:
          if ($ftype == TType::LST) {
            $_size166 = 0;
            $_val165 = Vector {};
            $_etype169 = 0;
            $xfer += $input->readListBegin($_etype169, $_size166);
            for ($_i170 = 0; $_size166 === null || $_i170 < $_size166; ++$_i170)
            {
              if ($_size166 === null && !$input->readListHasNext()) {
                break;
              }
              $elem171 = null;
              $elem171 = new B();
              $xfer += $elem171->read($input);
              if ($elem171 !== null) {
                $_val165 []= $elem171;
              }
            }
            $xfer += $input->readListEnd();
            $this->list_of_self = $_val165;
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 16:
          if ($ftype == TType::MAP) {
            $_size173 = 0;
            $_val172 = Map {};
            $_ktype174 = 0;
            $_vtype175 = 0;
            $xfer += $input->readMapBegin($_ktype174, $_vtype175, $_size173);
            for ($_i177 = 0; $_size173 === null || $_i177 < $_size173; ++$_i177)
            {
              if ($_size173 === null && !$input->readMapHasNext()) {
                break;
              }
              $key178 = '';
              $val179 = new B();
              $xfer += $input->readString($key178);
              $val179 = new B();
              $xfer += $val179->read($input);
              if ($key178 !== null && $val179 !== null) {
                $_val172[$key178] = $val179;
              }
            }
            $xfer += $input->readMapEnd();
            $this->map_of_string_to_self = $_val172;
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 51:
          if ($ftype == TType::STRUCT) {
            $this->optional_just_an_A = new A();
            $xfer += $this->optional_just_an_A->read($input);
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 52:
          if ($ftype == TType::SET) {
            $_size181 = 0;
            $_etype184 = 0;
            $_val180 = Set{};
            $xfer += $input->readSetBegin($_etype184, $_size181);
            for ($_i185 = 0; $_size181 === null || $_i185 < $_size181; ++$_i185)
            {
              if ($_size181 === null && !$input->readSetHasNext()) {
                break;
              }
              $elem186 = null;
              $xfer += $input->readI32($elem186);
              if ($elem186 !== null) {
                $_val180->add($elem186);
              }
            }
            $xfer += $input->readSetEnd();
            $this->optional_set_of_i32 = $_val180;
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 53:
          if ($ftype == TType::LST) {
            $_size188 = 0;
            $_val187 = Vector {};
            $_etype191 = 0;
            $xfer += $input->readListBegin($_etype191, $_size188);
            for ($_i192 = 0; $_size188 === null || $_i192 < $_size188; ++$_i192)
            {
              if ($_size188 === null && !$input->readListHasNext()) {
                break;
              }
              $elem193 = null;
              $xfer += $input->readI32($elem193);
              if ($elem193 !== null) {
                $_val187 []= $elem193;
              }
            }
            $xfer += $input->readListEnd();
            $this->optional_list_of_i32 = $_val187;
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 54:
          if ($ftype == TType::LST) {
            $_size195 = 0;
            $_val194 = Vector {};
            $_etype198 = 0;
            $xfer += $input->readListBegin($_etype198, $_size195);
            for ($_i199 = 0; $_size195 === null || $_i199 < $_size195; ++$_i199)
            {
              if ($_size195 === null && !$input->readListHasNext()) {
                break;
              }
              $elem200 = null;
              $xfer += $input->readString($elem200);
              if ($elem200 !== null) {
                $_val194 []= $elem200;
              }
            }
            $xfer += $input->readListEnd();
            $this->optional_list_of_i32 = $_val194;
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 55:
          if ($ftype == TType::MAP) {
            $_size202 = 0;
            $_val201 = Map {};
            $_ktype203 = 0;
            $_vtype204 = 0;
            $xfer += $input->readMapBegin($_ktype203, $_vtype204, $_size202);
            for ($_i206 = 0; $_size202 === null || $_i206 < $_size202; ++$_i206)
            {
              if ($_size202 === null && !$input->readMapHasNext()) {
                break;
              }
              $key207 = '';
              $val208 = 0;
              $xfer += $input->readString($key207);
              $xfer += $input->readI32($val208);
              if ($key207 !== null && $val208 !== null) {
                $_val201[$key207] = $val208;
              }
            }
            $xfer += $input->readMapEnd();
            $this->optional_map_of_string_to_i32 = $_val201;
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 56:
          if ($ftype == TType::MAP) {
            $_size210 = 0;
            $_val209 = Map {};
            $_ktype211 = 0;
            $_vtype212 = 0;
            $xfer += $input->readMapBegin($_ktype211, $_vtype212, $_size210);
            for ($_i214 = 0; $_size210 === null || $_i214 < $_size210; ++$_i214)
            {
              if ($_size210 === null && !$input->readMapHasNext()) {
                break;
              }
              $key215 = '';
              $val216 = new A();
              $xfer += $input->readString($key215);
              $val216 = new A();
              $xfer += $val216->read($input);
              if ($key215 !== null && $val216 !== null) {
                $_val209[$key215] = $val216;
              }
            }
            $xfer += $input->readMapEnd();
            $this->optional_map_of_string_to_A = $_val209;
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 57:
          if ($ftype == TType::MAP) {
            $_size218 = 0;
            $_val217 = Map {};
            $_ktype219 = 0;
            $_vtype220 = 0;
            $xfer += $input->readMapBegin($_ktype219, $_vtype220, $_size218);
            for ($_i222 = 0; $_size218 === null || $_i222 < $_size218; ++$_i222)
            {
              if ($_size218 === null && !$input->readMapHasNext()) {
                break;
              }
              $key223 = '';
              $val224 = Vector {};
              $xfer += $input->readString($key223);
              $_size226 = 0;
              $_val225 = Vector {};
              $_etype229 = 0;
              $xfer += $input->readListBegin($_etype229, $_size226);
              for ($_i230 = 0; $_size226 === null || $_i230 < $_size226; ++$_i230)
              {
                if ($_size226 === null && !$input->readListHasNext()) {
                  break;
                }
                $elem231 = null;
                $xfer += $input->readI32($elem231);
                if ($elem231 !== null) {
                  $_val225 []= $elem231;
                }
              }
              $xfer += $input->readListEnd();
              $val224 = $_val225;
              if ($key223 !== null && $val224 !== null) {
                $_val217[$key223] = $val224;
              }
            }
            $xfer += $input->readMapEnd();
            $this->optional_map_of_string_to_list_of_i32 = $_val217;
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 58:
          if ($ftype == TType::MAP) {
            $_size233 = 0;
            $_val232 = Map {};
            $_ktype234 = 0;
            $_vtype235 = 0;
            $xfer += $input->readMapBegin($_ktype234, $_vtype235, $_size233);
            for ($_i237 = 0; $_size233 === null || $_i237 < $_size233; ++$_i237)
            {
              if ($_size233 === null && !$input->readMapHasNext()) {
                break;
              }
              $key238 = '';
              $val239 = Vector {};
              $xfer += $input->readString($key238);
              $_size241 = 0;
              $_val240 = Vector {};
              $_etype244 = 0;
              $xfer += $input->readListBegin($_etype244, $_size241);
              for ($_i245 = 0; $_size241 === null || $_i245 < $_size241; ++$_i245)
              {
                if ($_size241 === null && !$input->readListHasNext()) {
                  break;
                }
                $elem246 = null;
                $elem246 = new A();
                $xfer += $elem246->read($input);
                if ($elem246 !== null) {
                  $_val240 []= $elem246;
                }
              }
              $xfer += $input->readListEnd();
              $val239 = $_val240;
              if ($key238 !== null && $val239 !== null) {
                $_val232[$key238] = $val239;
              }
            }
            $xfer += $input->readMapEnd();
            $this->optional_map_of_string_to_list_of_A = $_val232;
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        case 59:
          if ($ftype == TType::MAP) {
            $_size248 = 0;
            $_val247 = Map {};
            $_ktype249 = 0;
            $_vtype250 = 0;
            $xfer += $input->readMapBegin($_ktype249, $_vtype250, $_size248);
            for ($_i252 = 0; $_size248 === null || $_i252 < $_size248; ++$_i252)
            {
              if ($_size248 === null && !$input->readMapHasNext()) {
                break;
              }
              $key253 = '';
              $val254 = Set {};
              $xfer += $input->readString($key253);
              $_size256 = 0;
              $_etype259 = 0;
              $_val255 = Set{};
              $xfer += $input->readSetBegin($_etype259, $_size256);
              for ($_i260 = 0; $_size256 === null || $_i260 < $_size256; ++$_i260)
              {
                if ($_size256 === null && !$input->readSetHasNext()) {
                  break;
                }
                $elem261 = null;
                $xfer += $input->readI32($elem261);
                if ($elem261 !== null) {
                  $_val255->add($elem261);
                }
              }
              $xfer += $input->readSetEnd();
              $val254 = $_val255;
              if ($key253 !== null && $val254 !== null) {
                $_val247[$key253] = $val254;
              }
            }
            $xfer += $input->readMapEnd();
            $this->optional_map_of_string_to_set_of_i32 = $_val247;
          } else {
            $xfer += $input->skip($ftype);
          }
          break;
        default:
          $xfer += $input->skip($ftype);
          break;
      }
      $xfer += $input->readFieldEnd();
    }
    $xfer += $input->readStructEnd();
    return $xfer;
  }

  public function write(TProtocol $output): int {
    $xfer = 0;
    $xfer += $output->writeStructBegin('B');
    if ($this->just_an_A !== null) {
      $_val0 = $this->just_an_A;
      if (!($_val0 instanceof A)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('just_an_A', TType::STRUCT, 1);
      $xfer += $_val0->write($output);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->set_of_i32 !== null) {
      $_val1 = $this->set_of_i32;
      if (!($_val1 instanceof Set)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('set_of_i32', TType::SET, 2);
      $output->writeSetBegin(TType::I32, count($_val1));
      if ($_val1 !== null)
      {
        foreach ($_val1 as $iter2)
        {
          $xfer += $output->writeI32($iter2);
        }
      }
      $output->writeSetEnd();
      $xfer += $output->writeFieldEnd();
    }
    if ($this->list_of_i32 !== null) {
      $_val3 = $this->list_of_i32;
      if (!($_val3 instanceof Indexish) && !(($_val3 instanceof Iterator || $_val3 instanceof IteratorAggregate) && $_val3 instanceof Countable)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('list_of_i32', TType::LST, 3);
      $output->writeListBegin(TType::I32, count($_val3));
      if ($_val3 !== null)
      {
        foreach ($_val3 as $iter4)
        {
          $xfer += $output->writeI32($iter4);
        }
      }
      $output->writeListEnd();
      $xfer += $output->writeFieldEnd();
    }
    if ($this->list_of_i32 !== null) {
      $_val5 = $this->list_of_i32;
      if (!($_val5 instanceof Indexish) && !(($_val5 instanceof Iterator || $_val5 instanceof IteratorAggregate) && $_val5 instanceof Countable)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('list_of_i32', TType::LST, 4);
      $output->writeListBegin(TType::STRING, count($_val5));
      if ($_val5 !== null)
      {
        foreach ($_val5 as $iter6)
        {
          $xfer += $output->writeString($iter6);
        }
      }
      $output->writeListEnd();
      $xfer += $output->writeFieldEnd();
    }
    if ($this->map_of_string_to_i32 !== null) {
      $_val7 = $this->map_of_string_to_i32;
      if (!($_val7 instanceof Indexish) && !(($_val7 instanceof Iterator || $_val7 instanceof IteratorAggregate) && $_val7 instanceof Countable)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('map_of_string_to_i32', TType::MAP, 5);
      $output->writeMapBegin(TType::STRING, TType::I32, count($_val7));
      if ($_val7 !== null)
      {
        foreach ($_val7 as $kiter8 => $viter9)
        {
          $xfer += $output->writeString($kiter8);
          $xfer += $output->writeI32($viter9);
        }
      }
      $output->writeMapEnd();
      $xfer += $output->writeFieldEnd();
    }
    if ($this->map_of_string_to_A !== null) {
      $_val10 = $this->map_of_string_to_A;
      if (!($_val10 instanceof Indexish) && !(($_val10 instanceof Iterator || $_val10 instanceof IteratorAggregate) && $_val10 instanceof Countable)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('map_of_string_to_A', TType::MAP, 6);
      $output->writeMapBegin(TType::STRING, TType::STRUCT, count($_val10));
      if ($_val10 !== null)
      {
        foreach ($_val10 as $kiter11 => $viter12)
        {
          $xfer += $output->writeString($kiter11);
          $xfer += $viter12->write($output);
        }
      }
      $output->writeMapEnd();
      $xfer += $output->writeFieldEnd();
    }
    if ($this->map_of_string_to_list_of_i32 !== null) {
      $_val13 = $this->map_of_string_to_list_of_i32;
      if (!($_val13 instanceof Indexish) && !(($_val13 instanceof Iterator || $_val13 instanceof IteratorAggregate) && $_val13 instanceof Countable)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('map_of_string_to_list_of_i32', TType::MAP, 7);
      $output->writeMapBegin(TType::STRING, TType::LST, count($_val13));
      if ($_val13 !== null)
      {
        foreach ($_val13 as $kiter14 => $viter15)
        {
          $xfer += $output->writeString($kiter14);
          $output->writeListBegin(TType::I32, count($viter15));
          if ($viter15 !== null)
          {
            foreach ($viter15 as $iter16)
            {
              $xfer += $output->writeI32($iter16);
            }
          }
          $output->writeListEnd();
        }
      }
      $output->writeMapEnd();
      $xfer += $output->writeFieldEnd();
    }
    if ($this->map_of_string_to_list_of_A !== null) {
      $_val17 = $this->map_of_string_to_list_of_A;
      if (!($_val17 instanceof Indexish) && !(($_val17 instanceof Iterator || $_val17 instanceof IteratorAggregate) && $_val17 instanceof Countable)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('map_of_string_to_list_of_A', TType::MAP, 8);
      $output->writeMapBegin(TType::STRING, TType::LST, count($_val17));
      if ($_val17 !== null)
      {
        foreach ($_val17 as $kiter18 => $viter19)
        {
          $xfer += $output->writeString($kiter18);
          $output->writeListBegin(TType::STRUCT, count($viter19));
          if ($viter19 !== null)
          {
            foreach ($viter19 as $iter20)
            {
              $xfer += $iter20->write($output);
            }
          }
          $output->writeListEnd();
        }
      }
      $output->writeMapEnd();
      $xfer += $output->writeFieldEnd();
    }
    if ($this->map_of_string_to_set_of_i32 !== null) {
      $_val21 = $this->map_of_string_to_set_of_i32;
      if (!($_val21 instanceof Indexish) && !(($_val21 instanceof Iterator || $_val21 instanceof IteratorAggregate) && $_val21 instanceof Countable)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('map_of_string_to_set_of_i32', TType::MAP, 9);
      $output->writeMapBegin(TType::STRING, TType::SET, count($_val21));
      if ($_val21 !== null)
      {
        foreach ($_val21 as $kiter22 => $viter23)
        {
          $xfer += $output->writeString($kiter22);
          $output->writeSetBegin(TType::I32, count($viter23));
          if ($viter23 !== null)
          {
            foreach ($viter23 as $iter24)
            {
              $xfer += $output->writeI32($iter24);
            }
          }
          $output->writeSetEnd();
        }
      }
      $output->writeMapEnd();
      $xfer += $output->writeFieldEnd();
    }
    if ($this->map_of_string_to_map_of_string_to_i32 !== null) {
      $_val25 = $this->map_of_string_to_map_of_string_to_i32;
      if (!($_val25 instanceof Indexish) && !(($_val25 instanceof Iterator || $_val25 instanceof IteratorAggregate) && $_val25 instanceof Countable)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('map_of_string_to_map_of_string_to_i32', TType::MAP, 10);
      $output->writeMapBegin(TType::STRING, TType::MAP, count($_val25));
      if ($_val25 !== null)
      {
        foreach ($_val25 as $kiter26 => $viter27)
        {
          $xfer += $output->writeString($kiter26);
          $output->writeMapBegin(TType::STRING, TType::I32, count($viter27));
          if ($viter27 !== null)
          {
            foreach ($viter27 as $kiter28 => $viter29)
            {
              $xfer += $output->writeString($kiter28);
              $xfer += $output->writeI32($viter29);
            }
          }
          $output->writeMapEnd();
        }
      }
      $output->writeMapEnd();
      $xfer += $output->writeFieldEnd();
    }
    if ($this->map_of_string_to_map_of_string_to_A !== null) {
      $_val30 = $this->map_of_string_to_map_of_string_to_A;
      if (!($_val30 instanceof Indexish) && !(($_val30 instanceof Iterator || $_val30 instanceof IteratorAggregate) && $_val30 instanceof Countable)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('map_of_string_to_map_of_string_to_A', TType::MAP, 11);
      $output->writeMapBegin(TType::STRING, TType::MAP, count($_val30));
      if ($_val30 !== null)
      {
        foreach ($_val30 as $kiter31 => $viter32)
        {
          $xfer += $output->writeString($kiter31);
          $output->writeMapBegin(TType::STRING, TType::STRUCT, count($viter32));
          if ($viter32 !== null)
          {
            foreach ($viter32 as $kiter33 => $viter34)
            {
              $xfer += $output->writeString($kiter33);
              $xfer += $viter34->write($output);
            }
          }
          $output->writeMapEnd();
        }
      }
      $output->writeMapEnd();
      $xfer += $output->writeFieldEnd();
    }
    if ($this->list_of_set_of_i32 !== null) {
      $_val35 = $this->list_of_set_of_i32;
      if (!($_val35 instanceof Indexish) && !(($_val35 instanceof Iterator || $_val35 instanceof IteratorAggregate) && $_val35 instanceof Countable)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('list_of_set_of_i32', TType::LST, 12);
      $output->writeListBegin(TType::SET, count($_val35));
      if ($_val35 !== null)
      {
        foreach ($_val35 as $iter36)
        {
          $output->writeSetBegin(TType::I32, count($iter36));
          if ($iter36 !== null)
          {
            foreach ($iter36 as $iter37)
            {
              $xfer += $output->writeI32($iter37);
            }
          }
          $output->writeSetEnd();
        }
      }
      $output->writeListEnd();
      $xfer += $output->writeFieldEnd();
    }
    if ($this->list_of_map_of_string_to_list_of_A !== null) {
      $_val38 = $this->list_of_map_of_string_to_list_of_A;
      if (!($_val38 instanceof Indexish) && !(($_val38 instanceof Iterator || $_val38 instanceof IteratorAggregate) && $_val38 instanceof Countable)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('list_of_map_of_string_to_list_of_A', TType::LST, 13);
      $output->writeListBegin(TType::MAP, count($_val38));
      if ($_val38 !== null)
      {
        foreach ($_val38 as $iter39)
        {
          $output->writeMapBegin(TType::STRING, TType::LST, count($iter39));
          if ($iter39 !== null)
          {
            foreach ($iter39 as $kiter40 => $viter41)
            {
              $xfer += $output->writeString($kiter40);
              $output->writeListBegin(TType::STRUCT, count($viter41));
              if ($viter41 !== null)
              {
                foreach ($viter41 as $iter42)
                {
                  $xfer += $iter42->write($output);
                }
              }
              $output->writeListEnd();
            }
          }
          $output->writeMapEnd();
        }
      }
      $output->writeListEnd();
      $xfer += $output->writeFieldEnd();
    }
    if ($this->list_of_map_of_string_to_A !== null) {
      $_val43 = $this->list_of_map_of_string_to_A;
      if (!($_val43 instanceof Indexish) && !(($_val43 instanceof Iterator || $_val43 instanceof IteratorAggregate) && $_val43 instanceof Countable)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('list_of_map_of_string_to_A', TType::LST, 14);
      $output->writeListBegin(TType::MAP, count($_val43));
      if ($_val43 !== null)
      {
        foreach ($_val43 as $iter44)
        {
          $output->writeMapBegin(TType::STRING, TType::STRUCT, count($iter44));
          if ($iter44 !== null)
          {
            foreach ($iter44 as $kiter45 => $viter46)
            {
              $xfer += $output->writeString($kiter45);
              $xfer += $viter46->write($output);
            }
          }
          $output->writeMapEnd();
        }
      }
      $output->writeListEnd();
      $xfer += $output->writeFieldEnd();
    }
    if ($this->list_of_self !== null) {
      $_val47 = $this->list_of_self;
      if (!($_val47 instanceof Indexish) && !(($_val47 instanceof Iterator || $_val47 instanceof IteratorAggregate) && $_val47 instanceof Countable)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('list_of_self', TType::LST, 15);
      $output->writeListBegin(TType::STRUCT, count($_val47));
      if ($_val47 !== null)
      {
        foreach ($_val47 as $iter48)
        {
          $xfer += $iter48->write($output);
        }
      }
      $output->writeListEnd();
      $xfer += $output->writeFieldEnd();
    }
    if ($this->map_of_string_to_self !== null) {
      $_val49 = $this->map_of_string_to_self;
      if (!($_val49 instanceof Indexish) && !(($_val49 instanceof Iterator || $_val49 instanceof IteratorAggregate) && $_val49 instanceof Countable)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('map_of_string_to_self', TType::MAP, 16);
      $output->writeMapBegin(TType::STRING, TType::STRUCT, count($_val49));
      if ($_val49 !== null)
      {
        foreach ($_val49 as $kiter50 => $viter51)
        {
          $xfer += $output->writeString($kiter50);
          $xfer += $viter51->write($output);
        }
      }
      $output->writeMapEnd();
      $xfer += $output->writeFieldEnd();
    }
    if ($this->optional_just_an_A !== null) {
      $_val52 = $this->optional_just_an_A;
      if (!($_val52 instanceof A)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('optional_just_an_A', TType::STRUCT, 51);
      $xfer += $_val52->write($output);
      $xfer += $output->writeFieldEnd();
    }
    if ($this->optional_set_of_i32 !== null) {
      $_val53 = $this->optional_set_of_i32;
      if (!($_val53 instanceof Set)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('optional_set_of_i32', TType::SET, 52);
      $output->writeSetBegin(TType::I32, count($_val53));
      if ($_val53 !== null)
      {
        foreach ($_val53 as $iter54)
        {
          $xfer += $output->writeI32($iter54);
        }
      }
      $output->writeSetEnd();
      $xfer += $output->writeFieldEnd();
    }
    if ($this->optional_list_of_i32 !== null) {
      $_val55 = $this->optional_list_of_i32;
      if (!($_val55 instanceof Indexish) && !(($_val55 instanceof Iterator || $_val55 instanceof IteratorAggregate) && $_val55 instanceof Countable)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('optional_list_of_i32', TType::LST, 53);
      $output->writeListBegin(TType::I32, count($_val55));
      if ($_val55 !== null)
      {
        foreach ($_val55 as $iter56)
        {
          $xfer += $output->writeI32($iter56);
        }
      }
      $output->writeListEnd();
      $xfer += $output->writeFieldEnd();
    }
    if ($this->optional_list_of_i32 !== null) {
      $_val57 = $this->optional_list_of_i32;
      if (!($_val57 instanceof Indexish) && !(($_val57 instanceof Iterator || $_val57 instanceof IteratorAggregate) && $_val57 instanceof Countable)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('optional_list_of_i32', TType::LST, 54);
      $output->writeListBegin(TType::STRING, count($_val57));
      if ($_val57 !== null)
      {
        foreach ($_val57 as $iter58)
        {
          $xfer += $output->writeString($iter58);
        }
      }
      $output->writeListEnd();
      $xfer += $output->writeFieldEnd();
    }
    if ($this->optional_map_of_string_to_i32 !== null) {
      $_val59 = $this->optional_map_of_string_to_i32;
      if (!($_val59 instanceof Indexish) && !(($_val59 instanceof Iterator || $_val59 instanceof IteratorAggregate) && $_val59 instanceof Countable)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('optional_map_of_string_to_i32', TType::MAP, 55);
      $output->writeMapBegin(TType::STRING, TType::I32, count($_val59));
      if ($_val59 !== null)
      {
        foreach ($_val59 as $kiter60 => $viter61)
        {
          $xfer += $output->writeString($kiter60);
          $xfer += $output->writeI32($viter61);
        }
      }
      $output->writeMapEnd();
      $xfer += $output->writeFieldEnd();
    }
    if ($this->optional_map_of_string_to_A !== null) {
      $_val62 = $this->optional_map_of_string_to_A;
      if (!($_val62 instanceof Indexish) && !(($_val62 instanceof Iterator || $_val62 instanceof IteratorAggregate) && $_val62 instanceof Countable)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('optional_map_of_string_to_A', TType::MAP, 56);
      $output->writeMapBegin(TType::STRING, TType::STRUCT, count($_val62));
      if ($_val62 !== null)
      {
        foreach ($_val62 as $kiter63 => $viter64)
        {
          $xfer += $output->writeString($kiter63);
          $xfer += $viter64->write($output);
        }
      }
      $output->writeMapEnd();
      $xfer += $output->writeFieldEnd();
    }
    if ($this->optional_map_of_string_to_list_of_i32 !== null) {
      $_val65 = $this->optional_map_of_string_to_list_of_i32;
      if (!($_val65 instanceof Indexish) && !(($_val65 instanceof Iterator || $_val65 instanceof IteratorAggregate) && $_val65 instanceof Countable)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('optional_map_of_string_to_list_of_i32', TType::MAP, 57);
      $output->writeMapBegin(TType::STRING, TType::LST, count($_val65));
      if ($_val65 !== null)
      {
        foreach ($_val65 as $kiter66 => $viter67)
        {
          $xfer += $output->writeString($kiter66);
          $output->writeListBegin(TType::I32, count($viter67));
          if ($viter67 !== null)
          {
            foreach ($viter67 as $iter68)
            {
              $xfer += $output->writeI32($iter68);
            }
          }
          $output->writeListEnd();
        }
      }
      $output->writeMapEnd();
      $xfer += $output->writeFieldEnd();
    }
    if ($this->optional_map_of_string_to_list_of_A !== null) {
      $_val69 = $this->optional_map_of_string_to_list_of_A;
      if (!($_val69 instanceof Indexish) && !(($_val69 instanceof Iterator || $_val69 instanceof IteratorAggregate) && $_val69 instanceof Countable)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('optional_map_of_string_to_list_of_A', TType::MAP, 58);
      $output->writeMapBegin(TType::STRING, TType::LST, count($_val69));
      if ($_val69 !== null)
      {
        foreach ($_val69 as $kiter70 => $viter71)
        {
          $xfer += $output->writeString($kiter70);
          $output->writeListBegin(TType::STRUCT, count($viter71));
          if ($viter71 !== null)
          {
            foreach ($viter71 as $iter72)
            {
              $xfer += $iter72->write($output);
            }
          }
          $output->writeListEnd();
        }
      }
      $output->writeMapEnd();
      $xfer += $output->writeFieldEnd();
    }
    if ($this->optional_map_of_string_to_set_of_i32 !== null) {
      $_val73 = $this->optional_map_of_string_to_set_of_i32;
      if (!($_val73 instanceof Indexish) && !(($_val73 instanceof Iterator || $_val73 instanceof IteratorAggregate) && $_val73 instanceof Countable)) {
        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
      }
      $xfer += $output->writeFieldBegin('optional_map_of_string_to_set_of_i32', TType::MAP, 59);
      $output->writeMapBegin(TType::STRING, TType::SET, count($_val73));
      if ($_val73 !== null)
      {
        foreach ($_val73 as $kiter74 => $viter75)
        {
          $xfer += $output->writeString($kiter74);
          $output->writeSetBegin(TType::I32, count($viter75));
          if ($viter75 !== null)
          {
            foreach ($viter75 as $iter76)
            {
              $xfer += $output->writeI32($iter76);
            }
          }
          $output->writeSetEnd();
        }
      }
      $output->writeMapEnd();
      $xfer += $output->writeFieldEnd();
    }
    $xfer += $output->writeFieldStop();
    $xfer += $output->writeStructEnd();
    return $xfer;
  }

}

