1<?php
2$foo = (int) $bar;
3$foo = (integer) $bar;
4$foo = (bool) $bar;
5$foo = (boolean) $bar;
6$foo = (float) $bar;
7$foo = (double) $bar;
8$foo = (real) $bar;
9$foo = (string) $bar;
10$foo = (array) $bar;
11$foo = (object) $bar;
12$foo = (unset) $bar;
13
14$foo = (int) $bar;
15$foo = (integer) $bar;
16$foo = (bool) $bar;
17$foo = (string) $bar;
18$foo = ( array ) $bar;
19
20function foo(int $a, string $b, bool $c, array $d, Foo\Bar $e) : int {}
21function foo(int $a, string $b, bool $c, array $d, Foo\Bar $e) : Foo\Bar {}
22function foo(int $a, Bar $b, bool $c, array $d, Foo\Bar $e) : Bar {}
23function foo(callable $a, callable $b, self $c, iterable $d, iterable $e) : float {}
24
25$foo = function (int $a, bool $b) {};
26$foo = function (int $a, callable $b) :int{};
27$foo = function (bool $a, float $b) use ($foo) : int {};
28$foo = function (Foo $a, Foo\Bar $b) use ($foo) : \Foo\Bar {};
29$foo = function (bool $a, callable $b) use ($foo) : Bar {};
30
31class Testing {
32    public function TestThis(self $a, object $b, parent $c) : void {}
33}
34
35function foo(
36    ?float $a,
37    ? string $b,
38    ?iterable $c,
39    ?	object $d,
40    ?Foo\Bar $e
41) : ?Foo\Bar {}
42
43$foo = function (?int $a, ?    callable $b)
44    :?int{};
45
46$var = (binary) $string;
47$var = (binary)$string;
48
49function unionParamTypesA (bool|array| /* nullability operator not allowed in union */ null $var) {}
50
51function unionParamTypesB (\Package\ClassName | int | \Package\Other_Class | false $var) {}
52
53function unionReturnTypesA ($var): bool|array| /* nullability operator not allowed in union */ null {}
54
55function unionReturnTypesB ($var): \Package\ClassName | int | \Package\Other_Class | false {}
56
57class TypedProperties
58{
59    protected ClassName $class;
60    public int $int;
61    private ?bool $bool;
62    public self $self;
63    protected parent $parent;
64    private array $array;
65    public float $float;
66    protected ?string $string;
67    private iterable $iterable;
68    public object $object;
69    protected mixed $mixed;
70
71    public iterable|false|null $unionTypeA;
72    protected self|parent /* comment */ |\Fully\Qualified\ClassName|UnQualifiedClass $unionTypeB;
73    private ClassName|/*comment*/float|string|false $unionTypeC;
74    public string | array | false $unionTypeD;
75}
76
77class ConstructorPropertyPromotionWithTypes {
78    public function __construct(protected float|int $x, public ?string &$y = 'test', private mixed $z) {}
79}
80
81class ConstructorPropertyPromotionAndNormalParams {
82    public function __construct(public int $promotedProp, ?int $normalArg) {}
83}
84