可空字符串类型提示在 PHP 7.2 中出现语法错误

Met*_*iem 0 php types php-7.2

我正在使用 PHP 7.2 并尝试键入提示此变量:

class TestClass
{
    public static ?string $test = null;
Run Code Online (Sandbox Code Playgroud)

但是 PHP 给了我以下错误:

语法错误,意外的“?”,需要函数 (T_FUNCTION) 或常量 (T_CONST)

我完全不知道为什么!难道我做错了什么?

El_*_*nja 5

直到 PHP 7.4 才包含类型属性