Magento does not pass the values of missed optional arguments of intercepted methods to plugins


For a method NAME Magento generates the interceptor code:

public function NAME(<…>) {
	$pluginInfo = $this->pluginList->getNext($this->subjectType, 'NAME');
	return $pluginInfo ? $this->___callPlugins('NAME', func_get_args(), $pluginInfo) : parent::NAME($i);

Let’s see \Magento\Framework\Pricing\Render\Amount::formatCurrency() as an example:

Magento generates the interceptor method \Magento\Framework\Pricing\Render\Amount\Interceptor::formatCurrency() with the code:

public function formatCurrency($amount, $includeContainer = true, $precision = 2) {
	$pluginInfo = $this->pluginList->getNext($this->subjectType, 'formatCurrency');
	return $pluginInfo ? $this->___callPlugins('formatCurrency', func_get_args(), $pluginInfo) : parent::formatCurrency($amount, $includeContainer, $precision);


func_get_args does not return the values of missed optional arguments:


So if an optional argument is missed from an intercepted method call, then before- and around- plugins will not get the argument’s value.