1ffe3c632Sopenharmony_ci<?php
2ffe3c632Sopenharmony_ci
3ffe3c632Sopenharmony_cirequire_once('generated/NoNamespaceEnum.php');
4ffe3c632Sopenharmony_cirequire_once('generated/NoNamespaceMessage.php');
5ffe3c632Sopenharmony_cirequire_once('test_base.php');
6ffe3c632Sopenharmony_cirequire_once('test_util.php');
7ffe3c632Sopenharmony_ci
8ffe3c632Sopenharmony_ciuse Google\Protobuf\Internal\RepeatedField;
9ffe3c632Sopenharmony_ciuse Google\Protobuf\Internal\MapField;
10ffe3c632Sopenharmony_ciuse Google\Protobuf\Internal\GPBType;
11ffe3c632Sopenharmony_ciuse Bar\TestLegacyMessage;
12ffe3c632Sopenharmony_ciuse Bar\TestLegacyMessage_NestedEnum;
13ffe3c632Sopenharmony_ciuse Bar\TestLegacyMessage_NestedMessage;
14ffe3c632Sopenharmony_ciuse Foo\TestEnum;
15ffe3c632Sopenharmony_ciuse Foo\TestIncludeNamespaceMessage;
16ffe3c632Sopenharmony_ciuse Foo\TestIncludePrefixMessage;
17ffe3c632Sopenharmony_ciuse Foo\TestMessage;
18ffe3c632Sopenharmony_ciuse Foo\TestMessage\Sub;
19ffe3c632Sopenharmony_ciuse Foo\TestMessage_Sub;
20ffe3c632Sopenharmony_ciuse Foo\TestMessage\NestedEnum;
21ffe3c632Sopenharmony_ciuse Foo\TestReverseFieldOrder;
22ffe3c632Sopenharmony_ciuse Foo\testLowerCaseMessage;
23ffe3c632Sopenharmony_ciuse Foo\testLowerCaseEnum;
24ffe3c632Sopenharmony_ciuse PBEmpty\PBEcho\TestEmptyPackage;
25ffe3c632Sopenharmony_ciuse Php\Test\TestNamespace;
26ffe3c632Sopenharmony_ci
27ffe3c632Sopenharmony_ciclass GeneratedClassTest extends TestBase
28ffe3c632Sopenharmony_ci{
29ffe3c632Sopenharmony_ci
30ffe3c632Sopenharmony_ci    #########################################################
31ffe3c632Sopenharmony_ci    # Test field accessors.
32ffe3c632Sopenharmony_ci    #########################################################
33ffe3c632Sopenharmony_ci
34ffe3c632Sopenharmony_ci    public function testSetterGetter()
35ffe3c632Sopenharmony_ci    {
36ffe3c632Sopenharmony_ci        $m = new TestMessage();
37ffe3c632Sopenharmony_ci        $m->setOptionalInt32(1);
38ffe3c632Sopenharmony_ci        $this->assertSame(1, $m->getOptionalInt32());
39ffe3c632Sopenharmony_ci    }
40ffe3c632Sopenharmony_ci
41ffe3c632Sopenharmony_ci    #########################################################
42ffe3c632Sopenharmony_ci    # Test int32 field.
43ffe3c632Sopenharmony_ci    #########################################################
44ffe3c632Sopenharmony_ci
45ffe3c632Sopenharmony_ci    public function testInt32Field()
46ffe3c632Sopenharmony_ci    {
47ffe3c632Sopenharmony_ci        $m = new TestMessage();
48ffe3c632Sopenharmony_ci
49ffe3c632Sopenharmony_ci        // Set integer.
50ffe3c632Sopenharmony_ci        $m->setOptionalInt32(MAX_INT32);
51ffe3c632Sopenharmony_ci        $this->assertSame(MAX_INT32, $m->getOptionalInt32());
52ffe3c632Sopenharmony_ci        $m->setOptionalInt32(MIN_INT32);
53ffe3c632Sopenharmony_ci        $this->assertSame(MIN_INT32, $m->getOptionalInt32());
54ffe3c632Sopenharmony_ci
55ffe3c632Sopenharmony_ci        // Set float.
56ffe3c632Sopenharmony_ci        $m->setOptionalInt32(1.1);
57ffe3c632Sopenharmony_ci        $this->assertSame(1, $m->getOptionalInt32());
58ffe3c632Sopenharmony_ci        $m->setOptionalInt32(MAX_INT32_FLOAT);
59ffe3c632Sopenharmony_ci        $this->assertSame(MAX_INT32, $m->getOptionalInt32());
60ffe3c632Sopenharmony_ci        $m->setOptionalInt32(MIN_INT32_FLOAT);
61ffe3c632Sopenharmony_ci        $this->assertSame(MIN_INT32, $m->getOptionalInt32());
62ffe3c632Sopenharmony_ci
63ffe3c632Sopenharmony_ci        // Set string.
64ffe3c632Sopenharmony_ci        $m->setOptionalInt32('2');
65ffe3c632Sopenharmony_ci        $this->assertSame(2, $m->getOptionalInt32());
66ffe3c632Sopenharmony_ci        $m->setOptionalInt32('3.1');
67ffe3c632Sopenharmony_ci        $this->assertSame(3, $m->getOptionalInt32());
68ffe3c632Sopenharmony_ci        $m->setOptionalInt32(MAX_INT32_STRING);
69ffe3c632Sopenharmony_ci        $this->assertSame(MAX_INT32, $m->getOptionalInt32());
70ffe3c632Sopenharmony_ci        $m->setOptionalInt32(MIN_INT32_STRING);
71ffe3c632Sopenharmony_ci        $this->assertSame(MIN_INT32, $m->getOptionalInt32());
72ffe3c632Sopenharmony_ci    }
73ffe3c632Sopenharmony_ci
74ffe3c632Sopenharmony_ci    #########################################################
75ffe3c632Sopenharmony_ci    # Test optional int32 field.
76ffe3c632Sopenharmony_ci    #########################################################
77ffe3c632Sopenharmony_ci
78ffe3c632Sopenharmony_ci    public function testOptionalInt32Field()
79ffe3c632Sopenharmony_ci    {
80ffe3c632Sopenharmony_ci        $m = new TestMessage();
81ffe3c632Sopenharmony_ci
82ffe3c632Sopenharmony_ci        $this->assertFalse($m->hasTrueOptionalInt32());
83ffe3c632Sopenharmony_ci        $this->assertSame(0, $m->getTrueOptionalInt32());
84ffe3c632Sopenharmony_ci
85ffe3c632Sopenharmony_ci        // Set integer.
86ffe3c632Sopenharmony_ci        $m->setTrueOptionalInt32(MAX_INT32);
87ffe3c632Sopenharmony_ci        $this->assertTrue($m->hasTrueOptionalInt32());
88ffe3c632Sopenharmony_ci        $this->assertSame(MAX_INT32, $m->getTrueOptionalInt32());
89ffe3c632Sopenharmony_ci
90ffe3c632Sopenharmony_ci        // Clear integer.
91ffe3c632Sopenharmony_ci        $m->clearTrueOptionalInt32();
92ffe3c632Sopenharmony_ci        $this->assertFalse($m->hasTrueOptionalInt32());
93ffe3c632Sopenharmony_ci        $this->assertSame(0, $m->getTrueOptionalInt32());
94ffe3c632Sopenharmony_ci    }
95ffe3c632Sopenharmony_ci
96ffe3c632Sopenharmony_ci    #########################################################
97ffe3c632Sopenharmony_ci    # Test uint32 field.
98ffe3c632Sopenharmony_ci    #########################################################
99ffe3c632Sopenharmony_ci
100ffe3c632Sopenharmony_ci    public function testUint32Field()
101ffe3c632Sopenharmony_ci    {
102ffe3c632Sopenharmony_ci        $m = new TestMessage();
103ffe3c632Sopenharmony_ci
104ffe3c632Sopenharmony_ci        // Set integer.
105ffe3c632Sopenharmony_ci        $m->setOptionalUint32(MAX_UINT32);
106ffe3c632Sopenharmony_ci        $this->assertSame(-1, $m->getOptionalUint32());
107ffe3c632Sopenharmony_ci        $m->setOptionalUint32(-1);
108ffe3c632Sopenharmony_ci        $this->assertSame(-1, $m->getOptionalUint32());
109ffe3c632Sopenharmony_ci        $m->setOptionalUint32(MIN_UINT32);
110ffe3c632Sopenharmony_ci        $this->assertSame(MIN_INT32, $m->getOptionalUint32());
111ffe3c632Sopenharmony_ci
112ffe3c632Sopenharmony_ci        // Set float.
113ffe3c632Sopenharmony_ci        $m->setOptionalUint32(1.1);
114ffe3c632Sopenharmony_ci        $this->assertSame(1, $m->getOptionalUint32());
115ffe3c632Sopenharmony_ci        $m->setOptionalUint32(MAX_UINT32_FLOAT);
116ffe3c632Sopenharmony_ci        $this->assertSame(-1, $m->getOptionalUint32());
117ffe3c632Sopenharmony_ci        $m->setOptionalUint32(-1.0);
118ffe3c632Sopenharmony_ci        $this->assertSame(-1, $m->getOptionalUint32());
119ffe3c632Sopenharmony_ci        $m->setOptionalUint32(MIN_UINT32_FLOAT);
120ffe3c632Sopenharmony_ci        $this->assertSame(MIN_INT32, $m->getOptionalUint32());
121ffe3c632Sopenharmony_ci
122ffe3c632Sopenharmony_ci        // Set string.
123ffe3c632Sopenharmony_ci        $m->setOptionalUint32('2');
124ffe3c632Sopenharmony_ci        $this->assertSame(2, $m->getOptionalUint32());
125ffe3c632Sopenharmony_ci        $m->setOptionalUint32('3.1');
126ffe3c632Sopenharmony_ci        $this->assertSame(3, $m->getOptionalUint32());
127ffe3c632Sopenharmony_ci        $m->setOptionalUint32(MAX_UINT32_STRING);
128ffe3c632Sopenharmony_ci        $this->assertSame(-1, $m->getOptionalUint32());
129ffe3c632Sopenharmony_ci        $m->setOptionalUint32('-1.0');
130ffe3c632Sopenharmony_ci        $this->assertSame(-1, $m->getOptionalUint32());
131ffe3c632Sopenharmony_ci        $m->setOptionalUint32(MIN_UINT32_STRING);
132ffe3c632Sopenharmony_ci        $this->assertSame(MIN_INT32, $m->getOptionalUint32());
133ffe3c632Sopenharmony_ci    }
134ffe3c632Sopenharmony_ci
135ffe3c632Sopenharmony_ci    #########################################################
136ffe3c632Sopenharmony_ci    # Test int64 field.
137ffe3c632Sopenharmony_ci    #########################################################
138ffe3c632Sopenharmony_ci
139ffe3c632Sopenharmony_ci    public function testInt64Field()
140ffe3c632Sopenharmony_ci    {
141ffe3c632Sopenharmony_ci        $m = new TestMessage();
142ffe3c632Sopenharmony_ci
143ffe3c632Sopenharmony_ci        // Set integer.
144ffe3c632Sopenharmony_ci        $m->setOptionalInt64(MAX_INT64);
145ffe3c632Sopenharmony_ci        $this->assertSame(MAX_INT64, $m->getOptionalInt64());
146ffe3c632Sopenharmony_ci        $m->setOptionalInt64(MIN_INT64);
147ffe3c632Sopenharmony_ci        $this->assertEquals(MIN_INT64, $m->getOptionalInt64());
148ffe3c632Sopenharmony_ci
149ffe3c632Sopenharmony_ci        // Set float.
150ffe3c632Sopenharmony_ci        $m->setOptionalInt64(1.1);
151ffe3c632Sopenharmony_ci        if (PHP_INT_SIZE == 4) {
152ffe3c632Sopenharmony_ci            $this->assertSame('1', $m->getOptionalInt64());
153ffe3c632Sopenharmony_ci        } else {
154ffe3c632Sopenharmony_ci            $this->assertSame(1, $m->getOptionalInt64());
155ffe3c632Sopenharmony_ci        }
156ffe3c632Sopenharmony_ci
157ffe3c632Sopenharmony_ci        // Set string.
158ffe3c632Sopenharmony_ci        $m->setOptionalInt64('2');
159ffe3c632Sopenharmony_ci        if (PHP_INT_SIZE == 4) {
160ffe3c632Sopenharmony_ci            $this->assertSame('2', $m->getOptionalInt64());
161ffe3c632Sopenharmony_ci        } else {
162ffe3c632Sopenharmony_ci            $this->assertSame(2, $m->getOptionalInt64());
163ffe3c632Sopenharmony_ci        }
164ffe3c632Sopenharmony_ci
165ffe3c632Sopenharmony_ci        $m->setOptionalInt64('3.1');
166ffe3c632Sopenharmony_ci        if (PHP_INT_SIZE == 4) {
167ffe3c632Sopenharmony_ci            $this->assertSame('3', $m->getOptionalInt64());
168ffe3c632Sopenharmony_ci        } else {
169ffe3c632Sopenharmony_ci            $this->assertSame(3, $m->getOptionalInt64());
170ffe3c632Sopenharmony_ci        }
171ffe3c632Sopenharmony_ci
172ffe3c632Sopenharmony_ci        $m->setOptionalInt64(MAX_INT64_STRING);
173ffe3c632Sopenharmony_ci        if (PHP_INT_SIZE == 4) {
174ffe3c632Sopenharmony_ci            $this->assertSame(MAX_INT64_STRING, $m->getOptionalInt64());
175ffe3c632Sopenharmony_ci        } else {
176ffe3c632Sopenharmony_ci            $this->assertSame(MAX_INT64, $m->getOptionalInt64());
177ffe3c632Sopenharmony_ci        }
178ffe3c632Sopenharmony_ci
179ffe3c632Sopenharmony_ci        $m->setOptionalInt64(MIN_INT64_STRING);
180ffe3c632Sopenharmony_ci        if (PHP_INT_SIZE == 4) {
181ffe3c632Sopenharmony_ci            $this->assertSame(MIN_INT64_STRING, $m->getOptionalInt64());
182ffe3c632Sopenharmony_ci        } else {
183ffe3c632Sopenharmony_ci            $this->assertSame(MIN_INT64, $m->getOptionalInt64());
184ffe3c632Sopenharmony_ci        }
185ffe3c632Sopenharmony_ci    }
186ffe3c632Sopenharmony_ci
187ffe3c632Sopenharmony_ci    #########################################################
188ffe3c632Sopenharmony_ci    # Test uint64 field.
189ffe3c632Sopenharmony_ci    #########################################################
190ffe3c632Sopenharmony_ci
191ffe3c632Sopenharmony_ci    public function testUint64Field()
192ffe3c632Sopenharmony_ci    {
193ffe3c632Sopenharmony_ci        $m = new TestMessage();
194ffe3c632Sopenharmony_ci
195ffe3c632Sopenharmony_ci        // Set integer.
196ffe3c632Sopenharmony_ci        $m->setOptionalUint64(MAX_UINT64);
197ffe3c632Sopenharmony_ci        if (PHP_INT_SIZE == 4) {
198ffe3c632Sopenharmony_ci            $this->assertSame(MAX_UINT64_STRING, $m->getOptionalUint64());
199ffe3c632Sopenharmony_ci        } else {
200ffe3c632Sopenharmony_ci            $this->assertSame(MAX_UINT64, $m->getOptionalUint64());
201ffe3c632Sopenharmony_ci        }
202ffe3c632Sopenharmony_ci
203ffe3c632Sopenharmony_ci        // Set float.
204ffe3c632Sopenharmony_ci        $m->setOptionalUint64(1.1);
205ffe3c632Sopenharmony_ci        if (PHP_INT_SIZE == 4) {
206ffe3c632Sopenharmony_ci            $this->assertSame('1', $m->getOptionalUint64());
207ffe3c632Sopenharmony_ci        } else {
208ffe3c632Sopenharmony_ci            $this->assertSame(1, $m->getOptionalUint64());
209ffe3c632Sopenharmony_ci        }
210ffe3c632Sopenharmony_ci
211ffe3c632Sopenharmony_ci        // Set string.
212ffe3c632Sopenharmony_ci        $m->setOptionalUint64('2');
213ffe3c632Sopenharmony_ci        if (PHP_INT_SIZE == 4) {
214ffe3c632Sopenharmony_ci            $this->assertSame('2', $m->getOptionalUint64());
215ffe3c632Sopenharmony_ci        } else {
216ffe3c632Sopenharmony_ci            $this->assertSame(2, $m->getOptionalUint64());
217ffe3c632Sopenharmony_ci        }
218ffe3c632Sopenharmony_ci
219ffe3c632Sopenharmony_ci        $m->setOptionalUint64('3.1');
220ffe3c632Sopenharmony_ci        if (PHP_INT_SIZE == 4) {
221ffe3c632Sopenharmony_ci            $this->assertSame('3', $m->getOptionalUint64());
222ffe3c632Sopenharmony_ci        } else {
223ffe3c632Sopenharmony_ci            $this->assertSame(3, $m->getOptionalUint64());
224ffe3c632Sopenharmony_ci        }
225ffe3c632Sopenharmony_ci
226ffe3c632Sopenharmony_ci        $m->setOptionalUint64(MAX_UINT64_STRING);
227ffe3c632Sopenharmony_ci        if (PHP_INT_SIZE == 4) {
228ffe3c632Sopenharmony_ci            $this->assertSame(MAX_UINT64_STRING, $m->getOptionalUint64());
229ffe3c632Sopenharmony_ci        } else {
230ffe3c632Sopenharmony_ci            $this->assertSame(MAX_UINT64, $m->getOptionalUint64());
231ffe3c632Sopenharmony_ci        }
232ffe3c632Sopenharmony_ci    }
233ffe3c632Sopenharmony_ci
234ffe3c632Sopenharmony_ci    #########################################################
235ffe3c632Sopenharmony_ci    # Test enum field.
236ffe3c632Sopenharmony_ci    #########################################################
237ffe3c632Sopenharmony_ci
238ffe3c632Sopenharmony_ci    public function testEnumField()
239ffe3c632Sopenharmony_ci    {
240ffe3c632Sopenharmony_ci        $m = new TestMessage();
241ffe3c632Sopenharmony_ci
242ffe3c632Sopenharmony_ci        // Set enum.
243ffe3c632Sopenharmony_ci        $m->setOptionalEnum(TestEnum::ONE);
244ffe3c632Sopenharmony_ci        $this->assertEquals(TestEnum::ONE, $m->getOptionalEnum());
245ffe3c632Sopenharmony_ci
246ffe3c632Sopenharmony_ci        // Set integer.
247ffe3c632Sopenharmony_ci        $m->setOptionalEnum(1);
248ffe3c632Sopenharmony_ci        $this->assertEquals(TestEnum::ONE, $m->getOptionalEnum());
249ffe3c632Sopenharmony_ci
250ffe3c632Sopenharmony_ci        // Set float.
251ffe3c632Sopenharmony_ci        $m->setOptionalEnum(1.1);
252ffe3c632Sopenharmony_ci        $this->assertEquals(TestEnum::ONE, $m->getOptionalEnum());
253ffe3c632Sopenharmony_ci
254ffe3c632Sopenharmony_ci        // Set string.
255ffe3c632Sopenharmony_ci        $m->setOptionalEnum("1");
256ffe3c632Sopenharmony_ci        $this->assertEquals(TestEnum::ONE, $m->getOptionalEnum());
257ffe3c632Sopenharmony_ci
258ffe3c632Sopenharmony_ci        // Test Enum methods
259ffe3c632Sopenharmony_ci        $this->assertEquals('ONE', TestEnum::name(1));
260ffe3c632Sopenharmony_ci        $this->assertEquals(1, TestEnum::value('ONE'));
261ffe3c632Sopenharmony_ci    }
262ffe3c632Sopenharmony_ci
263ffe3c632Sopenharmony_ci    /**
264ffe3c632Sopenharmony_ci     * @expectedException UnexpectedValueException
265ffe3c632Sopenharmony_ci     * @expectedExceptionMessage Enum Foo\TestEnum has no name defined for value -1
266ffe3c632Sopenharmony_ci     */
267ffe3c632Sopenharmony_ci    public function testInvalidEnumValueThrowsException()
268ffe3c632Sopenharmony_ci    {
269ffe3c632Sopenharmony_ci        TestEnum::name(-1);
270ffe3c632Sopenharmony_ci    }
271ffe3c632Sopenharmony_ci
272ffe3c632Sopenharmony_ci    /**
273ffe3c632Sopenharmony_ci     * @expectedException UnexpectedValueException
274ffe3c632Sopenharmony_ci     * @expectedExceptionMessage Enum Foo\TestEnum has no value defined for name DOES_NOT_EXIST
275ffe3c632Sopenharmony_ci     */
276ffe3c632Sopenharmony_ci    public function testInvalidEnumNameThrowsException()
277ffe3c632Sopenharmony_ci    {
278ffe3c632Sopenharmony_ci        TestEnum::value('DOES_NOT_EXIST');
279ffe3c632Sopenharmony_ci    }
280ffe3c632Sopenharmony_ci
281ffe3c632Sopenharmony_ci    public function testNestedEnum()
282ffe3c632Sopenharmony_ci    {
283ffe3c632Sopenharmony_ci        $m = new TestMessage();
284ffe3c632Sopenharmony_ci        $m->setOptionalNestedEnum(NestedEnum::ZERO);
285ffe3c632Sopenharmony_ci        $this->assertTrue(true);
286ffe3c632Sopenharmony_ci    }
287ffe3c632Sopenharmony_ci
288ffe3c632Sopenharmony_ci    public function testLegacyNestedEnum()
289ffe3c632Sopenharmony_ci    {
290ffe3c632Sopenharmony_ci        $m = new TestMessage();
291ffe3c632Sopenharmony_ci        $m->setOptionalNestedEnum(\Foo\TestMessage_NestedEnum::ZERO);
292ffe3c632Sopenharmony_ci        $this->assertTrue(true);
293ffe3c632Sopenharmony_ci    }
294ffe3c632Sopenharmony_ci
295ffe3c632Sopenharmony_ci    public function testLegacyTypehintWithNestedEnums()
296ffe3c632Sopenharmony_ci    {
297ffe3c632Sopenharmony_ci        $this->legacyEnum(new TestLegacyMessage\NestedEnum);
298ffe3c632Sopenharmony_ci    }
299ffe3c632Sopenharmony_ci
300ffe3c632Sopenharmony_ci    private function legacyEnum(TestLegacyMessage_NestedEnum $enum)
301ffe3c632Sopenharmony_ci    {
302ffe3c632Sopenharmony_ci        // If we made it here without a PHP Fatal error, the typehint worked
303ffe3c632Sopenharmony_ci        $this->assertTrue(true);
304ffe3c632Sopenharmony_ci    }
305ffe3c632Sopenharmony_ci
306ffe3c632Sopenharmony_ci    #########################################################
307ffe3c632Sopenharmony_ci    # Test float field.
308ffe3c632Sopenharmony_ci    #########################################################
309ffe3c632Sopenharmony_ci
310ffe3c632Sopenharmony_ci    public function testFloatField()
311ffe3c632Sopenharmony_ci    {
312ffe3c632Sopenharmony_ci        $m = new TestMessage();
313ffe3c632Sopenharmony_ci
314ffe3c632Sopenharmony_ci        // Set integer.
315ffe3c632Sopenharmony_ci        $m->setOptionalFloat(1);
316ffe3c632Sopenharmony_ci        $this->assertEquals(1.0, $m->getOptionalFloat(), '', MAX_FLOAT_DIFF);
317ffe3c632Sopenharmony_ci
318ffe3c632Sopenharmony_ci        // Set float.
319ffe3c632Sopenharmony_ci        $m->setOptionalFloat(1.1);
320ffe3c632Sopenharmony_ci        $this->assertEquals(1.1, $m->getOptionalFloat(), '', MAX_FLOAT_DIFF);
321ffe3c632Sopenharmony_ci
322ffe3c632Sopenharmony_ci        // Set string.
323ffe3c632Sopenharmony_ci        $m->setOptionalFloat('2');
324ffe3c632Sopenharmony_ci        $this->assertEquals(2.0, $m->getOptionalFloat(), '', MAX_FLOAT_DIFF);
325ffe3c632Sopenharmony_ci        $m->setOptionalFloat('3.1');
326ffe3c632Sopenharmony_ci        $this->assertEquals(3.1, $m->getOptionalFloat(), '', MAX_FLOAT_DIFF);
327ffe3c632Sopenharmony_ci    }
328ffe3c632Sopenharmony_ci
329ffe3c632Sopenharmony_ci    #########################################################
330ffe3c632Sopenharmony_ci    # Test double field.
331ffe3c632Sopenharmony_ci    #########################################################
332ffe3c632Sopenharmony_ci
333ffe3c632Sopenharmony_ci    public function testDoubleField()
334ffe3c632Sopenharmony_ci    {
335ffe3c632Sopenharmony_ci        $m = new TestMessage();
336ffe3c632Sopenharmony_ci
337ffe3c632Sopenharmony_ci        // Set integer.
338ffe3c632Sopenharmony_ci        $m->setOptionalDouble(1);
339ffe3c632Sopenharmony_ci        $this->assertEquals(1.0, $m->getOptionalDouble(), '', MAX_FLOAT_DIFF);
340ffe3c632Sopenharmony_ci
341ffe3c632Sopenharmony_ci        // Set float.
342ffe3c632Sopenharmony_ci        $m->setOptionalDouble(1.1);
343ffe3c632Sopenharmony_ci        $this->assertEquals(1.1, $m->getOptionalDouble(), '', MAX_FLOAT_DIFF);
344ffe3c632Sopenharmony_ci
345ffe3c632Sopenharmony_ci        // Set string.
346ffe3c632Sopenharmony_ci        $m->setOptionalDouble('2');
347ffe3c632Sopenharmony_ci        $this->assertEquals(2.0, $m->getOptionalDouble(), '', MAX_FLOAT_DIFF);
348ffe3c632Sopenharmony_ci        $m->setOptionalDouble('3.1');
349ffe3c632Sopenharmony_ci        $this->assertEquals(3.1, $m->getOptionalDouble(), '', MAX_FLOAT_DIFF);
350ffe3c632Sopenharmony_ci    }
351ffe3c632Sopenharmony_ci
352ffe3c632Sopenharmony_ci    #########################################################
353ffe3c632Sopenharmony_ci    # Test bool field.
354ffe3c632Sopenharmony_ci    #########################################################
355ffe3c632Sopenharmony_ci
356ffe3c632Sopenharmony_ci    public function testBoolField()
357ffe3c632Sopenharmony_ci    {
358ffe3c632Sopenharmony_ci        $m = new TestMessage();
359ffe3c632Sopenharmony_ci
360ffe3c632Sopenharmony_ci        // Set bool.
361ffe3c632Sopenharmony_ci        $m->setOptionalBool(true);
362ffe3c632Sopenharmony_ci        $this->assertSame(true, $m->getOptionalBool());
363ffe3c632Sopenharmony_ci
364ffe3c632Sopenharmony_ci        // Set integer.
365ffe3c632Sopenharmony_ci        $m->setOptionalBool(-1);
366ffe3c632Sopenharmony_ci        $this->assertSame(true, $m->getOptionalBool());
367ffe3c632Sopenharmony_ci
368ffe3c632Sopenharmony_ci        // Set float.
369ffe3c632Sopenharmony_ci        $m->setOptionalBool(1.1);
370ffe3c632Sopenharmony_ci        $this->assertSame(true, $m->getOptionalBool());
371ffe3c632Sopenharmony_ci
372ffe3c632Sopenharmony_ci        // Set string.
373ffe3c632Sopenharmony_ci        $m->setOptionalBool('');
374ffe3c632Sopenharmony_ci        $this->assertSame(false, $m->getOptionalBool());
375ffe3c632Sopenharmony_ci    }
376ffe3c632Sopenharmony_ci
377ffe3c632Sopenharmony_ci    #########################################################
378ffe3c632Sopenharmony_ci    # Test string field.
379ffe3c632Sopenharmony_ci    #########################################################
380ffe3c632Sopenharmony_ci
381ffe3c632Sopenharmony_ci    public function testStringField()
382ffe3c632Sopenharmony_ci    {
383ffe3c632Sopenharmony_ci        $m = new TestMessage();
384ffe3c632Sopenharmony_ci
385ffe3c632Sopenharmony_ci        // Set string.
386ffe3c632Sopenharmony_ci        $m->setOptionalString('abc');
387ffe3c632Sopenharmony_ci        $this->assertSame('abc', $m->getOptionalString());
388ffe3c632Sopenharmony_ci
389ffe3c632Sopenharmony_ci        // Set integer.
390ffe3c632Sopenharmony_ci        $m->setOptionalString(1);
391ffe3c632Sopenharmony_ci        $this->assertSame('1', $m->getOptionalString());
392ffe3c632Sopenharmony_ci
393ffe3c632Sopenharmony_ci        // Set double.
394ffe3c632Sopenharmony_ci        $m->setOptionalString(1.1);
395ffe3c632Sopenharmony_ci        $this->assertSame('1.1', $m->getOptionalString());
396ffe3c632Sopenharmony_ci
397ffe3c632Sopenharmony_ci        // Set bool.
398ffe3c632Sopenharmony_ci        $m->setOptionalString(true);
399ffe3c632Sopenharmony_ci        $this->assertSame('1', $m->getOptionalString());
400ffe3c632Sopenharmony_ci    }
401ffe3c632Sopenharmony_ci
402ffe3c632Sopenharmony_ci    #########################################################
403ffe3c632Sopenharmony_ci    # Test bytes field.
404ffe3c632Sopenharmony_ci    #########################################################
405ffe3c632Sopenharmony_ci
406ffe3c632Sopenharmony_ci    public function testBytesField()
407ffe3c632Sopenharmony_ci    {
408ffe3c632Sopenharmony_ci        $m = new TestMessage();
409ffe3c632Sopenharmony_ci
410ffe3c632Sopenharmony_ci        // Set string.
411ffe3c632Sopenharmony_ci        $m->setOptionalBytes('abc');
412ffe3c632Sopenharmony_ci        $this->assertSame('abc', $m->getOptionalBytes());
413ffe3c632Sopenharmony_ci
414ffe3c632Sopenharmony_ci        // Set integer.
415ffe3c632Sopenharmony_ci        $m->setOptionalBytes(1);
416ffe3c632Sopenharmony_ci        $this->assertSame('1', $m->getOptionalBytes());
417ffe3c632Sopenharmony_ci
418ffe3c632Sopenharmony_ci        // Set double.
419ffe3c632Sopenharmony_ci        $m->setOptionalBytes(1.1);
420ffe3c632Sopenharmony_ci        $this->assertSame('1.1', $m->getOptionalBytes());
421ffe3c632Sopenharmony_ci
422ffe3c632Sopenharmony_ci        // Set bool.
423ffe3c632Sopenharmony_ci        $m->setOptionalBytes(true);
424ffe3c632Sopenharmony_ci        $this->assertSame('1', $m->getOptionalBytes());
425ffe3c632Sopenharmony_ci    }
426ffe3c632Sopenharmony_ci
427ffe3c632Sopenharmony_ci      public function testBytesFieldInvalidUTF8Success()
428ffe3c632Sopenharmony_ci      {
429ffe3c632Sopenharmony_ci          $m = new TestMessage();
430ffe3c632Sopenharmony_ci          $hex = hex2bin("ff");
431ffe3c632Sopenharmony_ci          $m->setOptionalBytes($hex);
432ffe3c632Sopenharmony_ci          $this->assertTrue(true);
433ffe3c632Sopenharmony_ci      }
434ffe3c632Sopenharmony_ci
435ffe3c632Sopenharmony_ci    #########################################################
436ffe3c632Sopenharmony_ci    # Test message field.
437ffe3c632Sopenharmony_ci    #########################################################
438ffe3c632Sopenharmony_ci
439ffe3c632Sopenharmony_ci    public function testMessageField()
440ffe3c632Sopenharmony_ci    {
441ffe3c632Sopenharmony_ci        $m = new TestMessage();
442ffe3c632Sopenharmony_ci
443ffe3c632Sopenharmony_ci        $sub_m = new Sub();
444ffe3c632Sopenharmony_ci        $sub_m->setA(1);
445ffe3c632Sopenharmony_ci        $m->setOptionalMessage($sub_m);
446ffe3c632Sopenharmony_ci        $this->assertSame(1, $m->getOptionalMessage()->getA());
447ffe3c632Sopenharmony_ci
448ffe3c632Sopenharmony_ci        $null = null;
449ffe3c632Sopenharmony_ci        $m->setOptionalMessage($null);
450ffe3c632Sopenharmony_ci        $this->assertNull($m->getOptionalMessage());
451ffe3c632Sopenharmony_ci    }
452ffe3c632Sopenharmony_ci
453ffe3c632Sopenharmony_ci    public function testLegacyMessageField()
454ffe3c632Sopenharmony_ci    {
455ffe3c632Sopenharmony_ci        $m = new TestMessage();
456ffe3c632Sopenharmony_ci
457ffe3c632Sopenharmony_ci        $sub_m = new TestMessage_Sub();
458ffe3c632Sopenharmony_ci        $sub_m->setA(1);
459ffe3c632Sopenharmony_ci        $m->setOptionalMessage($sub_m);
460ffe3c632Sopenharmony_ci        $this->assertSame(1, $m->getOptionalMessage()->getA());
461ffe3c632Sopenharmony_ci
462ffe3c632Sopenharmony_ci        $null = null;
463ffe3c632Sopenharmony_ci        $m->setOptionalMessage($null);
464ffe3c632Sopenharmony_ci        $this->assertNull($m->getOptionalMessage());
465ffe3c632Sopenharmony_ci    }
466ffe3c632Sopenharmony_ci
467ffe3c632Sopenharmony_ci    public function testLegacyTypehintWithNestedMessages()
468ffe3c632Sopenharmony_ci    {
469ffe3c632Sopenharmony_ci        $this->legacyMessage(new TestLegacyMessage\NestedMessage);
470ffe3c632Sopenharmony_ci    }
471ffe3c632Sopenharmony_ci
472ffe3c632Sopenharmony_ci    private function legacyMessage(TestLegacyMessage_NestedMessage $sub)
473ffe3c632Sopenharmony_ci    {
474ffe3c632Sopenharmony_ci        // If we made it here without a PHP Fatal error, the typehint worked
475ffe3c632Sopenharmony_ci        $this->assertTrue(true);
476ffe3c632Sopenharmony_ci    }
477ffe3c632Sopenharmony_ci
478ffe3c632Sopenharmony_ci    #########################################################
479ffe3c632Sopenharmony_ci    # Test repeated field.
480ffe3c632Sopenharmony_ci    #########################################################
481ffe3c632Sopenharmony_ci
482ffe3c632Sopenharmony_ci    public function testRepeatedField()
483ffe3c632Sopenharmony_ci    {
484ffe3c632Sopenharmony_ci        $m = new TestMessage();
485ffe3c632Sopenharmony_ci
486ffe3c632Sopenharmony_ci        $repeated_int32 = new RepeatedField(GPBType::INT32);
487ffe3c632Sopenharmony_ci        $m->setRepeatedInt32($repeated_int32);
488ffe3c632Sopenharmony_ci        $this->assertSame($repeated_int32, $m->getRepeatedInt32());
489ffe3c632Sopenharmony_ci    }
490ffe3c632Sopenharmony_ci
491ffe3c632Sopenharmony_ci    public function testRepeatedFieldViaArray()
492ffe3c632Sopenharmony_ci    {
493ffe3c632Sopenharmony_ci        $m = new TestMessage();
494ffe3c632Sopenharmony_ci
495ffe3c632Sopenharmony_ci        $arr = array();
496ffe3c632Sopenharmony_ci        $m->setRepeatedInt32($arr);
497ffe3c632Sopenharmony_ci        $this->assertSame(0, count($m->getRepeatedInt32()));
498ffe3c632Sopenharmony_ci
499ffe3c632Sopenharmony_ci        $arr = array(1, 2.1, "3");
500ffe3c632Sopenharmony_ci        $m->setRepeatedInt32($arr);
501ffe3c632Sopenharmony_ci        $this->assertTrue($m->getRepeatedInt32() instanceof RepeatedField);
502ffe3c632Sopenharmony_ci        $this->assertSame("Google\Protobuf\Internal\RepeatedField",
503ffe3c632Sopenharmony_ci                          get_class($m->getRepeatedInt32()));
504ffe3c632Sopenharmony_ci        $this->assertSame(3, count($m->getRepeatedInt32()));
505ffe3c632Sopenharmony_ci        $this->assertSame(1, $m->getRepeatedInt32()[0]);
506ffe3c632Sopenharmony_ci        $this->assertSame(2, $m->getRepeatedInt32()[1]);
507ffe3c632Sopenharmony_ci        $this->assertSame(3, $m->getRepeatedInt32()[2]);
508ffe3c632Sopenharmony_ci        $this->assertFalse($arr instanceof RepeatedField);
509ffe3c632Sopenharmony_ci    }
510ffe3c632Sopenharmony_ci
511ffe3c632Sopenharmony_ci    #########################################################
512ffe3c632Sopenharmony_ci    # Test map field.
513ffe3c632Sopenharmony_ci    #########################################################
514ffe3c632Sopenharmony_ci
515ffe3c632Sopenharmony_ci    public function testMapField()
516ffe3c632Sopenharmony_ci    {
517ffe3c632Sopenharmony_ci        $m = new TestMessage();
518ffe3c632Sopenharmony_ci
519ffe3c632Sopenharmony_ci        $map_int32_int32 = new MapField(GPBType::INT32, GPBType::INT32);
520ffe3c632Sopenharmony_ci        $m->setMapInt32Int32($map_int32_int32);
521ffe3c632Sopenharmony_ci        $this->assertSame($map_int32_int32, $m->getMapInt32Int32());
522ffe3c632Sopenharmony_ci    }
523ffe3c632Sopenharmony_ci
524ffe3c632Sopenharmony_ci    public function testMapFieldViaArray()
525ffe3c632Sopenharmony_ci    {
526ffe3c632Sopenharmony_ci        $m = new TestMessage();
527ffe3c632Sopenharmony_ci
528ffe3c632Sopenharmony_ci        $dict = array();
529ffe3c632Sopenharmony_ci        $m->setMapInt32Int32($dict);
530ffe3c632Sopenharmony_ci        $this->assertSame(0, count($m->getMapInt32Int32()));
531ffe3c632Sopenharmony_ci
532ffe3c632Sopenharmony_ci        $dict = array(5 => 5, 6.1 => 6.1, "7" => "7");
533ffe3c632Sopenharmony_ci        $m->setMapInt32Int32($dict);
534ffe3c632Sopenharmony_ci        $this->assertTrue($m->getMapInt32Int32() instanceof MapField);
535ffe3c632Sopenharmony_ci        $this->assertSame(3, count($m->getMapInt32Int32()));
536ffe3c632Sopenharmony_ci        $this->assertSame(5, $m->getMapInt32Int32()[5]);
537ffe3c632Sopenharmony_ci        $this->assertSame(6, $m->getMapInt32Int32()[6]);
538ffe3c632Sopenharmony_ci        $this->assertSame(7, $m->getMapInt32Int32()[7]);
539ffe3c632Sopenharmony_ci        $this->assertFalse($dict instanceof MapField);
540ffe3c632Sopenharmony_ci    }
541ffe3c632Sopenharmony_ci
542ffe3c632Sopenharmony_ci    #########################################################
543ffe3c632Sopenharmony_ci    # Test oneof field.
544ffe3c632Sopenharmony_ci    #########################################################
545ffe3c632Sopenharmony_ci
546ffe3c632Sopenharmony_ci    public function testOneofField() {
547ffe3c632Sopenharmony_ci        $m = new TestMessage();
548ffe3c632Sopenharmony_ci
549ffe3c632Sopenharmony_ci        $this->assertSame("", $m->getMyOneof());
550ffe3c632Sopenharmony_ci
551ffe3c632Sopenharmony_ci        $m->setOneofInt32(1);
552ffe3c632Sopenharmony_ci        $this->assertSame(1, $m->getOneofInt32());
553ffe3c632Sopenharmony_ci        $this->assertSame(0.0, $m->getOneofFloat());
554ffe3c632Sopenharmony_ci        $this->assertSame('', $m->getOneofString());
555ffe3c632Sopenharmony_ci        $this->assertSame(NULL, $m->getOneofMessage());
556ffe3c632Sopenharmony_ci        $this->assertSame("oneof_int32", $m->getMyOneof());
557ffe3c632Sopenharmony_ci
558ffe3c632Sopenharmony_ci        $m->setOneofFloat(2.0);
559ffe3c632Sopenharmony_ci        $this->assertSame(0, $m->getOneofInt32());
560ffe3c632Sopenharmony_ci        $this->assertSame(2.0, $m->getOneofFloat());
561ffe3c632Sopenharmony_ci        $this->assertSame('', $m->getOneofString());
562ffe3c632Sopenharmony_ci        $this->assertSame(NULL, $m->getOneofMessage());
563ffe3c632Sopenharmony_ci        $this->assertSame("oneof_float", $m->getMyOneof());
564ffe3c632Sopenharmony_ci
565ffe3c632Sopenharmony_ci        $m->setOneofString('abc');
566ffe3c632Sopenharmony_ci        $this->assertSame(0, $m->getOneofInt32());
567ffe3c632Sopenharmony_ci        $this->assertSame(0.0, $m->getOneofFloat());
568ffe3c632Sopenharmony_ci        $this->assertSame('abc', $m->getOneofString());
569ffe3c632Sopenharmony_ci        $this->assertSame(NULL, $m->getOneofMessage());
570ffe3c632Sopenharmony_ci        $this->assertSame("oneof_string", $m->getMyOneof());
571ffe3c632Sopenharmony_ci
572ffe3c632Sopenharmony_ci        $sub_m = new Sub();
573ffe3c632Sopenharmony_ci        $sub_m->setA(1);
574ffe3c632Sopenharmony_ci        $m->setOneofMessage($sub_m);
575ffe3c632Sopenharmony_ci        $this->assertSame(0, $m->getOneofInt32());
576ffe3c632Sopenharmony_ci        $this->assertSame(0.0, $m->getOneofFloat());
577ffe3c632Sopenharmony_ci        $this->assertSame('', $m->getOneofString());
578ffe3c632Sopenharmony_ci        $this->assertSame(1, $m->getOneofMessage()->getA());
579ffe3c632Sopenharmony_ci        $this->assertSame("oneof_message", $m->getMyOneof());
580ffe3c632Sopenharmony_ci    }
581ffe3c632Sopenharmony_ci
582ffe3c632Sopenharmony_ci    #########################################################
583ffe3c632Sopenharmony_ci    # Test clear method.
584ffe3c632Sopenharmony_ci    #########################################################
585ffe3c632Sopenharmony_ci
586ffe3c632Sopenharmony_ci    public function testMessageClear()
587ffe3c632Sopenharmony_ci    {
588ffe3c632Sopenharmony_ci        $m = new TestMessage();
589ffe3c632Sopenharmony_ci        $this->setFields($m);
590ffe3c632Sopenharmony_ci        $this->expectFields($m);
591ffe3c632Sopenharmony_ci        $m->clear();
592ffe3c632Sopenharmony_ci        $this->expectEmptyFields($m);
593ffe3c632Sopenharmony_ci    }
594ffe3c632Sopenharmony_ci
595ffe3c632Sopenharmony_ci    #########################################################
596ffe3c632Sopenharmony_ci    # Test mergeFrom method.
597ffe3c632Sopenharmony_ci    #########################################################
598ffe3c632Sopenharmony_ci
599ffe3c632Sopenharmony_ci    public function testMessageMergeFrom()
600ffe3c632Sopenharmony_ci    {
601ffe3c632Sopenharmony_ci        $m = new TestMessage();
602ffe3c632Sopenharmony_ci        $this->setFields($m);
603ffe3c632Sopenharmony_ci        $this->expectFields($m);
604ffe3c632Sopenharmony_ci        $arr = $m->getOptionalMessage()->getB();
605ffe3c632Sopenharmony_ci        $arr[] = 1;
606ffe3c632Sopenharmony_ci
607ffe3c632Sopenharmony_ci        $n = new TestMessage();
608ffe3c632Sopenharmony_ci
609ffe3c632Sopenharmony_ci        // Singular
610ffe3c632Sopenharmony_ci        $n->setOptionalInt32(100);
611ffe3c632Sopenharmony_ci        $sub1 = new Sub();
612ffe3c632Sopenharmony_ci        $sub1->setA(101);
613ffe3c632Sopenharmony_ci
614ffe3c632Sopenharmony_ci        $b = $sub1->getB();
615ffe3c632Sopenharmony_ci        $b[] = 102;
616ffe3c632Sopenharmony_ci        $sub1->setB($b);
617ffe3c632Sopenharmony_ci
618ffe3c632Sopenharmony_ci        $n->setOptionalMessage($sub1);
619ffe3c632Sopenharmony_ci
620ffe3c632Sopenharmony_ci        // Repeated
621ffe3c632Sopenharmony_ci        $repeatedInt32 = $n->getRepeatedInt32();
622ffe3c632Sopenharmony_ci        $repeatedInt32[] = 200;
623ffe3c632Sopenharmony_ci        $n->setRepeatedInt32($repeatedInt32);
624ffe3c632Sopenharmony_ci
625ffe3c632Sopenharmony_ci        $repeatedString = $n->getRepeatedString();
626ffe3c632Sopenharmony_ci        $repeatedString[] = 'abc';
627ffe3c632Sopenharmony_ci        $n->setRepeatedString($repeatedString);
628ffe3c632Sopenharmony_ci
629ffe3c632Sopenharmony_ci        $sub2 = new Sub();
630ffe3c632Sopenharmony_ci        $sub2->setA(201);
631ffe3c632Sopenharmony_ci        $repeatedMessage = $n->getRepeatedMessage();
632ffe3c632Sopenharmony_ci        $repeatedMessage[] = $sub2;
633ffe3c632Sopenharmony_ci        $n->setRepeatedMessage($repeatedMessage);
634ffe3c632Sopenharmony_ci
635ffe3c632Sopenharmony_ci        // Map
636ffe3c632Sopenharmony_ci        $mapInt32Int32 = $n->getMapInt32Int32();
637ffe3c632Sopenharmony_ci        $mapInt32Int32[1] = 300;
638ffe3c632Sopenharmony_ci        $mapInt32Int32[-62] = 301;
639ffe3c632Sopenharmony_ci        $n->setMapInt32Int32($mapInt32Int32);
640ffe3c632Sopenharmony_ci
641ffe3c632Sopenharmony_ci        $mapStringString = $n->getMapStringString();
642ffe3c632Sopenharmony_ci        $mapStringString['def'] = 'def';
643ffe3c632Sopenharmony_ci        $n->setMapStringString($mapStringString);
644ffe3c632Sopenharmony_ci
645ffe3c632Sopenharmony_ci        $mapInt32Message = $n->getMapInt32Message();
646ffe3c632Sopenharmony_ci        $mapInt32Message[1] = new Sub();
647ffe3c632Sopenharmony_ci        $mapInt32Message[1]->setA(302);
648ffe3c632Sopenharmony_ci        $mapInt32Message[2] = new Sub();
649ffe3c632Sopenharmony_ci        $mapInt32Message[2]->setA(303);
650ffe3c632Sopenharmony_ci        $n->setMapInt32Message($mapInt32Message);
651ffe3c632Sopenharmony_ci
652ffe3c632Sopenharmony_ci        $m->mergeFrom($n);
653ffe3c632Sopenharmony_ci
654ffe3c632Sopenharmony_ci        $this->assertSame(100, $m->getOptionalInt32());
655ffe3c632Sopenharmony_ci        $this->assertSame(42, $m->getOptionalUint32());
656ffe3c632Sopenharmony_ci        $this->assertSame(101, $m->getOptionalMessage()->getA());
657ffe3c632Sopenharmony_ci        $this->assertSame(2, count($m->getOptionalMessage()->getB()));
658ffe3c632Sopenharmony_ci        $this->assertSame(1, $m->getOptionalMessage()->getB()[0]);
659ffe3c632Sopenharmony_ci        $this->assertSame(102, $m->getOptionalMessage()->getB()[1]);
660ffe3c632Sopenharmony_ci
661ffe3c632Sopenharmony_ci        $this->assertSame(3, count($m->getRepeatedInt32()));
662ffe3c632Sopenharmony_ci        $this->assertSame(200, $m->getRepeatedInt32()[2]);
663ffe3c632Sopenharmony_ci        $this->assertSame(2, count($m->getRepeatedUint32()));
664ffe3c632Sopenharmony_ci        $this->assertSame(3, count($m->getRepeatedString()));
665ffe3c632Sopenharmony_ci        $this->assertSame('abc', $m->getRepeatedString()[2]);
666ffe3c632Sopenharmony_ci        $this->assertSame(3, count($m->getRepeatedMessage()));
667ffe3c632Sopenharmony_ci        $this->assertSame(201, $m->getRepeatedMessage()[2]->getA());
668ffe3c632Sopenharmony_ci
669ffe3c632Sopenharmony_ci        $this->assertSame(2, count($m->getMapInt32Int32()));
670ffe3c632Sopenharmony_ci        $this->assertSame(300, $m->getMapInt32Int32()[1]);
671ffe3c632Sopenharmony_ci        $this->assertSame(301, $m->getMapInt32Int32()[-62]);
672ffe3c632Sopenharmony_ci        $this->assertSame(1, count($m->getMapUint32Uint32()));
673ffe3c632Sopenharmony_ci        $this->assertSame(2, count($m->getMapStringString()));
674ffe3c632Sopenharmony_ci        $this->assertSame('def', $m->getMapStringString()['def']);
675ffe3c632Sopenharmony_ci
676ffe3c632Sopenharmony_ci        $this->assertSame(2, count($m->getMapInt32Message()));
677ffe3c632Sopenharmony_ci        $this->assertSame(302, $m->getMapInt32Message()[1]->getA());
678ffe3c632Sopenharmony_ci        $this->assertSame(303, $m->getMapInt32Message()[2]->getA());
679ffe3c632Sopenharmony_ci
680ffe3c632Sopenharmony_ci        $this->assertSame("", $m->getMyOneof());
681ffe3c632Sopenharmony_ci
682ffe3c632Sopenharmony_ci        // Check sub-messages are copied by value.
683ffe3c632Sopenharmony_ci        $n->getOptionalMessage()->setA(-101);
684ffe3c632Sopenharmony_ci        $this->assertSame(101, $m->getOptionalMessage()->getA());
685ffe3c632Sopenharmony_ci
686ffe3c632Sopenharmony_ci        $repeatedMessage = $n->getRepeatedMessage();
687ffe3c632Sopenharmony_ci        $repeatedMessage[0]->setA(-201);
688ffe3c632Sopenharmony_ci        $n->setRepeatedMessage($repeatedMessage);
689ffe3c632Sopenharmony_ci        $this->assertSame(201, $m->getRepeatedMessage()[2]->getA());
690ffe3c632Sopenharmony_ci
691ffe3c632Sopenharmony_ci        $mapInt32Message = $n->getMapInt32Message();
692ffe3c632Sopenharmony_ci        $mapInt32Message[1]->setA(-302);
693ffe3c632Sopenharmony_ci        $n->setMapInt32Message($mapInt32Message);
694ffe3c632Sopenharmony_ci
695ffe3c632Sopenharmony_ci        $this->assertSame(302, $m->getMapInt32Message()[1]->getA());
696ffe3c632Sopenharmony_ci
697ffe3c632Sopenharmony_ci        // Test merge oneof.
698ffe3c632Sopenharmony_ci        $m = new TestMessage();
699ffe3c632Sopenharmony_ci
700ffe3c632Sopenharmony_ci        $n = new TestMessage();
701ffe3c632Sopenharmony_ci        $n->setOneofInt32(1);
702ffe3c632Sopenharmony_ci        $m->mergeFrom($n);
703ffe3c632Sopenharmony_ci        $this->assertSame(1, $m->getOneofInt32());
704ffe3c632Sopenharmony_ci
705ffe3c632Sopenharmony_ci        $sub = new Sub();
706ffe3c632Sopenharmony_ci        $n->setOneofMessage($sub);
707ffe3c632Sopenharmony_ci        $n->getOneofMessage()->setA(400);
708ffe3c632Sopenharmony_ci        $m->mergeFrom($n);
709ffe3c632Sopenharmony_ci        $this->assertSame(400, $m->getOneofMessage()->getA());
710ffe3c632Sopenharmony_ci        $n->getOneofMessage()->setA(-400);
711ffe3c632Sopenharmony_ci        $this->assertSame(400, $m->getOneofMessage()->getA());
712ffe3c632Sopenharmony_ci
713ffe3c632Sopenharmony_ci        // Test all fields
714ffe3c632Sopenharmony_ci        $m = new TestMessage();
715ffe3c632Sopenharmony_ci        $n = new TestMessage();
716ffe3c632Sopenharmony_ci        $this->setFields($m);
717ffe3c632Sopenharmony_ci        $n->mergeFrom($m);
718ffe3c632Sopenharmony_ci        $this->expectFields($n);
719ffe3c632Sopenharmony_ci    }
720ffe3c632Sopenharmony_ci
721ffe3c632Sopenharmony_ci    #########################################################
722ffe3c632Sopenharmony_ci    # Test message/enum without namespace.
723ffe3c632Sopenharmony_ci    #########################################################
724ffe3c632Sopenharmony_ci
725ffe3c632Sopenharmony_ci    public function testMessageWithoutNamespace()
726ffe3c632Sopenharmony_ci    {
727ffe3c632Sopenharmony_ci        $m = new TestMessage();
728ffe3c632Sopenharmony_ci        $n = new NoNameSpaceMessage();
729ffe3c632Sopenharmony_ci        $m->setOptionalNoNamespaceMessage($n);
730ffe3c632Sopenharmony_ci        $repeatedNoNamespaceMessage = $m->getRepeatedNoNamespaceMessage();
731ffe3c632Sopenharmony_ci        $repeatedNoNamespaceMessage[] = new NoNameSpaceMessage();
732ffe3c632Sopenharmony_ci        $m->setRepeatedNoNamespaceMessage($repeatedNoNamespaceMessage);
733ffe3c632Sopenharmony_ci
734ffe3c632Sopenharmony_ci        // test nested messages
735ffe3c632Sopenharmony_ci        $sub = new NoNamespaceMessage\NestedMessage();
736ffe3c632Sopenharmony_ci        $n->setNestedMessage($sub);
737ffe3c632Sopenharmony_ci
738ffe3c632Sopenharmony_ci        $this->assertTrue(true);
739ffe3c632Sopenharmony_ci    }
740ffe3c632Sopenharmony_ci
741ffe3c632Sopenharmony_ci    public function testEnumWithoutNamespace()
742ffe3c632Sopenharmony_ci    {
743ffe3c632Sopenharmony_ci        $m = new TestMessage();
744ffe3c632Sopenharmony_ci        $m->setOptionalNoNamespaceEnum(NoNameSpaceEnum::VALUE_A);
745ffe3c632Sopenharmony_ci        $repeatedNoNamespaceEnum = $m->getRepeatedNoNamespaceEnum();
746ffe3c632Sopenharmony_ci        $repeatedNoNamespaceEnum[] = NoNameSpaceEnum::VALUE_A;
747ffe3c632Sopenharmony_ci        $m->setRepeatedNoNamespaceEnum($repeatedNoNamespaceEnum);
748ffe3c632Sopenharmony_ci        $this->assertTrue(true);
749ffe3c632Sopenharmony_ci    }
750ffe3c632Sopenharmony_ci
751ffe3c632Sopenharmony_ci    #########################################################
752ffe3c632Sopenharmony_ci    # Test message with given namespace.
753ffe3c632Sopenharmony_ci    #########################################################
754ffe3c632Sopenharmony_ci
755ffe3c632Sopenharmony_ci    public function testNestedMessagesAndEnums()
756ffe3c632Sopenharmony_ci    {
757ffe3c632Sopenharmony_ci        $m = new TestMessage();
758ffe3c632Sopenharmony_ci        $n = new TestMessage\Sub();
759ffe3c632Sopenharmony_ci        $m->setOptionalMessage($n);
760ffe3c632Sopenharmony_ci        $m->setOptionalNestedEnum(TestMessage\NestedEnum::ZERO);
761ffe3c632Sopenharmony_ci        $this->assertSame($n, $m->getOptionalMessage());
762ffe3c632Sopenharmony_ci        $this->assertSame(TestMessage\NestedEnum::ZERO, $m->getOptionalNestedEnum());
763ffe3c632Sopenharmony_ci    }
764ffe3c632Sopenharmony_ci
765ffe3c632Sopenharmony_ci    public function testMessagesAndEnumsWithPrefix()
766ffe3c632Sopenharmony_ci    {
767ffe3c632Sopenharmony_ci        // Test message prefix
768ffe3c632Sopenharmony_ci        $m = new TestIncludePrefixMessage();
769ffe3c632Sopenharmony_ci        $n = new PrefixTestPrefix();
770ffe3c632Sopenharmony_ci        $n->setA(1);
771ffe3c632Sopenharmony_ci        $m->setPrefixMessage($n);
772ffe3c632Sopenharmony_ci        $this->assertSame(1, $m->getPrefixMessage()->getA());
773ffe3c632Sopenharmony_ci
774ffe3c632Sopenharmony_ci        // Test nested message prefix
775ffe3c632Sopenharmony_ci        $o = new PrefixTestPrefix();
776ffe3c632Sopenharmony_ci        $p = new PrefixTestPrefix\PrefixNestedMessage();
777ffe3c632Sopenharmony_ci        $o->setNestedMessage($p);
778ffe3c632Sopenharmony_ci        $o->setNestedEnum(PrefixTestPrefix\PrefixNestedEnum::ZERO);
779ffe3c632Sopenharmony_ci        $this->assertSame($p, $o->getNestedMessage());
780ffe3c632Sopenharmony_ci        $this->assertSame(PrefixTestPrefix\PrefixNestedEnum::ZERO, $o->getNestedEnum());
781ffe3c632Sopenharmony_ci    }
782ffe3c632Sopenharmony_ci
783ffe3c632Sopenharmony_ci    public function testMessagesAndEnumsWithPhpNamespace()
784ffe3c632Sopenharmony_ci    {
785ffe3c632Sopenharmony_ci        $m = new TestNamespace();
786ffe3c632Sopenharmony_ci        $n = new TestNamespace\NestedMessage();
787ffe3c632Sopenharmony_ci        $m->setNestedMessage($n);
788ffe3c632Sopenharmony_ci        $m->setNestedEnum(TestNamespace\NestedEnum::ZERO);
789ffe3c632Sopenharmony_ci        $this->assertSame($n, $m->getNestedMessage());
790ffe3c632Sopenharmony_ci        $this->assertSame(TestNamespace\NestedEnum::ZERO, $m->getNestedEnum());
791ffe3c632Sopenharmony_ci    }
792ffe3c632Sopenharmony_ci
793ffe3c632Sopenharmony_ci    public function testMesssagesAndEnumsWithEmptyPhpNamespace()
794ffe3c632Sopenharmony_ci    {
795ffe3c632Sopenharmony_ci        $m = new TestEmptyNamespace();
796ffe3c632Sopenharmony_ci        $n = new TestEmptyNamespace\NestedMessage();
797ffe3c632Sopenharmony_ci        $m->setNestedMessage($n);
798ffe3c632Sopenharmony_ci        $m->setNestedEnum(TestEmptyNamespace\NestedEnum::ZERO);
799ffe3c632Sopenharmony_ci        $this->assertSame($n, $m->getNestedMessage());
800ffe3c632Sopenharmony_ci        $this->assertSame(TestEmptyNamespace\NestedEnum::ZERO, $m->getNestedEnum());
801ffe3c632Sopenharmony_ci    }
802ffe3c632Sopenharmony_ci
803ffe3c632Sopenharmony_ci    public function testMessagesAndEnumsWithNoNamespace()
804ffe3c632Sopenharmony_ci    {
805ffe3c632Sopenharmony_ci        $m = new NoNamespaceMessage();
806ffe3c632Sopenharmony_ci        $n = new NoNamespaceMessage\NestedMessage();
807ffe3c632Sopenharmony_ci        $m->setNestedMessage($n);
808ffe3c632Sopenharmony_ci        $m->setNestedEnum(NoNamespaceMessage\NestedEnum::ZERO);
809ffe3c632Sopenharmony_ci        $this->assertSame($n, $m->getNestedMessage());
810ffe3c632Sopenharmony_ci        $this->assertSame(NoNamespaceMessage\NestedEnum::ZERO, $m->getNestedEnum());
811ffe3c632Sopenharmony_ci    }
812ffe3c632Sopenharmony_ci
813ffe3c632Sopenharmony_ci    public function testReservedWordsInPackageName()
814ffe3c632Sopenharmony_ci    {
815ffe3c632Sopenharmony_ci        $m = new TestEmptyPackage();
816ffe3c632Sopenharmony_ci        $n = new TestEmptyPackage\NestedMessage();
817ffe3c632Sopenharmony_ci        $m->setNestedMessage($n);
818ffe3c632Sopenharmony_ci        $m->setNestedEnum(TestEmptyPackage\NestedEnum::ZERO);
819ffe3c632Sopenharmony_ci        $this->assertSame($n, $m->getNestedMessage());
820ffe3c632Sopenharmony_ci        $this->assertSame(TestEmptyPackage\NestedEnum::ZERO, $m->getNestedEnum());
821ffe3c632Sopenharmony_ci    }
822ffe3c632Sopenharmony_ci
823ffe3c632Sopenharmony_ci    public function testReservedWordsInNamespace()
824ffe3c632Sopenharmony_ci    {
825ffe3c632Sopenharmony_ci        $m = new TestNamespace();
826ffe3c632Sopenharmony_ci        $n = new TestNamespace\PBEmpty();
827ffe3c632Sopenharmony_ci        $o = new TestNamespace\PBEmpty\NestedMessage();
828ffe3c632Sopenharmony_ci        $n->setNestedMessage($o);
829ffe3c632Sopenharmony_ci        $n->setNestedEnum(TestNamespace\PBEmpty\NestedEnum::ZERO);
830ffe3c632Sopenharmony_ci        $m->setReservedName($n);
831ffe3c632Sopenharmony_ci        $this->assertSame($n, $m->getReservedName());
832ffe3c632Sopenharmony_ci        $this->assertSame($o, $n->getNestedMessage());
833ffe3c632Sopenharmony_ci        $this->assertSame(
834ffe3c632Sopenharmony_ci            TestNamespace\PBEmpty\NestedEnum::ZERO,
835ffe3c632Sopenharmony_ci            $n->getNestedEnum()
836ffe3c632Sopenharmony_ci        );
837ffe3c632Sopenharmony_ci    }
838ffe3c632Sopenharmony_ci
839ffe3c632Sopenharmony_ci    #########################################################
840ffe3c632Sopenharmony_ci    # Test prefix for reserved words.
841ffe3c632Sopenharmony_ci    #########################################################
842ffe3c632Sopenharmony_ci
843ffe3c632Sopenharmony_ci    public function testPrefixForReservedWords()
844ffe3c632Sopenharmony_ci    {
845ffe3c632Sopenharmony_ci        $m = new \Foo\TestMessage\PBEmpty();
846ffe3c632Sopenharmony_ci        $m = new \Foo\PBEmpty();
847ffe3c632Sopenharmony_ci        $m = new \PrefixEmpty();
848ffe3c632Sopenharmony_ci        $m = new \Foo\PBARRAY();
849ffe3c632Sopenharmony_ci
850ffe3c632Sopenharmony_ci        $m = new \Lower\PBabstract();
851ffe3c632Sopenharmony_ci        $m = new \Lower\PBand();
852ffe3c632Sopenharmony_ci        $m = new \Lower\PBarray();
853ffe3c632Sopenharmony_ci        $m = new \Lower\PBas();
854ffe3c632Sopenharmony_ci        $m = new \Lower\PBbreak();
855ffe3c632Sopenharmony_ci        $m = new \Lower\PBcallable();
856ffe3c632Sopenharmony_ci        $m = new \Lower\PBcase();
857ffe3c632Sopenharmony_ci        $m = new \Lower\PBcatch();
858ffe3c632Sopenharmony_ci        $m = new \Lower\PBclass();
859ffe3c632Sopenharmony_ci        $m = new \Lower\PBclone();
860ffe3c632Sopenharmony_ci        $m = new \Lower\PBconst();
861ffe3c632Sopenharmony_ci        $m = new \Lower\PBcontinue();
862ffe3c632Sopenharmony_ci        $m = new \Lower\PBdeclare();
863ffe3c632Sopenharmony_ci        $m = new \Lower\PBdefault();
864ffe3c632Sopenharmony_ci        $m = new \Lower\PBdie();
865ffe3c632Sopenharmony_ci        $m = new \Lower\PBdo();
866ffe3c632Sopenharmony_ci        $m = new \Lower\PBecho();
867ffe3c632Sopenharmony_ci        $m = new \Lower\PBelse();
868ffe3c632Sopenharmony_ci        $m = new \Lower\PBelseif();
869ffe3c632Sopenharmony_ci        $m = new \Lower\PBempty();
870ffe3c632Sopenharmony_ci        $m = new \Lower\PBenddeclare();
871ffe3c632Sopenharmony_ci        $m = new \Lower\PBendfor();
872ffe3c632Sopenharmony_ci        $m = new \Lower\PBendforeach();
873ffe3c632Sopenharmony_ci        $m = new \Lower\PBendif();
874ffe3c632Sopenharmony_ci        $m = new \Lower\PBendswitch();
875ffe3c632Sopenharmony_ci        $m = new \Lower\PBendwhile();
876ffe3c632Sopenharmony_ci        $m = new \Lower\PBeval();
877ffe3c632Sopenharmony_ci        $m = new \Lower\PBexit();
878ffe3c632Sopenharmony_ci        $m = new \Lower\PBextends();
879ffe3c632Sopenharmony_ci        $m = new \Lower\PBfinal();
880ffe3c632Sopenharmony_ci        $m = new \Lower\PBfor();
881ffe3c632Sopenharmony_ci        $m = new \Lower\PBforeach();
882ffe3c632Sopenharmony_ci        $m = new \Lower\PBfunction();
883ffe3c632Sopenharmony_ci        $m = new \Lower\PBglobal();
884ffe3c632Sopenharmony_ci        $m = new \Lower\PBgoto();
885ffe3c632Sopenharmony_ci        $m = new \Lower\PBif();
886ffe3c632Sopenharmony_ci        $m = new \Lower\PBimplements();
887ffe3c632Sopenharmony_ci        $m = new \Lower\PBinclude();
888ffe3c632Sopenharmony_ci        $m = new \Lower\PBinclude_once();
889ffe3c632Sopenharmony_ci        $m = new \Lower\PBinstanceof();
890ffe3c632Sopenharmony_ci        $m = new \Lower\PBinsteadof();
891ffe3c632Sopenharmony_ci        $m = new \Lower\PBinterface();
892ffe3c632Sopenharmony_ci        $m = new \Lower\PBisset();
893ffe3c632Sopenharmony_ci        $m = new \Lower\PBlist();
894ffe3c632Sopenharmony_ci        $m = new \Lower\PBnamespace();
895ffe3c632Sopenharmony_ci        $m = new \Lower\PBnew();
896ffe3c632Sopenharmony_ci        $m = new \Lower\PBor();
897ffe3c632Sopenharmony_ci        $m = new \Lower\PBprint();
898ffe3c632Sopenharmony_ci        $m = new \Lower\PBprivate();
899ffe3c632Sopenharmony_ci        $m = new \Lower\PBprotected();
900ffe3c632Sopenharmony_ci        $m = new \Lower\PBpublic();
901ffe3c632Sopenharmony_ci        $m = new \Lower\PBrequire();
902ffe3c632Sopenharmony_ci        $m = new \Lower\PBrequire_once();
903ffe3c632Sopenharmony_ci        $m = new \Lower\PBreturn();
904ffe3c632Sopenharmony_ci        $m = new \Lower\PBstatic();
905ffe3c632Sopenharmony_ci        $m = new \Lower\PBswitch();
906ffe3c632Sopenharmony_ci        $m = new \Lower\PBthrow();
907ffe3c632Sopenharmony_ci        $m = new \Lower\PBtrait();
908ffe3c632Sopenharmony_ci        $m = new \Lower\PBtry();
909ffe3c632Sopenharmony_ci        $m = new \Lower\PBunset();
910ffe3c632Sopenharmony_ci        $m = new \Lower\PBuse();
911ffe3c632Sopenharmony_ci        $m = new \Lower\PBvar();
912ffe3c632Sopenharmony_ci        $m = new \Lower\PBwhile();
913ffe3c632Sopenharmony_ci        $m = new \Lower\PBxor();
914ffe3c632Sopenharmony_ci        $m = new \Lower\PBint();
915ffe3c632Sopenharmony_ci        $m = new \Lower\PBfloat();
916ffe3c632Sopenharmony_ci        $m = new \Lower\PBbool();
917ffe3c632Sopenharmony_ci        $m = new \Lower\PBstring();
918ffe3c632Sopenharmony_ci        $m = new \Lower\PBtrue();
919ffe3c632Sopenharmony_ci        $m = new \Lower\PBfalse();
920ffe3c632Sopenharmony_ci        $m = new \Lower\PBnull();
921ffe3c632Sopenharmony_ci        $m = new \Lower\PBvoid();
922ffe3c632Sopenharmony_ci        $m = new \Lower\PBiterable();
923ffe3c632Sopenharmony_ci
924ffe3c632Sopenharmony_ci        $m = new \Upper\PBABSTRACT();
925ffe3c632Sopenharmony_ci        $m = new \Upper\PBAND();
926ffe3c632Sopenharmony_ci        $m = new \Upper\PBARRAY();
927ffe3c632Sopenharmony_ci        $m = new \Upper\PBAS();
928ffe3c632Sopenharmony_ci        $m = new \Upper\PBBREAK();
929ffe3c632Sopenharmony_ci        $m = new \Upper\PBCALLABLE();
930ffe3c632Sopenharmony_ci        $m = new \Upper\PBCASE();
931ffe3c632Sopenharmony_ci        $m = new \Upper\PBCATCH();
932ffe3c632Sopenharmony_ci        $m = new \Upper\PBCLASS();
933ffe3c632Sopenharmony_ci        $m = new \Upper\PBCLONE();
934ffe3c632Sopenharmony_ci        $m = new \Upper\PBCONST();
935ffe3c632Sopenharmony_ci        $m = new \Upper\PBCONTINUE();
936ffe3c632Sopenharmony_ci        $m = new \Upper\PBDECLARE();
937ffe3c632Sopenharmony_ci        $m = new \Upper\PBDEFAULT();
938ffe3c632Sopenharmony_ci        $m = new \Upper\PBDIE();
939ffe3c632Sopenharmony_ci        $m = new \Upper\PBDO();
940ffe3c632Sopenharmony_ci        $m = new \Upper\PBECHO();
941ffe3c632Sopenharmony_ci        $m = new \Upper\PBELSE();
942ffe3c632Sopenharmony_ci        $m = new \Upper\PBELSEIF();
943ffe3c632Sopenharmony_ci        $m = new \Upper\PBEMPTY();
944ffe3c632Sopenharmony_ci        $m = new \Upper\PBENDDECLARE();
945ffe3c632Sopenharmony_ci        $m = new \Upper\PBENDFOR();
946ffe3c632Sopenharmony_ci        $m = new \Upper\PBENDFOREACH();
947ffe3c632Sopenharmony_ci        $m = new \Upper\PBENDIF();
948ffe3c632Sopenharmony_ci        $m = new \Upper\PBENDSWITCH();
949ffe3c632Sopenharmony_ci        $m = new \Upper\PBENDWHILE();
950ffe3c632Sopenharmony_ci        $m = new \Upper\PBEVAL();
951ffe3c632Sopenharmony_ci        $m = new \Upper\PBEXIT();
952ffe3c632Sopenharmony_ci        $m = new \Upper\PBEXTENDS();
953ffe3c632Sopenharmony_ci        $m = new \Upper\PBFINAL();
954ffe3c632Sopenharmony_ci        $m = new \Upper\PBFOR();
955ffe3c632Sopenharmony_ci        $m = new \Upper\PBFOREACH();
956ffe3c632Sopenharmony_ci        $m = new \Upper\PBFUNCTION();
957ffe3c632Sopenharmony_ci        $m = new \Upper\PBGLOBAL();
958ffe3c632Sopenharmony_ci        $m = new \Upper\PBGOTO();
959ffe3c632Sopenharmony_ci        $m = new \Upper\PBIF();
960ffe3c632Sopenharmony_ci        $m = new \Upper\PBIMPLEMENTS();
961ffe3c632Sopenharmony_ci        $m = new \Upper\PBINCLUDE();
962ffe3c632Sopenharmony_ci        $m = new \Upper\PBINCLUDE_ONCE();
963ffe3c632Sopenharmony_ci        $m = new \Upper\PBINSTANCEOF();
964ffe3c632Sopenharmony_ci        $m = new \Upper\PBINSTEADOF();
965ffe3c632Sopenharmony_ci        $m = new \Upper\PBINTERFACE();
966ffe3c632Sopenharmony_ci        $m = new \Upper\PBISSET();
967ffe3c632Sopenharmony_ci        $m = new \Upper\PBLIST();
968ffe3c632Sopenharmony_ci        $m = new \Upper\PBNAMESPACE();
969ffe3c632Sopenharmony_ci        $m = new \Upper\PBNEW();
970ffe3c632Sopenharmony_ci        $m = new \Upper\PBOR();
971ffe3c632Sopenharmony_ci        $m = new \Upper\PBPRINT();
972ffe3c632Sopenharmony_ci        $m = new \Upper\PBPRIVATE();
973ffe3c632Sopenharmony_ci        $m = new \Upper\PBPROTECTED();
974ffe3c632Sopenharmony_ci        $m = new \Upper\PBPUBLIC();
975ffe3c632Sopenharmony_ci        $m = new \Upper\PBREQUIRE();
976ffe3c632Sopenharmony_ci        $m = new \Upper\PBREQUIRE_ONCE();
977ffe3c632Sopenharmony_ci        $m = new \Upper\PBRETURN();
978ffe3c632Sopenharmony_ci        $m = new \Upper\PBSTATIC();
979ffe3c632Sopenharmony_ci        $m = new \Upper\PBSWITCH();
980ffe3c632Sopenharmony_ci        $m = new \Upper\PBTHROW();
981ffe3c632Sopenharmony_ci        $m = new \Upper\PBTRAIT();
982ffe3c632Sopenharmony_ci        $m = new \Upper\PBTRY();
983ffe3c632Sopenharmony_ci        $m = new \Upper\PBUNSET();
984ffe3c632Sopenharmony_ci        $m = new \Upper\PBUSE();
985ffe3c632Sopenharmony_ci        $m = new \Upper\PBVAR();
986ffe3c632Sopenharmony_ci        $m = new \Upper\PBWHILE();
987ffe3c632Sopenharmony_ci        $m = new \Upper\PBXOR();
988ffe3c632Sopenharmony_ci        $m = new \Upper\PBINT();
989ffe3c632Sopenharmony_ci        $m = new \Upper\PBFLOAT();
990ffe3c632Sopenharmony_ci        $m = new \Upper\PBBOOL();
991ffe3c632Sopenharmony_ci        $m = new \Upper\PBSTRING();
992ffe3c632Sopenharmony_ci        $m = new \Upper\PBTRUE();
993ffe3c632Sopenharmony_ci        $m = new \Upper\PBFALSE();
994ffe3c632Sopenharmony_ci        $m = new \Upper\PBNULL();
995ffe3c632Sopenharmony_ci        $m = new \Upper\PBVOID();
996ffe3c632Sopenharmony_ci        $m = new \Upper\PBITERABLE();
997ffe3c632Sopenharmony_ci
998ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBabstract();
999ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBand();
1000ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBarray();
1001ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBas();
1002ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBbreak();
1003ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBcallable();
1004ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBcase();
1005ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBcatch();
1006ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBclass();
1007ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBclone();
1008ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBconst();
1009ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBcontinue();
1010ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBdeclare();
1011ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBdefault();
1012ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBdie();
1013ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBdo();
1014ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBecho();
1015ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBelse();
1016ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBelseif();
1017ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBempty();
1018ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBenddeclare();
1019ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBendfor();
1020ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBendforeach();
1021ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBendif();
1022ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBendswitch();
1023ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBendwhile();
1024ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBeval();
1025ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBexit();
1026ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBextends();
1027ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBfinal();
1028ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBfor();
1029ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBforeach();
1030ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBfunction();
1031ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBglobal();
1032ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBgoto();
1033ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBif();
1034ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBimplements();
1035ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBinclude();
1036ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBinclude_once();
1037ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBinstanceof();
1038ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBinsteadof();
1039ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBinterface();
1040ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBisset();
1041ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBlist();
1042ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBnamespace();
1043ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBnew();
1044ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBor();
1045ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBprint();
1046ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBprivate();
1047ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBprotected();
1048ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBpublic();
1049ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBrequire();
1050ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBrequire_once();
1051ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBreturn();
1052ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBstatic();
1053ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBswitch();
1054ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBthrow();
1055ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBtrait();
1056ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBtry();
1057ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBunset();
1058ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBuse();
1059ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBvar();
1060ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBwhile();
1061ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBxor();
1062ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBint();
1063ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBfloat();
1064ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBbool();
1065ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBstring();
1066ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBtrue();
1067ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBfalse();
1068ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBnull();
1069ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBvoid();
1070ffe3c632Sopenharmony_ci        $m = new \Lower_enum\PBiterable();
1071ffe3c632Sopenharmony_ci
1072ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBABSTRACT();
1073ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBAND();
1074ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBARRAY();
1075ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBAS();
1076ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBBREAK();
1077ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBCALLABLE();
1078ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBCASE();
1079ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBCATCH();
1080ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBCLASS();
1081ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBCLONE();
1082ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBCONST();
1083ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBCONTINUE();
1084ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBDECLARE();
1085ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBDEFAULT();
1086ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBDIE();
1087ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBDO();
1088ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBECHO();
1089ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBELSE();
1090ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBELSEIF();
1091ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBEMPTY();
1092ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBENDDECLARE();
1093ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBENDFOR();
1094ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBENDFOREACH();
1095ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBENDIF();
1096ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBENDSWITCH();
1097ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBENDWHILE();
1098ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBEVAL();
1099ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBEXIT();
1100ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBEXTENDS();
1101ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBFINAL();
1102ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBFOR();
1103ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBFOREACH();
1104ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBFUNCTION();
1105ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBGLOBAL();
1106ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBGOTO();
1107ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBIF();
1108ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBIMPLEMENTS();
1109ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBINCLUDE();
1110ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBINCLUDE_ONCE();
1111ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBINSTANCEOF();
1112ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBINSTEADOF();
1113ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBINTERFACE();
1114ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBISSET();
1115ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBLIST();
1116ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBNAMESPACE();
1117ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBNEW();
1118ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBOR();
1119ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBPRINT();
1120ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBPRIVATE();
1121ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBPROTECTED();
1122ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBPUBLIC();
1123ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBREQUIRE();
1124ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBREQUIRE_ONCE();
1125ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBRETURN();
1126ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBSTATIC();
1127ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBSWITCH();
1128ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBTHROW();
1129ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBTRAIT();
1130ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBTRY();
1131ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBUNSET();
1132ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBUSE();
1133ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBVAR();
1134ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBWHILE();
1135ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBXOR();
1136ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBINT();
1137ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBFLOAT();
1138ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBBOOL();
1139ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBSTRING();
1140ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBTRUE();
1141ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBFALSE();
1142ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBNULL();
1143ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBVOID();
1144ffe3c632Sopenharmony_ci        $m = new \Upper_enum\PBITERABLE();
1145ffe3c632Sopenharmony_ci
1146ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBabstract;
1147ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBand;
1148ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBarray;
1149ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBas;
1150ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBbreak;
1151ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBcallable;
1152ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBcase;
1153ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBcatch;
1154ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBclass;
1155ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBclone;
1156ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBconst;
1157ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBcontinue;
1158ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBdeclare;
1159ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBdefault;
1160ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBdie;
1161ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBdo;
1162ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBecho;
1163ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBelse;
1164ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBelseif;
1165ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBempty;
1166ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBenddeclare;
1167ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBendfor;
1168ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBendforeach;
1169ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBendif;
1170ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBendswitch;
1171ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBendwhile;
1172ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBeval;
1173ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBexit;
1174ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBextends;
1175ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBfinal;
1176ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBfor;
1177ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBforeach;
1178ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBfunction;
1179ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBglobal;
1180ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBgoto;
1181ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBif;
1182ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBimplements;
1183ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBinclude;
1184ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBinclude_once;
1185ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBinstanceof;
1186ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBinsteadof;
1187ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBinterface;
1188ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBisset;
1189ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBlist;
1190ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBnamespace;
1191ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBnew;
1192ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBor;
1193ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBprint;
1194ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBprivate;
1195ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBprotected;
1196ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBpublic;
1197ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBrequire;
1198ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBrequire_once;
1199ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBreturn;
1200ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBstatic;
1201ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBswitch;
1202ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBthrow;
1203ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBtrait;
1204ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBtry;
1205ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBunset;
1206ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBuse;
1207ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBvar;
1208ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBwhile;
1209ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::PBxor;
1210ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::int;
1211ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::float;
1212ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::bool;
1213ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::string;
1214ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::true;
1215ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::false;
1216ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::null;
1217ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::void;
1218ffe3c632Sopenharmony_ci        $m = \Lower_enum_value\NotAllowed::iterable;
1219ffe3c632Sopenharmony_ci
1220ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBABSTRACT;
1221ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBAND;
1222ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBARRAY;
1223ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBAS;
1224ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBBREAK;
1225ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBCALLABLE;
1226ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBCASE;
1227ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBCATCH;
1228ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBCLASS;
1229ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBCLONE;
1230ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBCONST;
1231ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBCONTINUE;
1232ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBDECLARE;
1233ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBDEFAULT;
1234ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBDIE;
1235ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBDO;
1236ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBECHO;
1237ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBELSE;
1238ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBELSEIF;
1239ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBEMPTY;
1240ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBENDDECLARE;
1241ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBENDFOR;
1242ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBENDFOREACH;
1243ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBENDIF;
1244ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBENDSWITCH;
1245ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBENDWHILE;
1246ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBEVAL;
1247ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBEXIT;
1248ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBEXTENDS;
1249ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBFINAL;
1250ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBFOR;
1251ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBFOREACH;
1252ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBFUNCTION;
1253ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBGLOBAL;
1254ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBGOTO;
1255ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBIF;
1256ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBIMPLEMENTS;
1257ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBINCLUDE;
1258ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBINCLUDE_ONCE;
1259ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBINSTANCEOF;
1260ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBINSTEADOF;
1261ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBINTERFACE;
1262ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBISSET;
1263ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBLIST;
1264ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBNAMESPACE;
1265ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBNEW;
1266ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBOR;
1267ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBPRINT;
1268ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBPRIVATE;
1269ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBPROTECTED;
1270ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBPUBLIC;
1271ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBREQUIRE;
1272ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBREQUIRE_ONCE;
1273ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBRETURN;
1274ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBSTATIC;
1275ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBSWITCH;
1276ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBTHROW;
1277ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBTRAIT;
1278ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBTRY;
1279ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBUNSET;
1280ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBUSE;
1281ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBVAR;
1282ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBWHILE;
1283ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::PBXOR;
1284ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::INT;
1285ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::FLOAT;
1286ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::BOOL;
1287ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::STRING;
1288ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::TRUE;
1289ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::FALSE;
1290ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::NULL;
1291ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::VOID;
1292ffe3c632Sopenharmony_ci        $m = \Upper_enum_value\NotAllowed::ITERABLE;
1293ffe3c632Sopenharmony_ci
1294ffe3c632Sopenharmony_ci        $this->assertTrue(true);
1295ffe3c632Sopenharmony_ci    }
1296ffe3c632Sopenharmony_ci
1297ffe3c632Sopenharmony_ci    #########################################################
1298ffe3c632Sopenharmony_ci    # Test fluent setters.
1299ffe3c632Sopenharmony_ci    #########################################################
1300ffe3c632Sopenharmony_ci
1301ffe3c632Sopenharmony_ci    public function testFluentSetters()
1302ffe3c632Sopenharmony_ci    {
1303ffe3c632Sopenharmony_ci        $m = (new TestMessage())
1304ffe3c632Sopenharmony_ci            ->setOptionalInt32(1)
1305ffe3c632Sopenharmony_ci            ->setOptionalUInt32(2);
1306ffe3c632Sopenharmony_ci        $this->assertSame(1, $m->getOptionalInt32());
1307ffe3c632Sopenharmony_ci        $this->assertSame(2, $m->getOptionalUInt32());
1308ffe3c632Sopenharmony_ci    }
1309ffe3c632Sopenharmony_ci
1310ffe3c632Sopenharmony_ci    #########################################################
1311ffe3c632Sopenharmony_ci    # Test Reverse Field Order.
1312ffe3c632Sopenharmony_ci    #########################################################
1313ffe3c632Sopenharmony_ci
1314ffe3c632Sopenharmony_ci    public function testReverseFieldOrder()
1315ffe3c632Sopenharmony_ci    {
1316ffe3c632Sopenharmony_ci        $m = new TestReverseFieldOrder();
1317ffe3c632Sopenharmony_ci        $m->setB("abc");
1318ffe3c632Sopenharmony_ci        $this->assertSame("abc", $m->getB());
1319ffe3c632Sopenharmony_ci        $this->assertNotSame("abc", $m->getA());
1320ffe3c632Sopenharmony_ci    }
1321ffe3c632Sopenharmony_ci
1322ffe3c632Sopenharmony_ci    #########################################################
1323ffe3c632Sopenharmony_ci    # Test Reverse Field Order.
1324ffe3c632Sopenharmony_ci    #########################################################
1325ffe3c632Sopenharmony_ci
1326ffe3c632Sopenharmony_ci    public function testLowerCase()
1327ffe3c632Sopenharmony_ci    {
1328ffe3c632Sopenharmony_ci        $m = new testLowerCaseMessage();
1329ffe3c632Sopenharmony_ci        $n = testLowerCaseEnum::VALUE;
1330ffe3c632Sopenharmony_ci        $this->assertTrue(true);
1331ffe3c632Sopenharmony_ci    }
1332ffe3c632Sopenharmony_ci
1333ffe3c632Sopenharmony_ci    #########################################################
1334ffe3c632Sopenharmony_ci    # Test Array Constructor.
1335ffe3c632Sopenharmony_ci    #########################################################
1336ffe3c632Sopenharmony_ci
1337ffe3c632Sopenharmony_ci    public function testArrayConstructor()
1338ffe3c632Sopenharmony_ci    {
1339ffe3c632Sopenharmony_ci        $m = new TestMessage([
1340ffe3c632Sopenharmony_ci            'optional_int32' => -42,
1341ffe3c632Sopenharmony_ci            'optional_int64' => -43,
1342ffe3c632Sopenharmony_ci            'optional_uint32' => 42,
1343ffe3c632Sopenharmony_ci            'optional_uint64' => 43,
1344ffe3c632Sopenharmony_ci            'optional_sint32' => -44,
1345ffe3c632Sopenharmony_ci            'optional_sint64' => -45,
1346ffe3c632Sopenharmony_ci            'optional_fixed32' => 46,
1347ffe3c632Sopenharmony_ci            'optional_fixed64' => 47,
1348ffe3c632Sopenharmony_ci            'optional_sfixed32' => -46,
1349ffe3c632Sopenharmony_ci            'optional_sfixed64' => -47,
1350ffe3c632Sopenharmony_ci            'optional_float' => 1.5,
1351ffe3c632Sopenharmony_ci            'optional_double' => 1.6,
1352ffe3c632Sopenharmony_ci            'optional_bool' => true,
1353ffe3c632Sopenharmony_ci            'optional_string' => 'a',
1354ffe3c632Sopenharmony_ci            'optional_bytes' => 'bbbb',
1355ffe3c632Sopenharmony_ci            'optional_enum' => TestEnum::ONE,
1356ffe3c632Sopenharmony_ci            'optional_message' => new Sub([
1357ffe3c632Sopenharmony_ci                'a' => 33
1358ffe3c632Sopenharmony_ci            ]),
1359ffe3c632Sopenharmony_ci            'repeated_int32' => [-42, -52],
1360ffe3c632Sopenharmony_ci            'repeated_int64' => [-43, -53],
1361ffe3c632Sopenharmony_ci            'repeated_uint32' => [42, 52],
1362ffe3c632Sopenharmony_ci            'repeated_uint64' => [43, 53],
1363ffe3c632Sopenharmony_ci            'repeated_sint32' => [-44, -54],
1364ffe3c632Sopenharmony_ci            'repeated_sint64' => [-45, -55],
1365ffe3c632Sopenharmony_ci            'repeated_fixed32' => [46, 56],
1366ffe3c632Sopenharmony_ci            'repeated_fixed64' => [47, 57],
1367ffe3c632Sopenharmony_ci            'repeated_sfixed32' => [-46, -56],
1368ffe3c632Sopenharmony_ci            'repeated_sfixed64' => [-47, -57],
1369ffe3c632Sopenharmony_ci            'repeated_float' => [1.5, 2.5],
1370ffe3c632Sopenharmony_ci            'repeated_double' => [1.6, 2.6],
1371ffe3c632Sopenharmony_ci            'repeated_bool' => [true, false],
1372ffe3c632Sopenharmony_ci            'repeated_string' => ['a', 'c'],
1373ffe3c632Sopenharmony_ci            'repeated_bytes' => ['bbbb', 'dddd'],
1374ffe3c632Sopenharmony_ci            'repeated_enum' => [TestEnum::ZERO, TestEnum::ONE],
1375ffe3c632Sopenharmony_ci            'repeated_message' => [new Sub(['a' => 34]),
1376ffe3c632Sopenharmony_ci                                   new Sub(['a' => 35])],
1377ffe3c632Sopenharmony_ci            'map_int32_int32' => [-62 => -62],
1378ffe3c632Sopenharmony_ci            'map_int64_int64' => [-63 => -63],
1379ffe3c632Sopenharmony_ci            'map_uint32_uint32' => [62 => 62],
1380ffe3c632Sopenharmony_ci            'map_uint64_uint64' => [63 => 63],
1381ffe3c632Sopenharmony_ci            'map_sint32_sint32' => [-64 => -64],
1382ffe3c632Sopenharmony_ci            'map_sint64_sint64' => [-65 => -65],
1383ffe3c632Sopenharmony_ci            'map_fixed32_fixed32' => [66 => 66],
1384ffe3c632Sopenharmony_ci            'map_fixed64_fixed64' => [67 => 67],
1385ffe3c632Sopenharmony_ci            'map_sfixed32_sfixed32' => [-68 => -68],
1386ffe3c632Sopenharmony_ci            'map_sfixed64_sfixed64' => [-69 => -69],
1387ffe3c632Sopenharmony_ci            'map_int32_float' => [1 => 3.5],
1388ffe3c632Sopenharmony_ci            'map_int32_double' => [1 => 3.6],
1389ffe3c632Sopenharmony_ci            'map_bool_bool' => [true => true],
1390ffe3c632Sopenharmony_ci            'map_string_string' => ['e' => 'e'],
1391ffe3c632Sopenharmony_ci            'map_int32_bytes' => [1 => 'ffff'],
1392ffe3c632Sopenharmony_ci            'map_int32_enum' => [1 => TestEnum::ONE],
1393ffe3c632Sopenharmony_ci            'map_int32_message' => [1 => new Sub(['a' => 36])],
1394ffe3c632Sopenharmony_ci        ]);
1395ffe3c632Sopenharmony_ci
1396ffe3c632Sopenharmony_ci        TestUtil::assertTestMessage($m);
1397ffe3c632Sopenharmony_ci        $this->assertTrue(true);
1398ffe3c632Sopenharmony_ci    }
1399ffe3c632Sopenharmony_ci
1400ffe3c632Sopenharmony_ci    public function testReferenceInArrayConstructor()
1401ffe3c632Sopenharmony_ci    {
1402ffe3c632Sopenharmony_ci        $keys = [[
1403ffe3c632Sopenharmony_ci                    'optional_bool' => true,
1404ffe3c632Sopenharmony_ci                    'repeated_bool' => [true],
1405ffe3c632Sopenharmony_ci                    'map_bool_bool' => [true => true],
1406ffe3c632Sopenharmony_ci                    'optional_double' => 1.0,
1407ffe3c632Sopenharmony_ci                    'repeated_double' => [1.0],
1408ffe3c632Sopenharmony_ci                    'map_int32_double' => [1 => 1.0],
1409ffe3c632Sopenharmony_ci                    'optional_int32' => 1,
1410ffe3c632Sopenharmony_ci                    'repeated_int32' => [1],
1411ffe3c632Sopenharmony_ci                    'map_int32_int32' => [1 => 1],
1412ffe3c632Sopenharmony_ci                    'optional_string' => 'a',
1413ffe3c632Sopenharmony_ci                    'repeated_string' => ['a'],
1414ffe3c632Sopenharmony_ci                    'map_string_string' => ['a' => 'a'],
1415ffe3c632Sopenharmony_ci                    'optional_message' => ['a' => 1],
1416ffe3c632Sopenharmony_ci                    'repeated_message' => [['a' => 1]],
1417ffe3c632Sopenharmony_ci                    'map_int32_message' => [1 => ['a' => 1]],
1418ffe3c632Sopenharmony_ci                ]];
1419ffe3c632Sopenharmony_ci
1420ffe3c632Sopenharmony_ci        foreach ($keys as &$key) {
1421ffe3c632Sopenharmony_ci            foreach ($key as $id => &$value) {
1422ffe3c632Sopenharmony_ci                if ($id === 'repeated_bool') {
1423ffe3c632Sopenharmony_ci                    foreach ($value as &$element) {
1424ffe3c632Sopenharmony_ci                    }
1425ffe3c632Sopenharmony_ci                }
1426ffe3c632Sopenharmony_ci                if ($id === 'map_bool_bool') {
1427ffe3c632Sopenharmony_ci                    foreach ($value as $mapKey => &$element) {
1428ffe3c632Sopenharmony_ci                    }
1429ffe3c632Sopenharmony_ci                }
1430ffe3c632Sopenharmony_ci                if ($id === 'repeated_double') {
1431ffe3c632Sopenharmony_ci                    foreach ($value as &$element) {
1432ffe3c632Sopenharmony_ci                    }
1433ffe3c632Sopenharmony_ci                }
1434ffe3c632Sopenharmony_ci                if ($id === 'map_int32_double') {
1435ffe3c632Sopenharmony_ci                    foreach ($value as $mapKey => &$element) {
1436ffe3c632Sopenharmony_ci                    }
1437ffe3c632Sopenharmony_ci                }
1438ffe3c632Sopenharmony_ci                if ($id === 'repeated_int32') {
1439ffe3c632Sopenharmony_ci                    foreach ($value as &$element) {
1440ffe3c632Sopenharmony_ci                    }
1441ffe3c632Sopenharmony_ci                }
1442ffe3c632Sopenharmony_ci                if ($id === 'map_int32_int32') {
1443ffe3c632Sopenharmony_ci                    foreach ($value as $mapKey => &$element) {
1444ffe3c632Sopenharmony_ci                    }
1445ffe3c632Sopenharmony_ci                }
1446ffe3c632Sopenharmony_ci                if ($id === 'repeated_string') {
1447ffe3c632Sopenharmony_ci                    foreach ($value as &$element) {
1448ffe3c632Sopenharmony_ci                    }
1449ffe3c632Sopenharmony_ci                }
1450ffe3c632Sopenharmony_ci                if ($id === 'map_string_string') {
1451ffe3c632Sopenharmony_ci                    foreach ($value as $mapKey => &$element) {
1452ffe3c632Sopenharmony_ci                    }
1453ffe3c632Sopenharmony_ci                }
1454ffe3c632Sopenharmony_ci                if ($id === 'optional_message') {
1455ffe3c632Sopenharmony_ci                    $value = new Sub($value);
1456ffe3c632Sopenharmony_ci                }
1457ffe3c632Sopenharmony_ci                if ($id === 'repeated_message') {
1458ffe3c632Sopenharmony_ci                    foreach ($value as &$element) {
1459ffe3c632Sopenharmony_ci                        $element = new Sub($element);
1460ffe3c632Sopenharmony_ci                    }
1461ffe3c632Sopenharmony_ci                }
1462ffe3c632Sopenharmony_ci                if ($id === 'map_int32_message') {
1463ffe3c632Sopenharmony_ci                    foreach ($value as $mapKey => &$element) {
1464ffe3c632Sopenharmony_ci                        $element = new Sub($element);
1465ffe3c632Sopenharmony_ci                    }
1466ffe3c632Sopenharmony_ci                }
1467ffe3c632Sopenharmony_ci            }
1468ffe3c632Sopenharmony_ci            $key = new TestMessage($key);
1469ffe3c632Sopenharmony_ci        }
1470ffe3c632Sopenharmony_ci    }
1471ffe3c632Sopenharmony_ci
1472ffe3c632Sopenharmony_ci    public function testOneofMessageInArrayConstructor()
1473ffe3c632Sopenharmony_ci    {
1474ffe3c632Sopenharmony_ci        $m = new TestMessage([
1475ffe3c632Sopenharmony_ci            'oneof_message' => new Sub(),
1476ffe3c632Sopenharmony_ci        ]);
1477ffe3c632Sopenharmony_ci        $this->assertSame('oneof_message', $m->getMyOneof());
1478ffe3c632Sopenharmony_ci        $this->assertNotNull($m->getOneofMessage());
1479ffe3c632Sopenharmony_ci    }
1480ffe3c632Sopenharmony_ci
1481ffe3c632Sopenharmony_ci    public function testOneofStringInArrayConstructor()
1482ffe3c632Sopenharmony_ci    {
1483ffe3c632Sopenharmony_ci        $m = new TestMessage([
1484ffe3c632Sopenharmony_ci            'oneof_string' => 'abc',
1485ffe3c632Sopenharmony_ci        ]);
1486ffe3c632Sopenharmony_ci    }
1487ffe3c632Sopenharmony_ci
1488ffe3c632Sopenharmony_ci    #########################################################
1489ffe3c632Sopenharmony_ci    # Test message equals.
1490ffe3c632Sopenharmony_ci    #########################################################
1491ffe3c632Sopenharmony_ci
1492ffe3c632Sopenharmony_ci    public function testMessageEquals()
1493ffe3c632Sopenharmony_ci    {
1494ffe3c632Sopenharmony_ci        $m = new TestMessage();
1495ffe3c632Sopenharmony_ci        TestUtil::setTestMessage($m);
1496ffe3c632Sopenharmony_ci        $n = new TestMessage();
1497ffe3c632Sopenharmony_ci        TestUtil::setTestMessage($n);
1498ffe3c632Sopenharmony_ci        $this->assertEquals($m, $n);
1499ffe3c632Sopenharmony_ci    }
1500ffe3c632Sopenharmony_ci
1501ffe3c632Sopenharmony_ci    #########################################################
1502ffe3c632Sopenharmony_ci    # Test reference of value
1503ffe3c632Sopenharmony_ci    #########################################################
1504ffe3c632Sopenharmony_ci
1505ffe3c632Sopenharmony_ci    public function testValueIsReference()
1506ffe3c632Sopenharmony_ci    {
1507ffe3c632Sopenharmony_ci        // Bool element
1508ffe3c632Sopenharmony_ci        $values = [true];
1509ffe3c632Sopenharmony_ci        array_walk($values, function (&$value) {});
1510ffe3c632Sopenharmony_ci        $m = new TestMessage();
1511ffe3c632Sopenharmony_ci        $m->setOptionalBool($values[0]);
1512ffe3c632Sopenharmony_ci
1513ffe3c632Sopenharmony_ci        // Int32 element
1514ffe3c632Sopenharmony_ci        $values = [1];
1515ffe3c632Sopenharmony_ci        array_walk($values, function (&$value) {});
1516ffe3c632Sopenharmony_ci        $m = new TestMessage();
1517ffe3c632Sopenharmony_ci        $m->setOptionalInt32($values[0]);
1518ffe3c632Sopenharmony_ci
1519ffe3c632Sopenharmony_ci        // Double element
1520ffe3c632Sopenharmony_ci        $values = [1.0];
1521ffe3c632Sopenharmony_ci        array_walk($values, function (&$value) {});
1522ffe3c632Sopenharmony_ci        $m = new TestMessage();
1523ffe3c632Sopenharmony_ci        $m->setOptionalDouble($values[0]);
1524ffe3c632Sopenharmony_ci
1525ffe3c632Sopenharmony_ci        // String element
1526ffe3c632Sopenharmony_ci        $values = ['a'];
1527ffe3c632Sopenharmony_ci        array_walk($values, function (&$value) {});
1528ffe3c632Sopenharmony_ci        $m = new TestMessage();
1529ffe3c632Sopenharmony_ci        $m->setOptionalString($values[0]);
1530ffe3c632Sopenharmony_ci    }
1531ffe3c632Sopenharmony_ci
1532ffe3c632Sopenharmony_ci    #########################################################
1533ffe3c632Sopenharmony_ci    # Test no segfault when error happens
1534ffe3c632Sopenharmony_ci    #########################################################
1535ffe3c632Sopenharmony_ci
1536ffe3c632Sopenharmony_ci    function throwIntendedException()
1537ffe3c632Sopenharmony_ci    {
1538ffe3c632Sopenharmony_ci        throw new Exception('Intended');
1539ffe3c632Sopenharmony_ci    }
1540ffe3c632Sopenharmony_ci
1541ffe3c632Sopenharmony_ci    /**
1542ffe3c632Sopenharmony_ci     * @expectedException Exception
1543ffe3c632Sopenharmony_ci     */
1544ffe3c632Sopenharmony_ci    public function testNoSegfaultWithError()
1545ffe3c632Sopenharmony_ci    {
1546ffe3c632Sopenharmony_ci        new TestMessage(['optional_int32' => $this->throwIntendedException()]);
1547ffe3c632Sopenharmony_ci    }
1548ffe3c632Sopenharmony_ci
1549ffe3c632Sopenharmony_ci    public function testNoExceptionWithVarDump()
1550ffe3c632Sopenharmony_ci    {
1551ffe3c632Sopenharmony_ci        $m = new Sub(['a' => 1]);
1552ffe3c632Sopenharmony_ci        /*
1553ffe3c632Sopenharmony_ci         * This line currently segfaults on macOS with:
1554ffe3c632Sopenharmony_ci         *
1555ffe3c632Sopenharmony_ci         *    frame #0: 0x00000001029936cc xdebug.so`xdebug_zend_hash_is_recursive + 4
1556ffe3c632Sopenharmony_ci         *    frame #1: 0x00000001029a6736 xdebug.so`xdebug_var_export_text_ansi + 1006
1557ffe3c632Sopenharmony_ci         *    frame #2: 0x00000001029a715d xdebug.so`xdebug_get_zval_value_text_ansi + 273
1558ffe3c632Sopenharmony_ci         *    frame #3: 0x000000010298a441 xdebug.so`zif_xdebug_var_dump + 297
1559ffe3c632Sopenharmony_ci         *    frame #4: 0x000000010298d558 xdebug.so`xdebug_execute_internal + 640
1560ffe3c632Sopenharmony_ci         *    frame #5: 0x000000010046d47f php`ZEND_DO_FCALL_SPEC_RETVAL_UNUSED_HANDLER + 364
1561ffe3c632Sopenharmony_ci         *    frame #6: 0x000000010043cabc php`execute_ex + 44
1562ffe3c632Sopenharmony_ci         *    frame #7: 0x000000010298d151 xdebug.so`xdebug_execute_ex + 1662
1563ffe3c632Sopenharmony_ci         *    frame #8: 0x000000010046d865 php`ZEND_DO_FCALL_SPEC_RETVAL_USED_HANDLER + 426
1564ffe3c632Sopenharmony_ci         *
1565ffe3c632Sopenharmony_ci         * The value we are passing to var_dump() appears to be corrupt somehow.
1566ffe3c632Sopenharmony_ci         */
1567ffe3c632Sopenharmony_ci        /* var_dump($m); */
1568ffe3c632Sopenharmony_ci    }
1569ffe3c632Sopenharmony_ci}
1570