File tree 3 files changed +14
-19
lines changed
Filter options
3 files changed +14
-19
lines changed
Original file line number Diff line number Diff line change @@ -1255,7 +1255,7 @@ zend_string *zend_type_to_string_resolved(zend_type type, zend_class_entry *scop
1255
1255
1256
1256
if (type_mask & MAY_BE_NULL ) {
1257
1257
bool is_union = !str || memchr (ZSTR_VAL (str ), '|' , ZSTR_LEN (str )) != NULL ;
1258
- if (!is_union && ! zend_string_equals_literal ( str , "false" ) ) {
1258
+ if (!is_union ) {
1259
1259
zend_string * nullable_str = zend_string_concat2 ("?" , 1 , ZSTR_VAL (str ), ZSTR_LEN (str ));
1260
1260
zend_string_release (str );
1261
1261
return nullable_str ;
Original file line number Diff line number Diff line change @@ -1342,10 +1342,6 @@ static reflection_type_kind get_type_kind(zend_type type) {
1342
1342
if (type_mask_without_null == MAY_BE_BOOL || ZEND_TYPE_PURE_MASK (type ) == MAY_BE_ANY ) {
1343
1343
return NAMED_TYPE ;
1344
1344
}
1345
- /* null|false must be a union type */
1346
- if (ZEND_TYPE_PURE_MASK (type ) == (MAY_BE_NULL |MAY_BE_FALSE )) {
1347
- return UNION_TYPE ;
1348
- }
1349
1345
/* Check that only one bit is set. */
1350
1346
if ((type_mask_without_null & (type_mask_without_null - 1 )) != 0 ) {
1351
1347
return UNION_TYPE ;
Original file line number Diff line number Diff line change @@ -13,6 +13,13 @@ function dumpType(ReflectionUnionType $rt) {
13
13
}
14
14
}
15
15
16
+ function dumpBCType (ReflectionNamedType $ rt ) {
17
+ echo "Type $ rt: \n" ;
18
+ echo " Name: " . $ rt ->getName () . "\n" ;
19
+ echo " String: " . (string ) $ rt . "\n" ;
20
+ echo " Allows Null: " . ($ rt ->allowsNull () ? "true " : "false " ) . "\n" ;
21
+ }
22
+
16
23
function test1 (): X |Y |int |float |false |null { }
17
24
function test2 (): X |iterable |bool { }
18
25
function test3 (): null |false { }
@@ -24,8 +31,8 @@ class Test {
24
31
25
32
dumpType ((new ReflectionFunction ('test1 ' ))->getReturnType ());
26
33
dumpType ((new ReflectionFunction ('test2 ' ))->getReturnType ());
27
- dumpType ((new ReflectionFunction ('test3 ' ))->getReturnType ());
28
- dumpType ((new ReflectionFunction ('test4 ' ))->getReturnType ());
34
+ dumpBCType ((new ReflectionFunction ('test3 ' ))->getReturnType ());
35
+ dumpBCType ((new ReflectionFunction ('test4 ' ))->getReturnType ());
29
36
30
37
$ rc = new ReflectionClass (Test::class);
31
38
$ rp = $ rc ->getProperty ('prop ' );
@@ -79,21 +86,13 @@ Allows null: false
79
86
Name: bool
80
87
String: bool
81
88
Allows Null: false
82
- Type false|null:
83
- Allows null: true
89
+ Type ?false:
84
90
Name: false
85
- String: false
86
- Allows Null: false
87
- Name: null
88
- String: null
91
+ String: ?false
89
92
Allows Null: true
90
- Type false|null:
91
- Allows null: true
93
+ Type ?false:
92
94
Name: false
93
- String: false
94
- Allows Null: false
95
- Name: null
96
- String: null
95
+ String: ?false
97
96
Allows Null: true
98
97
Type X|Y|int:
99
98
Allows null: false
You can’t perform that action at this time.
0 commit comments