@@ -274,13 +274,22 @@ jobs:
274274 strategy :
275275 matrix :
276276 os : ['ubuntu-latest', 'windows-latest']
277+ # Note: we can only run code coverage builds against PHP 7.2 and PHP 8.4 or higher:
278+ # - PHP 7.2 will work as it uses PHPUnit 8, which doesn't use PHP Parser yet.
279+ # - As of PHPUnit 9.3 (PHP 7.3+), PHPUnit started using PHP Parser for code coverage, and PHP Parser
280+ # also polyfills tokens, but to different (integer) values.
281+ # - Additionally, PHP Parser will block PHPUnit from running with a fatal error if it detects
282+ # non-integer values for polyfilled tokens.... _sigh_.
283+ # - So, aside from PHP 7.2, we can only run code coverage on the last PHP version (or higher)
284+ # which added a new token, which is polyfilled by both.
285+ # At the time of writing, this means PHP 8.4 or higher.
277286 php : ['7.2', '8.4']
278287 custom_ini : [false]
279288
280289 include :
281290 # Also run one coverage build with custom ini settings for testing the DisallowShortOpenTag sniff.
282291 # Also run with a disabled extension for testing the handling of unsettable ini settings by PHPCS.
283- - php : ' 8.1 '
292+ - php : ' 8.4 '
284293 os : ' ubuntu-latest'
285294 custom_ini : true
286295 extensions : ' :mysqli' # Run with mysqli disabled.
@@ -334,10 +343,16 @@ jobs:
334343 run : |
335344 if [ "${{ startsWith( steps.phpunit_version.outputs.VERSION, '11.' ) }}" == "true" ]; then
336345 echo 'FILE=phpunit.xml.dist' >> "$GITHUB_OUTPUT"
346+ echo 'WARM_CACHE=true' >> "$GITHUB_OUTPUT"
337347 elif [ "${{ startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }}" == "true" ]; then
338348 echo 'FILE=phpunit.xml.dist' >> "$GITHUB_OUTPUT"
349+ echo 'WARM_CACHE=true' >> "$GITHUB_OUTPUT"
350+ elif [ "${{ steps.phpunit_version.outputs.VERSION >= '9.3' }}" == "true" ]; then
351+ echo 'FILE=phpunit-lte9.xml.dist' >> "$GITHUB_OUTPUT"
352+ echo 'WARM_CACHE=true' >> "$GITHUB_OUTPUT"
339353 else
340354 echo 'FILE=phpunit-lte9.xml.dist' >> "$GITHUB_OUTPUT"
355+ echo 'WARM_CACHE=false' >> "$GITHUB_OUTPUT"
341356 fi
342357
343358 - name : ' PHPCS: set the path to PHP'
@@ -348,10 +363,10 @@ jobs:
348363 # As of PHPUnit 9.3.4, a cache warming option is available.
349364 # Using that option prevents issues with PHP-Parser backfilling PHP tokens during our test runs.
350365 - name : " Warm the PHPUnit cache (PHPUnit 9.3+)"
351- if : ${{ steps.phpunit_version .outputs.VERSION >= '9.3 ' }}
366+ if : ${{ steps.phpunit_config .outputs.WARM_CACHE == 'true ' }}
352367 run : >
353- php "vendor/bin/phpunit" -c ${{ steps.phpunit_config.outputs.FILE }}
354- --coverage-cache ./build/phpunit-cache --warm-coverage-cache
368+ php "vendor/bin/phpunit" -c ${{ steps.phpunit_config.outputs.FILE }} --warm-coverage-cache
369+ ${{ steps.phpunit_version.outputs.VERSION >= '9.3' && ' --coverage-cache ./build/phpunit-cache' || '' }}
355370
356371 - name : " Run the unit tests with code coverage"
357372 if : ${{ matrix.os != 'windows-latest' }}
0 commit comments