Add patching for phpunit deprecated ReflectionParameter::getClass()
[MAILPOET-3296]
This commit is contained in:
committed by
Veljko V
parent
12e85972a3
commit
747d5fffee
@ -83,6 +83,9 @@
|
||||
"post-install-cmd": [
|
||||
"./tools/vendor/composer.phar --working-dir=tasks/code_sniffer install",
|
||||
"./tools/vendor/composer.phar --working-dir=tasks/phpstan install"
|
||||
],
|
||||
"pre-autoload-dump": [
|
||||
"php ./tasks/fix-phpunit.php"
|
||||
]
|
||||
},
|
||||
"config": {
|
||||
|
31
tasks/fix-phpunit.php
Normal file
31
tasks/fix-phpunit.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
// throw exception if anything fails
|
||||
set_error_handler(function ($severity, $message, $file, $line) {
|
||||
throw new ErrorException($message, 0, $severity, $file, $line);
|
||||
});
|
||||
|
||||
// Skip for production build
|
||||
if (!file_exists(__DIR__ . '/../vendor/phpunit/phpunit/src/Framework/MockObject/MockMethod.php')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$replacements = [
|
||||
// Fixes for PHP8 Compatibility
|
||||
[
|
||||
'file' => __DIR__ . '/../vendor/phpunit/phpunit/src/Framework/MockObject/MockMethod.php',
|
||||
'find' => [
|
||||
'$class = $parameter->getClass();',
|
||||
],
|
||||
'replace' => [
|
||||
'$class = $parameter->hasType() && $parameter->getType() && !$parameter->getType()->isBuiltin() ? new ReflectionClass($parameter->getType()->getName()) : null;',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
// 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);
|
||||
}
|
Reference in New Issue
Block a user