Skip to content

Commit 577ff65

Browse files
fix: keep rule documentation in sync
1 parent 6692a95 commit 577ff65

3 files changed

Lines changed: 66 additions & 1 deletion

File tree

AGENTS.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# SymPress Coding Standards agent contract
2+
3+
## Purpose and boundaries
4+
5+
This package owns reusable PHPCS profiles and the custom `SymPress.*` sniffs. Reuse an established vendor sniff before adding a custom rule. Keep WordPress-specific allowances out of the pure PHP layer.
6+
7+
## Read first
8+
9+
- `docs/Rules.md`: intent, severity and false-positive posture for every custom rule.
10+
- `docs/Sniffs.md`: compact custom-sniff inventory.
11+
- `docs/Compatibility.md` and `docs/Adoption.md`: supported profiles and rollout policy.
12+
- `SymPress-*/ruleset.xml`: public profile composition.
13+
- `tests/fixtures` and `tests/unit/FixturesTest.php`: executable sniff expectations.
14+
15+
## Verification
16+
17+
- Fast for one sniff: run the matching PHPUnit test or `composer tests -- --filter <name>`.
18+
- Full: `composer qa`.
19+
- Use `composer cs:fix` only for intended mechanical fixes, then inspect the diff.
20+
21+
## Invariants
22+
23+
- New custom sniffs must fill a documented gap rather than duplicate a vendor rule.
24+
- Pure, WordPress, boundary and template profiles keep their layer-specific responsibilities.
25+
- Every custom sniff needs fixture expectations and entries in both documentation catalogs.
26+
- Fixers must be idempotent and preserve semantics.
27+
- Runtime and compatibility claims must match `composer.json` and the public rulesets.
28+
29+
## Cross-repository impact
30+
31+
`sympress/qa` and most SymPress PHP repositories consume these profiles. A changed default severity or profile inclusion can break every consumer and requires release notes plus representative downstream validation.
32+
33+
## Definition of done
34+
35+
Fixtures cover positive and negative behavior, catalog validation passes, `composer qa` is green, and compatibility/changelog text matches the manifest.

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The format follows Keep a Changelog style sections and semantic versioning.
1313

1414
### Changed
1515

16-
- Lowered the package runtime requirement to PHP 8.2+ while keeping explicit profile targets for newer PHP and WordPress stacks.
16+
- Raised the package runtime requirement to PHP 8.5+.
1717
- Allowed stable PHPCompatibility 9.x in addition to PHPCompatibility 10 alpha releases.
1818
- Made base layers version-neutral and mapped `SymPress-Plugin`, `SymPress-Core`, and `SymPress-Extra` to `SymPress-Enterprise-Next`.
1919
- Updated `SymPress-Templates` to include the WordPress security layer before applying template-specific rules.

tests/unit/RulesetConfigurationTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,34 @@ public function testConfiguredWordPressMinimumUsesWpcsThreeConfigName(string $ru
4545
$contents,
4646
);
4747
}
48+
49+
public function testCustomSniffCatalogsMatchImplementations(): void
50+
{
51+
$libPath = rtrim((string) getenv('LIB_PATH'), '/');
52+
$implemented = [];
53+
54+
foreach (glob("{$libPath}/SymPress/Sniffs/*/*Sniff.php") ?: [] as $file) {
55+
$relative = substr($file, strlen("{$libPath}/SymPress/Sniffs/"));
56+
[$category, $class] = explode('/', $relative);
57+
$implemented[] = sprintf('SymPress.%s.%s', $category, substr($class, 0, -strlen('Sniff.php')));
58+
}
59+
60+
sort($implemented);
61+
62+
foreach (['docs/Sniffs.md', 'docs/Rules.md'] as $documentation) {
63+
preg_match_all(
64+
'/`(SymPress\.[A-Za-z0-9.]+)`/',
65+
(string) file_get_contents("{$libPath}/{$documentation}"),
66+
$matches,
67+
);
68+
$documented = $matches[1];
69+
sort($documented);
70+
71+
self::assertSame(
72+
$implemented,
73+
$documented,
74+
"{$documentation} must list every implemented custom sniff once.",
75+
);
76+
}
77+
}
4878
}

0 commit comments

Comments
 (0)