diff --git a/mailpoet/composer.json b/mailpoet/composer.json index aaffe4913a..293ef9def7 100644 --- a/mailpoet/composer.json +++ b/mailpoet/composer.json @@ -78,13 +78,15 @@ "./tools/vendor/composer.phar --working-dir=tasks/code_sniffer install", "./tools/vendor/composer.phar --working-dir=tasks/phpstan install", "php ./tasks/fix-guzzle.php", - "php ./tasks/fix-php82-deprecations.php" + "php ./tasks/fix-php82-deprecations.php", + "php ./tasks/fix-php82-codeception.php" ], "post-install-cmd": [ "./tools/vendor/composer.phar --working-dir=tasks/code_sniffer install", "./tools/vendor/composer.phar --working-dir=tasks/phpstan install", "php ./tasks/fix-guzzle.php", - "php ./tasks/fix-php82-deprecations.php" + "php ./tasks/fix-php82-deprecations.php", + "php ./tasks/fix-php82-codeception.php" ], "pre-autoload-dump": [ "php ./tasks/fix-codeception-stub.php", diff --git a/mailpoet/tasks/fix-php82-codeception.php b/mailpoet/tasks/fix-php82-codeception.php new file mode 100644 index 0000000000..19568b5002 --- /dev/null +++ b/mailpoet/tasks/fix-php82-codeception.php @@ -0,0 +1,59 @@ +formatClassName($parentClass); + } + + $interfaces = $reflection->getInterfaceNames(); + foreach ($interfaces as $interface) { + if (str_starts_with($interface, 'PHPUnit\\')) { + continue; + } + if (str_starts_with($interface, 'Codeception\\')) { + continue; + } + return $this->formatClassName($interface); + } +CODE; + +// Development packages +$replacements = [ + [ + 'file' => __DIR__ . '/../vendor/codeception/stub/src/Stub.php', + 'find' => [ + ' $mock->__mocked = $reflection->getName();', + ], + 'replace' => [ + ' //$mock->__mocked = $reflection->getName();', + ], + ], + [ + 'file' => __DIR__ . '/../vendor/codeception/codeception/src/Codeception/Step.php', + 'find' => [ + '} elseif ($argument instanceof MockObject && isset($argument->__mocked)) {', + 'return $this->formatClassName($argument->__mocked);', + ], + 'replace' => [ + '} elseif ($argument instanceof MockObject) {', + $codeceptionStepReplacement, + ], + ], +]; + +// 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); +}