7
考虑下面的代码:为什么在PHP 7中调用可调用属性有效?
interface Doll
{
/**
* @return string
*/
function __invoke();
}
class LargeDoll
{
private $inner;
function __construct(Doll $inner)
{
$this->inner = $inner;
}
function __invoke()
{
return $this->inner() . ' world';
}
}
,因为它期待$this->inner
是一种方法,而不是一个可调用的属性这将无法正常工作。
然后它发生在我身上,就像有(new LargeDoll)();
会工作,如果属性也包含在palenthesis中呢?所以我测试3v4l:
return ($this->inner)() . ' world';
And found that it works for PHP 7, but not for previous versions.
但是,我无法找到此in the changelogs的任何提及。
我在哪里可以找到关于此功能的更多信息?