In an app that I'm creating, I need to pass an unknown number of parameters to an unknown constructor of a class. The class (+ namespace) is a string, that is in $class. The parameters are in an array.
This application will be deployed over a couple of months, so we thought we could develop it already in PHP 5.6. So I thought that the solution of this would be:
$instance = new $class(...$args);
This is working...
But my collegues don't want to accept this, because the CI server does not understand this line of code. Their solution would rather be:
$reflect = new \ReflectionClass($class);
$instance = $reflect->newInstanceArgs($args)
Now: both are working fine, so that's not the problem. But my thought is that Reflection is slower then using other ways (like the PHP 5.6 splat operator).
Also the question: is reflection a good way, of should I use the splat operator from the moment the CI server does understand that line?