Skip to content

feat(testing): add a PHP adapter to the cannot-fail scanner (PHPUnit, Pest) #6237

Closed as not planned

Description

@kyle-sexton

Summary

The testing plugin's cannot-fail scanner (/testing:audit, and the test-scan and test-weaken hooks that run the same engine) covers JS/TS, Python, C#, Bash, PowerShell and Go. PHP test files are never enumerated, so a PHPUnit or Pest test with no assertion, or one that can only pass, goes unreported and the hooks never fire on a PHP test edit. Add a PHP adapter for PHPUnit and Pest.

Assertion forms to recognize:

Scope

  • plugins/testing/skills/audit/adapters/php-phpunit.yaml and php-pest.yaml: files: globs (for example *Test.php; confirm against each framework's conventions), test_start for PHPUnit public function test*( and #[Test]-attributed methods and Pest test( and it( closures, test_skip (markTestSkipped, markTestIncomplete, Pest ->skip() and ->todo()), and the assertion, weak, inert (assertTrue(true), expect(true)->toBeTrue()), count (assertCount, ->toHaveCount), fail (fail() and mock (createMock, ->expects(, Mockery shouldReceive) token sets. expectException() is an oracle and must count.
  • Masker: add mask_php to plugins/testing/skills/audit/scripts/cant-fail-scan.awk: //, # and /* */ comments (but #[ opens an attribute, not a comment), ' and " strings with {$var} interpolation, and heredoc (<<<TAG) and nowdoc (<<<'TAG') bodies masked to their closing tag line, which may be indented. mask_sh's heredoc state is a model to borrow from. Register it in mask_open and route language: php to it.
  • Corpus fixtures under plugins/testing/skills/audit/evals/fixtures/corpus/<adapter-id>/{bad,good}/ (stored as .fixture), each listed in corpus_files in cant-fail-scan.test.sh.
  • Regenerate plugins/testing/hooks/hooks.json with plugins/testing/scripts/gen-hook-filters.sh so the hooks' if rows include the new globs.
  • Add PHP to the language lists in plugins/testing/skills/audit/SKILL.md (description and ecosystems paragraph) and plugins/testing/README.md.
  • Version bump and CHANGELOG entry for testing.

Acceptance criteria

  • A PHPUnit test method and a Pest test() closure with no assertion each report rule-zero-assertion.
  • A test with one real assertion in each framework, in each of PHPUnit's four spellings, reports nothing.
  • A Pest ->and() chain is classified per statement: a chain holding a real matcher stays quiet, and one whose matchers are all inert is flagged.
  • An assertion token inside a # or // comment, a heredoc or a nowdoc does not count as an assertion; a #[Test] attribute line is not masked as a comment.
  • A skipped test (markTestSkipped, Pest ->skip()) is not reported as zero-assertion.
  • Every new fixture is in corpus_files, and cant-fail-scan.test.sh and check-corpus-grid.sh pass.
  • gen-hook-filters.sh --check passes after regeneration, and gen-hook-filters.test.sh passes.

Dependencies

Land after the in-flight scanner PR for #6211, #6218 and #6040, since all of them edit cant-fail-scan.awk, the corpus list and hooks.json. Run the four language adapters (Kotlin, C++, PHP, Ruby) one at a time for the same reason.

Rough size

Medium: a new masker (heredoc and nowdoc state, # versus #[) plus Pest's chained-expectation classification. Statements end in ; and blocks use braces, so the existing brace block model fits.

Activity

  1. github-actions commented on Oct 4, 2026

    @github-actions
    Contributor

    Thanks for the detailed writeup. This asks for a new PHP adapter (PHPUnit + Pest) for the cannot-fail scanner, covering the masker, corpus fixtures, hook filter regen, and docs updates — scope and acceptance criteria are clear and nothing appears missing.

    This is part of a series alongside similar adapter requests for Kotlin (#6235), C++ (#6236), and Ruby (#6238); not a duplicate, but worth sequencing per the stated dependency on the in-flight scanner work and running the four adapters one at a time as noted.

    Automated triage. A maintainer reviews it.

  2. added
    good first issue
    on Oct 4, 2026
  3. kyle-sexton commented on Oct 13, 2026

    @kyle-sexton
    MemberAuthor

    Owner decision (2026-10-13): approved the recommendation.

    Next: nobody acts now. Pick it up when one of the triggers above appears.

    This was generated by AI.

  4. removed
    good first issue
    on Oct 15, 2026
  5. added
    needs-human
    on Oct 19, 2026
  6. kyle-sexton commented on Oct 19, 2026

    @kyle-sexton
    MemberAuthor

    This was generated by AI during triage.

    Hold: the owner decision of 2026-10-13 parks this adapter until a repository the owner works in uses PHP or an outside user asks for it; neither trigger has happened.

  7. kyle-sexton commented on Oct 24, 2026

    @kyle-sexton
    MemberAuthor

    Decision recorded. Owner, Backlog HITL session, 2026-10-24. Q99: "Should the six issues parked until demand appears close as not planned, each with a reopen note?" Answer: "yes, go w/ recomended". To reopen: reopen this issue when a repo uses this or a user asks for it; the body and decisions above stay as the spec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-human

    Fields

    No fields configured for Feature.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions