【发布时间】:2018-03-21 10:43:39
【问题描述】:
我在https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Console/Output/Output.php 第 40 行看到了这段代码,他们正在使用 ?int。
public function __construct(?int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = false, OutputFormatterInterface $formatter = null)
{
$this->verbosity = null === $verbosity ? self::VERBOSITY_NORMAL : $verbosity;
$this->formatter = $formatter ?: new OutputFormatter();
$this->formatter->setDecorated($decorated);
}
【问题讨论】:
-
表示应该是int但也可以是null
-
php 7.2不支持的问题
-
@MaxChernopolsky 您能否提供您声称“php 7.2 不支持 Nullable 类型”的参考?
-
我错了。确实如此。