For PHP 8+ passing null to trim and other core functions is deprecated. simple solution would be the usage of the Null Coalescing Operator:
/**
* Validate reCAPTCHA challenge/response
*
* @return array Array with verified- (boolean) and error-code (string)
*/
public function validateReCaptcha(): array
{
if (!$this->getShowCaptcha()) {
return [
'verified' => true,
'error' => ''
];
}
$solution = trim(GeneralUtility::_GP('frc-captcha-solution') ?? '');
$request = [
'site_key' => $this->configuration['public_key'] ?? '',
'secreat_key' => $this->configuration['secret_key'] ?? '',
'response' => $solution,
'remoteip' => GeneralUtility::getIndpEnv('REMOTE_ADDR'),
'eu' => $this->configuration['eu'] ?? '',
'enablepuzzle' => $this->configuration['enablepuzzle'] ?? ''
];
if ($solution == '.UNSTARTED' || $solution == '.UNFINISHED' || $solution == '.FETCHING') {
$request['response'] = '';
}
$result = ['verified' => false, 'error' => ''];
if (empty($request['response'])) {
$result['error'] = 'missing-input-response';
}
// Server Side Velidation
$response = $this->queryVerificationServer($request);
if ($response['success']) {
$result['verified'] = true;
} else {
if (isset($response['error-codes'])) {
$result['error'] = $response['error-codes'];
}
if (isset($response['errors'])) {
$result['error'] = 'missing-input-response';
}
}
return $result;
}