Below is a function which we can find in core Magento 2 code.
protected function createObject($type, $args)
{
return new $type(...array_values($args));
}
This function is instantiating $type
(which is a string parameter) with the arguments $args
(which is an array parameter).
What I am not getting is those 3 dots (...
). Is this a valid syntax at all ? I never found such an object instantiation before !!
I tried to remove those dots and try to load a page. It gives fatal errors. So it seems that, those three dots are not accidentally come over there.
It seems like that code won't work for php-5.3 or lower versions. So it is something new which I couldn't find anywhere.