Files
piratepoet/mailpoet/tasks/phpstan/fix-WPStubs-for-PHP-8_1.php
Jan Jakes 9f790efbf0 Move plugin files to a subfolder
[MAILPOET-3988]
2022-01-18 15:30:22 +01:00

22 lines
609 B
PHP

<?php
// throw exception if anything fails
set_error_handler(function ($severity, $message, $file, $line) {
throw new ErrorException($message, 0, $severity, $file, $line);
});
$file = 'vendor/php-stubs/wordpress-stubs/wordpress-stubs.php';
$data = file_get_contents($file);
$search_term = 'function readonly';
if (!strpos($data, $search_term)) {
return;
}
// "readonly" is a reserved keyword in PHP 8.1,
// WP has a "function readonly", hence, we need to replace readonly with __readonly for the stub
$data = str_replace($search_term, 'function __readonly', $data);
file_put_contents($file, $data);