how to fix dynamically named function call in package to be installed on cloud

For package install on cloud instance, need to use callable function dynamically. I have tried to fix it using {} but did not help as the dynamic function call is not using object but it's a callable function.
$credentialProvider = CredentialProvider::fromCredentials($credentials);
(returns a callable function)
$signedRequest = $signer->signRequest($request$credentialProvider()->wait() );
(called above which is throwing error during installing package to cloud)
"Code attempted dynamically-named function call on line 47" 
Please advise what could be the alternate way to do so.
Tried below things but did not help.

$test = $credentialProvider()->wait();
$signedRequest = $signer->signRequest($request, $test);