From 46c45d9befe0544ca9c02cd13e9955966e8af0a3 Mon Sep 17 00:00:00 2001 From: alex-mailpoet Date: Thu, 26 Jan 2023 15:42:31 +0300 Subject: [PATCH] Fix consolidation/robo PHP 8.2 deprecation notices [MAILPOET-4900] When a new robo version with a fix for 'self' in callables is released, this patch can be removed. Check here: https://github.com/consolidation/robo/issues/1135 --- mailpoet/composer.json | 3 ++- mailpoet/tasks/fix-php82-robo.php | 44 +++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 mailpoet/tasks/fix-php82-robo.php diff --git a/mailpoet/composer.json b/mailpoet/composer.json index 42f6ef54e9..276d302d09 100644 --- a/mailpoet/composer.json +++ b/mailpoet/composer.json @@ -86,7 +86,8 @@ ], "pre-autoload-dump": [ "php ./tasks/fix-codeception-stub.php", - "php ./tasks/fix-requests.php" + "php ./tasks/fix-requests.php", + "php ./tasks/fix-php82-robo.php" ] }, "config": { diff --git a/mailpoet/tasks/fix-php82-robo.php b/mailpoet/tasks/fix-php82-robo.php new file mode 100644 index 0000000000..f4ef089872 --- /dev/null +++ b/mailpoet/tasks/fix-php82-robo.php @@ -0,0 +1,44 @@ + __DIR__ . '/../vendor/consolidation/robo/src/Common/CommandArguments.php', + 'find' => [ + '$this->arguments .= \' \' . implode(\' \', array_map(\'static::escape\', $args));', + ], + 'replace' => [ + '$this->arguments .= \' \' . implode(\' \', array_map([static::class, \'escape\'], $args));', + ], + ], + [ + 'file' => __DIR__ . '/../vendor/consolidation/robo/src/Task/Base/Exec.php', + 'find' => [ + '$stopRunningJobs = Closure::fromCallable([\'self\', \'stopRunningJobs\']);', + ], + 'replace' => [ + '$stopRunningJobs = Closure::fromCallable(self::class.\'::stopRunningJobs\');', + ], + ], +]; + +// 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); +}