Files
piratepoet/mailpoet/tasks/fix-php82-deprecations.php
2023-02-08 15:26:14 +01:00

29 lines
930 B
PHP

<?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing
// throw exception if anything fails
set_error_handler(function ($severity, $message, $file, $line) {
throw new ErrorException($message, 0, $severity, $file, $line);
});
// Fixes for PHP8.2 Compatibility
// Production packages
$replacements = [
[
'file' => __DIR__ . '/../vendor-prefixed/gregwar/captcha/src/Gregwar/Captcha/CaptchaBuilder.php',
'find' => [
'protected $backgroundColor = null;' . "\n" . ' /**',
],
'replace' => [
'protected $backgroundColor = null;' . PHP_EOL . ' protected $background = null;' . PHP_EOL . ' /**',
],
],
];
// Apply replacements
foreach ($replacements as $singleFile) {
$data = file_get_contents($singleFile['file']);
$data = str_replace($singleFile['find'], $singleFile['replace'], $data);
file_put_contents($singleFile['file'], $data);
}