Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
terrafrost committed Feb 22, 2024
1 parent e7e7177 commit 0971634
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ jobs:
php-version: ${{ matrix.php-version }}
- name: Composer Install
run: composer install --no-interaction --no-cache
- name: Make Tests Compatiable With PHPUnit 9+
if: contains(fromJSON('["7.3", "7.4", "8.0", "8.1", "8.2"]'), matrix.php-version)
run: php tests/make_compatible_with_phpunit9.php
- name: PHPUnit
run: vendor/bin/phpunit
strategy:
Expand Down
25 changes: 25 additions & 0 deletions tests/make_compatible_with_phpunit9.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

/** @var iterable<SplFileInfo> $files */
$files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(__DIR__));
foreach ($files as $file) {
if ($file->getExtension() === 'php' && $file->getPathname() !== __FILE__) {
$fileContents = file_get_contents($file->getPathname());
if ($fileContents === false) {
throw new \RuntimeException('file_get_contents() failed: ' . $file->getPathname());
}
$patternToReplacementMap = array(
'~(n assertIsArray\([^\)]*\))~' => '$1: void',
'~(n assertIsString\([^\)]*\))~' => '$1: void',
'~(n assertStringContainsString\([^\)]*\))~' => '$1: void'
);
$updatedFileContents = preg_replace(
array_keys($patternToReplacementMap),
array_values($patternToReplacementMap),
$fileContents
);
if (file_put_contents($file->getPathname(), $updatedFileContents) === false) {
throw new \RuntimeException('file_put_contents() failed: ' . $file->getPathname());
}
}
}

0 comments on commit 0971634

Please sign in to comment.