Skip to content

Commit df73374

Browse files
authored
chore: clarify the compatibility and static-analysis rules for agent reviewers (#10629)
1 parent 8e2db88 commit df73374

3 files changed

Lines changed: 37 additions & 5 deletions

File tree

‎.github/copilot-instructions.md‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,15 @@ Prioritize actionable findings involving:
2323
## Review behavior
2424

2525
- Determine the PR base branch and apply the compatibility policy from
26-
`AGENTS.md`. If the base branch cannot be determined, assume `develop`
27-
and state that assumption.
26+
`AGENTS.md`. When it is not visible, read it from the title prefix and
27+
the labels as `AGENTS.md` describes, and otherwise assume `develop` and
28+
state that assumption.
29+
- Before reporting a compatibility break, confirm the symbol exists in the
30+
latest tagged release. A symbol introduced on the base branch since that
31+
release is unreleased and may change freely, as `AGENTS.md` describes.
32+
- Do not report a PHPStan suppression or baseline entry covered by the
33+
exceptions in `AGENTS.md`, or a missing reset of state that
34+
`CIUnitTestCase::tearDown()` already restores.
2835
- Do not report formatting-only issues already enforced by PHP-CS-Fixer.
2936
- Every finding should identify a concrete failure scenario and the
3037
affected code.

‎.github/instructions/tests.instructions.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ applyTo: "tests/**/*.php"
1414
Avoid testing private implementation details.
1515
- Restore services, factories, environment variables, superglobals, handlers,
1616
locale, time-related state, and other global state modified by a test.
17+
Check `CIUnitTestCase::tearDown()` first: a test need not repeat the
18+
resets it already performs.
1719
- Tests must not depend on execution order or state left by another test.
1820
- Do not replace a meaningful assertion with a weaker assertion to make a test
1921
pass.

‎AGENTS.md‎

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,13 @@ existing implementation before introducing a new abstraction or convention.
1919
## Target branch and compatibility policy
2020

2121
Compatibility is judged against the pull request's base branch, not the
22-
contributor's source or feature branch. When the base branch is unknown,
23-
apply the stricter `develop` policy.
22+
contributor's source or feature branch. When the base branch is not stated,
23+
take the cues from the title prefix and the labels. A `feat:` prefix and the
24+
`enhancement`, `new feature`, `breaking change`, or `4.x` labels point to the
25+
next minor branch. A `fix:`, `refactor:`, or `docs:` prefix and the `bug` or
26+
`refactor` labels can go either way, since the next minor branch also takes
27+
fixes to its own unreleased code, so look at what the change touches. When no
28+
cue settles it, apply the stricter `develop` policy.
2429

2530
### Base branch `develop`
2631

@@ -50,6 +55,16 @@ complete the documented deprecation lifecycle.
5055
- Every accepted break needs tests for the new behavior, a minor-version
5156
changelog entry, and migration instructions in the upgrading guide.
5257

58+
### Unreleased API
59+
60+
A symbol first added on the base branch after its latest tagged release is
61+
unreleased. Nothing outside the repository can depend on it yet, so changing,
62+
renaming, or removing it is not a compatibility break: it needs no
63+
deprecation, no upgrading-guide entry, and no changelog line beyond the one
64+
describing the final shape. Check the version tags or the changelog of the
65+
unreleased version before reporting a break on such a symbol. The
66+
compatibility policy applies to what the latest tagged release ships.
67+
5368
### All base branches
5469

5570
- Production code must run on PHP 8.2. Do not require a newer PHP version,
@@ -83,7 +98,15 @@ complete the documented deprecation lifecycle.
8398
- Add PHPDoc only when it contributes information that native types cannot
8499
express. Do not duplicate a parent or interface docblock.
85100
- Never suppress a static-analysis error or update a baseline to make a
86-
check pass.
101+
check pass. The accepted exceptions are:
102+
- a false positive, when the usage is judged correct;
103+
- a suppression needed to assert a runtime behavior in a test;
104+
- a call to a function mocked in `system/Test/Mock/MockCommon.php`, such
105+
as `is_cli(false)`, which PHPStan reports as `arguments.count`.
106+
107+
Regenerate the baseline with `composer phpstan:baseline`, never by editing
108+
the `.neon` files, and add a test file that calls `is_cli()` with an
109+
argument to the `RemoveExtraParametersRector` skip list in `rector.php`.
87110

88111
## FrankenPHP Worker Mode
89112

0 commit comments

Comments
 (0)