File tree Expand file tree Collapse file tree 3 files changed +63
-3
lines changed Expand file tree Collapse file tree 3 files changed +63
-3
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,10 @@ PHP NEWS
11
11
. Add support for CURLINFO_CONN_ID in curl_getinfo() (thecaliskan)
12
12
. Add support for CURLINFO_QUEUE_TIME_T in curl_getinfo() (thecaliskan)
13
13
14
+ - Reflection:
15
+ . Fixed bug GH-19187 (ReflectionNamedType::getName() prints nullable type when
16
+ retrieved from ReflectionProperty::getSettableType()). (ilutov)
17
+
14
18
- Session:
15
19
. Fixed GH-19197: build broken with ZEND_STRL usage with memcpy
16
20
when implemented as macro. (David Carlier)
Original file line number Diff line number Diff line change @@ -6403,7 +6403,7 @@ ZEND_METHOD(ReflectionProperty, getSettableType)
6403
6403
/* Get-only virtual property can never be written to. */
6404
6404
if (prop -> hooks && (prop -> flags & ZEND_ACC_VIRTUAL ) && !prop -> hooks [ZEND_PROPERTY_HOOK_SET ]) {
6405
6405
zend_type never_type = ZEND_TYPE_INIT_CODE (IS_NEVER , 0 , 0 );
6406
- reflection_type_factory (never_type , return_value , 0 );
6406
+ reflection_type_factory (never_type , return_value , 1 );
6407
6407
return ;
6408
6408
}
6409
6409
@@ -6413,15 +6413,15 @@ ZEND_METHOD(ReflectionProperty, getSettableType)
6413
6413
if (!ZEND_TYPE_IS_SET (arg_info -> type )) {
6414
6414
RETURN_NULL ();
6415
6415
}
6416
- reflection_type_factory (arg_info -> type , return_value , 0 );
6416
+ reflection_type_factory (arg_info -> type , return_value , 1 );
6417
6417
return ;
6418
6418
}
6419
6419
6420
6420
/* Fall back to property type */
6421
6421
if (!ZEND_TYPE_IS_SET (ref -> prop -> type )) {
6422
6422
RETURN_NULL ();
6423
6423
}
6424
- reflection_type_factory (ref -> prop -> type , return_value , 0 );
6424
+ reflection_type_factory (ref -> prop -> type , return_value , 1 );
6425
6425
}
6426
6426
6427
6427
/* {{{ Returns whether property has a type */
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ GH-19187: ReflectionNamedType::getName() should not include nullable type
3
+ --FILE--
4
+ <?php
5
+
6
+ class C {
7
+ public string |null $ a {
8
+ set => $ value ;
9
+ }
10
+ public string |null $ b {
11
+ set(string |null $ value ) => $ value ;
12
+ }
13
+ public string |null $ c {
14
+ get => $ this ->c ;
15
+ }
16
+ }
17
+
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
+ }
31
+
32
+ ?>
33
+ --EXPECT--
34
+ ?string
35
+ 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
55
+ string
56
+ bool(true)
You can’t perform that action at this time.
0 commit comments