Closed thekid closed 2 years ago
The official way of writing this (int|string|null
) was fixed by xp-framework/ast@9cfc02d and released in https://github.com/xp-framework/ast/releases/tag/v8.2.0
However, int|string|null
yields the following when used with XP core reflection:
// PHP 8.2
lang.Nullable<?string|int>
// PHP < 8.2
lang.TypeUnion<int|string|void>
...which is inconsistent - the first form is what we should be getting in both cases.
For PHP 7, this fix is needed: https://github.com/xp-framework/core/pull/316
For PHP 7, this fix is needed: xp-framework/core#316
✅ Released in bugfix release https://github.com/xp-framework/core/releases/tag/v11.4.2
Fix released in https://github.com/xp-framework/compiler/releases/tag/v8.5.1
The union types RFC specifies in its nullable union types section:
XP Compiler supports both notations. However, either raise errors when compiled to PHP8.0+
int|string|null
: Compile error (Type declaration 'null' must be unqualified)?(int|string)
syntax error, unexpected token "|", expecting ";" or "{"