type = ParamType::LIST; $this->listType = $listType; $this->value = []; foreach ( $elements as $element ) { if ( $element instanceof MessageParam ) { $this->value[] = $element; } else { $this->value[] = new ScalarParam( ParamType::TEXT, $element ); } } } /** * Get the type of the list * * @return string One of the ListType constants */ public function getListType() { return $this->listType; } public function dump() { $contents = ''; foreach ( $this->value as $element ) { $contents .= $element->dump(); } return "<{$this->type} listType=\"{$this->listType}\">$contentstype}>"; } public function toJsonArray(): array { // WARNING: When changing how this class is serialized, follow the instructions // at ! return [ $this->type => $this->value, 'type' => $this->listType, ]; } public static function newFromJsonArray( JsonDeserializer $deserializer, array $json ) { // WARNING: When changing how this class is serialized, follow the instructions // at ! if ( count( $json ) !== 2 || !isset( $json[ParamType::LIST] ) || !isset( $json['type'] ) ) { throw new InvalidArgumentException( 'Invalid format' ); } return new self( $json['type'], $json[ParamType::LIST] ); } }