1--TEST--
2The default value must be legal for one of the type in the union
3--FILE--
4<?php
5
6class Test {
7    public int|float $a = 1;
8    public int|float $b = 2.0;
9    public float|string $c = 3; // Strict typing exception
10    public float|string $d = 4.0;
11    public float|string $e = "5";
12}
13
14function test(
15    int|float $a = 1,
16    int|float $b = 2.0,
17    float|string $c = 3, // Strict typing exception
18    float|string $d = 4.0,
19    float|string $e = "5"
20) {
21    var_dump($a, $b, $c, $d, $e);
22}
23
24var_dump(new Test);
25test();
26
27?>
28--EXPECT--
29object(Test)#1 (5) {
30  ["a"]=>
31  int(1)
32  ["b"]=>
33  float(2)
34  ["c"]=>
35  float(3)
36  ["d"]=>
37  float(4)
38  ["e"]=>
39  string(1) "5"
40}
41int(1)
42float(2)
43float(3)
44float(4)
45string(1) "5"
46