1--TEST--
2DOMDocument::$version write
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7class MyThrowingStringable {
8    public function __toString(): string {
9        throw new Exception("An exception was thrown");
10    }
11}
12
13$dom = new DOMDocument;
14var_dump($dom->version);
15$dom->version = "foobar";
16var_dump($dom->version);
17echo $dom->saveXML();
18
19try {
20    $dom->version = new MyThrowingStringable;
21} catch (Exception $e) {
22    echo $e->getMessage(), "\n";
23}
24var_dump($dom->version);
25echo $dom->saveXML();
26?>
27--EXPECT--
28string(3) "1.0"
29string(6) "foobar"
30<?xml version="foobar"?>
31An exception was thrown
32string(6) "foobar"
33<?xml version="foobar"?>
34