Option 1
Have you tried changing the function name? something similar function getClientFn($function){}? You can keep any name you want.
function getClientFn($function){
return '\DisplaceTech\Companies\\' . $function;
}
function add_clients_metabox(){
$screens = ['page'];
foreach ($screens as $screen) {
add_meta_box(
'clients', // Unique ID
__('Clients'), // Box title
getClientFn('clients_box_html'), // Content callback, must be of type callable
$screen, // Post type
'advanced', // Context
'high' // Priority
);
}
}
add_action('add_meta_boxes', 'add_clients_metabox');
Option 2: If you really need to keep ‘fn’ method, then give a try with below script which works in php 7.4.
$myfunction = fn($function) => '\DisplaceTech\Companies\\' . $function;
function add_clients_metabox(){
$screens = ['page'];
foreach ($screens as $screen) {
add_meta_box(
'clients', // Unique ID
__('Clients'), // Box title
$myfunction('clients_box_html'), // Content callback, must be of type callable
$screen, // Post type
'advanced', // Context
'high' // Priority
);
} } add_action('add_meta_boxes', 'add_clients_metabox');