Skip to content

Commit 5fc1394

Browse files
committed
Expand tests
1 parent 5f80c87 commit 5fc1394

File tree

1 file changed

+42
-5
lines changed

1 file changed

+42
-5
lines changed

ext/reflection/tests/gh19187.phpt

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,54 @@ GH-19187: ReflectionNamedType::getName() should not include nullable type
33
--FILE--
44
<?php
55

6-
class Foo {
7-
public string|null $bar {
6+
class C {
7+
public string|null $a {
8+
set => $value;
9+
}
10+
public string|null $b {
811
set(string|null $value) => $value;
912
}
13+
public string|null $c {
14+
get => $this->c;
15+
}
1016
}
1117

12-
$reflProp = new ReflectionProperty(Foo::class, 'bar');
13-
echo $reflProp->getType()->getName(), "\n";
14-
echo $reflProp->getSettableType()->getName(), "\n";
18+
foreach ((new ReflectionClass(C::class))->getProperties() as $r) {
19+
$type = $r->getType();
20+
echo $type, "\n";
21+
echo $type->getName(), "\n";
22+
var_dump($type->allowsNull());
23+
echo "\n";
24+
25+
$settableType = $r->getSettableType();
26+
echo $settableType, "\n";
27+
echo $settableType->getName(), "\n";
28+
var_dump($settableType->allowsNull());
29+
echo "\n";
30+
}
1531

1632
?>
1733
--EXPECT--
34+
?string
1835
string
36+
bool(true)
37+
38+
?string
39+
string
40+
bool(true)
41+
42+
?string
43+
string
44+
bool(true)
45+
46+
?string
47+
string
48+
bool(true)
49+
50+
?string
51+
string
52+
bool(true)
53+
54+
?string
1955
string
56+
bool(true)

0 commit comments

Comments
 (0)