类变量中的类型提示
2022-08-30 11:54:55
<?php
namespace Sandbox;
class Sandbox {
private Connectors\ISandboxConnector $connection;
public function __construct(Connectors\ISandboxConnector $conn) {
$this->connection = $conn;
}
}
?>
对于上面的代码,我得到以下错误:
Parse error: syntax error, unexpected 'Connectors' (T_STRING), expecting variable (T_VARIABLE)
当我删除类型提示并且该$connection变量时,它将是而不是,为什么?var_dump
private Sandbox\Sandbox
Sandbox\Connectors\ISandboxconnector