- preg_replace_callback: documentation ( source)
- array_unshift: documentation ( source)
- sprintf: documentation ( source)
<?php
class Model {};
function select(string $key, string ...$keys): Model
{
\array_unshift($keys, $key);
foreach ($keys as &$key) {
$key = \preg_replace_callback('/([a-zA-Z]+)\((.*)\)/', function ($match) {
return \sprintf('%s(%s)', $match[1], "foo");
}, $key);
}
return new Model;
}
select("x", 'a', 'b', 'c');