Apply patches on initial install/update

The patches to get PHPUnit working are causing problems for other projects that use both `cweagans/composer-patch-installers` and `predis/predis` along with PHPUnit.

This change moves the patch application to a simple PHP script run on the `post-update-cmd` composer event and removes the dependency on the patch installers package.
This commit is contained in:
Robert O'Rourke
2020-11-27 17:24:00 +00:00
parent 5f4b87080f
commit c021e380d6
2 changed files with 19 additions and 14 deletions
+4 -14
View File
@@ -31,8 +31,7 @@
"php": ">=5.3.9"
},
"require-dev": {
"phpunit/phpunit": "~4.8",
"cweagans/composer-patches": "^1.6"
"phpunit/phpunit": "~4.8"
},
"suggest": {
"ext-phpiredis": "Allows faster serialization and deserialization of the Redis protocol",
@@ -43,16 +42,7 @@
"Predis\\": "src/"
}
},
"extra": {
"composer-exit-on-patch-failure": true,
"patches": {
"phpunit/phpunit-mock-objects": {
"Fix PHP 7 and 8 compatibility": "./tests/phpunit_mock_objects.patch"
},
"phpunit/phpunit": {
"Fix PHP 7 compatibility": "./tests/phpunit_php7.patch",
"Fix PHP 8 compatibility": "./tests/phpunit_php8.patch"
}
}
}
"scripts": {
"post-update-cmd": "@php -f tests/apply-patches.php"
}
}
+15
View File
@@ -0,0 +1,15 @@
<?php
/**
* Apply patches to support newer PHP versions.
*/
$patches = [
'phpunit_mock_objects.patch' => 'phpunit/phpunit-mock-objects',
'phpunit_php7.patch' => 'phpunit/phpunit',
'phpunit_php8.patch' => 'phpunit/phpunit',
];
foreach ($patches as $patch => $package) {
chdir(__DIR__.'/../vendor/'.$package);
passthru(sprintf('patch -p1 -f < ../../../tests/%s', $patch));
}