Skip to content

Make the PHPStan sites/files exclusion test actually run PHPStan - #54

Merged
UltraBob merged 1 commit into
mainfrom
fix-vacuous-phpstan-exclusion-test
Aug 8, 2026
Merged

Make the PHPStan sites/files exclusion test actually run PHPStan#54
UltraBob merged 1 commit into
mainfrom
fix-vacuous-phpstan-exclusion-test

Conversation

@UltraBob

@UltraBob UltraBob commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Closes #50.

Problem

The quick test phpstan excludes nested files directory descendants ran in a bare project with no composer.json, so the installer never installed vendor/bin/phpstan and the wrapper exited 127 before any analysis. Both assertions passed vacuously — the test would have stayed green even with the excludePaths entries completely broken.

Fix

  • Delete the vacuous quick test (its config-presence aspect is already covered by the grep assertions in phpstan config includes default paths and excludes after install).
  • Move the behavioral coverage into the DCQ_FULL_TESTS=1 full-install test, where real PHPStan runs: a valid-PHP probe file at web/sites/default/files/php/twig/test-subdir/should-not-scan.php joins the shared fixtures, and a phpstan analyse --debug -c phpstan.neon web/sites run asserts the per-file listing omits it.
  • Add a positive control: the listing must contain sites/default/settings.php, so the exclusion check fails loudly if PHPStan ever stops analysing instead of passing silently. The probe is deliberately valid PHP because error output alone cannot distinguish "excluded" from "analysed and clean" — only the --debug file listing can.

Tests

DCQ_FULL_TESTS=1 bats ./tests/test.bats --filter "fresh install" passes locally (127s), confirming settings.php appears in the analysed-file listing while the probe does not.

The quick test "phpstan excludes nested files directory descendants"
ran in a bare project with no composer.json, so vendor/bin/phpstan was
never installed and the wrapper exited 127 before any analysis. Both
assertions then passed vacuously: the output could never contain the
probe file path because PHPStan never listed any files at all (#50).

Move the coverage into the full-install test, where real PHPStan runs.
The probe file under sites/default/files/php/twig/ is valid PHP, so
error output cannot distinguish "excluded" from "analysed and clean";
the --debug per-file listing can. A positive control asserts
sites/default/settings.php appears in that listing, so the exclusion
check fails loudly if PHPStan ever stops analysing rather than passing
silently again.
@UltraBob
UltraBob merged commit 3ab96b9 into main Aug 8, 2026
5 checks passed
@UltraBob
UltraBob deleted the fix-vacuous-phpstan-exclusion-test branch August 8, 2026 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bats test "phpstan excludes nested files directory descendants" passes vacuously without running PHPStan

1 participant