PHP 7.4 will introduce a new shorthand for defining functions inline. Currently we do things like this:
From PHP 7.4 onwards it can be shortened to:
Whilst the XenForo code base will not be able to benefit from this functionality for many years, it does mean that the
From XF 2.1.3 we have renamed the
We urge you from 2.1.3 onwards to replace any calls to
PHP:
$container['router'] = function (Container $c)
{
return $c['router.public'];
};
From PHP 7.4 onwards it can be shortened to:
PHP:
$container['router'] = fn(Container $c) => $c['router.public'];
Whilst the XenForo code base will not be able to benefit from this functionality for many years, it does mean that the
fn
part above becomes a reserved keyword which will be an issue if we want to support PHP 7.4 in the future. Unfortunately, we use fn
as a method name within our Templater.From XF 2.1.3 we have renamed the
XF\Template\Templater::fn()
method to XF\Template\Templater::func()
. Because this would very likely break existing code we have kept the fn()
method but it now simply calls the func()
method.We urge you from 2.1.3 onwards to replace any calls to
fn()
in your own code to func()
. At some point in the near-ish future, we will be adding PHP 7.4 support to XF 2.1 and at that point, we will likely have to remove the fn()
method.
Last edited: