Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .claude/skills/scaffold/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ For block scaffolds, surface a developer action before testing: "run `npm run bu
| D | Re-run. Confirm that one test passes. |
| E | Loop B-D one test at a time. |
| F | Once green, refactor; re-run. |
| G | Final gates - all must pass: full PHPUnit suite (`npm run test:php`), full Jest suite if JS touched (`npm run test:js`), `composer format` (phpcbf), `composer lint` (phpcs), `composer phpstan` (PHPStan level 5), `npm run lint:js`. Never silence a real phpcs/phpstan finding with a blanket ignore; fix it, or escalate (§8). |
| G | Final gates - all must pass: full PHPUnit suite (`npm run test:php`), full Jest suite if JS touched (`npm run test:js`), `composer format` (phpcbf), `composer lint` (phpcs), `composer phpstan` (PHPStan level 8), `npm run lint:js`. Never silence a real phpcs/phpstan finding with a blanket ignore; fix it, or escalate (§8). |

Frameworks per kind:

Expand Down
2 changes: 1 addition & 1 deletion .claude/skills/setup/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ npx wp-tooling add wp/cli \

The engine emits `ai.wiring` (where to register the command) and a thin test stub at `tests/Cli/OptimizeImagesCommandTest.php`. Show the wiring snippet, get consent, apply. Then turn the stub into a real test suite (happy path, dry-run flag, edge cases, error handling) and implement `__invoke()` test-by-test until the suite is green. Never leave `markTestIncomplete` in the final state.

**Code quality (required).** For any PHP a feature scaffold writes or changes under `inc/` or `tests/`, run the compliance pipeline once the implementation is green, exactly as in the `scaffold` skill (`skills/scaffold.md` §7a): `composer format` (phpcbf) -> `composer lint` (phpcs, `rtCampWP` ruleset via `phpcs.xml.dist`) -> `composer phpstan` (PHPStan level 5 via `phpstan.neon.dist`), resolving every finding in the generated code. Write it compliant in the first place (`declare( strict_types = 1 );`, short arrays, typed signatures, prefixed globals, documented). If a fix is unclear or would change behaviour, public API, or intent, STOP and ask - never silence a real issue with a blanket `phpcs:ignore` / `@phpstan-ignore`.
**Code quality (required).** For any PHP a feature scaffold writes or changes under `inc/` or `tests/`, run the compliance pipeline once the implementation is green, exactly as in the `scaffold` skill (`skills/scaffold.md` §7a): `composer format` (phpcbf) -> `composer lint` (phpcs, `rtCampWP` ruleset via `phpcs.xml.dist`) -> `composer phpstan` (PHPStan level 8 via `phpstan.neon.dist`), resolving every finding in the generated code. Write it compliant in the first place (`declare( strict_types = 1 );`, short arrays, typed signatures, prefixed globals, documented). If a fix is unclear or would change behaviour, public API, or intent, STOP and ask - never silence a real issue with a blanket `phpcs:ignore` / `@phpstan-ignore`.

**Phase B feature scaffolds require the matching test framework from Phase A.** If Phase A skipped `setup/phpunit` because the developer did not ask for tests, surface this before running Phase B feature scaffolds:

Expand Down
1 change: 1 addition & 0 deletions .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
/*.config.js
/*.config.mjs
/*.dist
/*.neon
/AGENTS.md
/CLAUDE.md
/CONTRIBUTING.md
Expand Down
2 changes: 1 addition & 1 deletion .github/prompts/scaffold.prompt.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Apply project-sampled conventions (class suffix, sub-namespace, vendor prefix, b
Tests before implementation, no exceptions. A. Expand the engine stub into the full suite from §4; strip every `markTestIncomplete`. B. Run `composer test` (PHP) / `npm run test:js` (JS); expect red. C. Implement just enough to flip ONE test green. D. Re-run. E. Loop B-D one test at a time. F. Refactor, re-run. G. Final gates: full PHPUnit, full Jest if JS touched, PHP compliance (§7a), `npm run lint:js`. For blocks, surface `npm run build` as a developer action before testing.

### 7a. PHP compliance (required, on changed PHP)
Write compliant PHP up front (`declare( strict_types = 1 );`, short arrays, full types, prefixed globals, `@package`/`@since`, `static::`). Then: `composer format` (phpcbf) → `composer lint` (phpcs, `rtCampWP` ruleset) → `composer phpstan` (level 5). Resolve every finding in the generated code. Never silence a real issue with a blanket `phpcs:ignore`/`@phpstan-ignore`; if a fix is unclear or changes behaviour/API, STOP and ask.
Write compliant PHP up front (`declare( strict_types = 1 );`, short arrays, full types, prefixed globals, `@package`/`@since`, `static::`). Then: `composer format` (phpcbf) → `composer lint` (phpcs, `rtCampWP` ruleset) → `composer phpstan` (level 8). Resolve every finding in the generated code. Never silence a real issue with a blanket `phpcs:ignore`/`@phpstan-ignore`; if a fix is unclear or changes behaviour/API, STOP and ask.

### 8. Escalate when stuck (do not guess)
Stop and report (what you tried, observed, what's blocking, 1-3 options) after: 3 stuck C-D iterations on one test; a result contradicting your model (re-read the file); conflicting project patterns; ambiguity after one clarification.
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-measure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ jobs:
test-php-exclude: '[]'
lint-js-files-command: npm run lint:js:files
lint-css-files-command: npm run lint:css:files
enable-phpstan: true
# No tokens: every rtCamp dependency is public and the shared workflow falls
# back to GITHUB_TOKEN. A PAT here breaks all dist downloads once it expires.
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The review rules ARE the coding rules: the files Copilot reviews against are the
## Stack

- **PHP 8.2+**, Composer, PSR-4: `Project_Name\Features\` → `inc/`; tests `Project_Name\Features\Tests\` → `tests/php/` (namespace === directory, filename === class).
- **PHPUnit + `wp-phpunit`** in `tests/php/` (mirrors `inc/`), run under `wp-env`. **PHPCS** (the shared `rtCampWP` ruleset from `rtcamp/wp-phpcs`: WPCS + VIP + Docs + Slevomat) and **PHPStan** (level 5, the `rtcamp/wp-phpstan` baseline): zero errors before merge.
- **PHPUnit + `wp-phpunit`** in `tests/php/` (mirrors `inc/`), run under `wp-env`. **PHPCS** (the shared `rtCampWP` ruleset from `rtcamp/wp-phpcs`: WPCS + VIP + Docs + Slevomat) and **PHPStan** (level 8, the `rtcamp/wp-phpstan` baseline): zero errors before merge.
- **Node 24**, build via `@wordpress/scripts` + a custom `webpack.config.js`. Source in `src/{blocks,css,js}`, output in `assets/build/`.

## Structure
Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^1.2",
"php-stubs/wp-cli-stubs": "^2.12",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan-deprecation-rules": "^2.0",
"phpstan/phpstan-phpunit": "^2.1",
"phpunit/phpunit": "^9.6",
"rtcamp/wp-phpcs": "^1.0",
"rtcamp/wp-phpstan": "^1.0",
"rtcamp/wp-phpstan": "^2.0",
"wp-cli/i18n-command": "^2.4",
"wp-phpunit/wp-phpunit": "^7.1",
"yoast/phpunit-polyfills": "^4.0"
Expand Down
58 changes: 7 additions & 51 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ These stay in every project, whichever example sets you remove. Most are thin pl
| Encryption | `inc/Core/Encryption.php`, `Util::encryption()` | `Encryptor` ([utilities](https://github.com/rtCamp/wp-primitives/blob/v2.0.0/docs/utilities.md#encryptor)) | Define `ACME_CONTENT_FEATURES_ENCRYPTION_KEY` in `wp-config.php` first; without it, calls throw. `Util::encryption()->encrypt( $secret )` / `->decrypt()`. |
| Activation and i18n | `inc/Core/PluginSetup.php` | `Registrable` | Stores `acme_content_features_version` on activation, unschedules the example cron job on deactivation, loads the text domain from `languages/`. |
| Helpers | `inc/Helpers/Util.php` | — | Accessors for the shared services above, plus `get_data()` (reads `inc/data/<slug>.php`), `is_production()` and `is_mobile()`. |
| Quality checks | `tests/`, `phpcs.xml.dist`, `phpstan.neon.dist`, `eslint.config.mjs`, `.stylelintrc.json` | Shared `rtcamp/wp-phpcs`, `rtcamp/wp-phpstan`, `@rtcamp/eslint-config`, `@rtcamp/stylelint-config` | PHPUnit (one test per module), PHPCS, PHPStan level 5, ESLint, Stylelint, Jest. See [Check a change](local-development.md#check-a-change). |
| Quality checks | `tests/`, `phpcs.xml.dist`, `phpstan.neon.dist`, `eslint.config.mjs`, `.stylelintrc.json` | Shared `rtcamp/wp-phpcs`, `rtcamp/wp-phpstan`, `@rtcamp/eslint-config`, `@rtcamp/stylelint-config` | PHPUnit (one test per module), PHPCS, PHPStan level 8, ESLint, Stylelint, Jest. See [Check a change](local-development.md#check-a-change). |

The shared services (`Assets`, `Templates`, `Components`, `Logger`, `Encryption`) implement `Shareable`, so the `Loader` keeps one instance in `Main`'s container. Why that is preferred over singletons is explained in the framework's [sharing vs. singletons](https://github.com/rtCamp/wp-primitives/blob/v2.0.0/docs/architecture.md#sharing-vs-singletons).

Expand Down
1 change: 0 additions & 1 deletion docs/internal/maintenance.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ None at the moment.

Keep implementation follow-ups out of documentation pull requests; record each with a reproduction and revision when it is picked up.

- **Release zip:** no `.distignore` ships, so `release:zip` includes `src/`, `docs/`, `graphify-out/`, AI files and dotfiles.
- **Scaffold wiring targets:** `wp/rest` and `wp/cli` suggest `inc/Modules/Rest.php` and `inc/Modules/Cli.php`, but this skeleton's modules are `REST.php` and `CLI.php`, which are different files on case-sensitive filesystems. Keep the uppercase names (they match WordPress acronym style and the framework's `AbstractRESTController` / `CLICommand`); the skill adapts, and CLI users edit the existing file. Fix upstream in wp-tooling.
- **Block scaffolder:** `npm run create:block` writes meta blocks to `src/blocks/meta-blocks/`, which `Assets::STATIC_BLOCKS` cannot register.
- **Dangling references:** `PluginSetup::deactivate()` mentions a root `uninstall.php` and `Util::get_data()` reads `inc/data/`; neither ships.
Expand Down
2 changes: 1 addition & 1 deletion docs/local-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ npm run test:php # the whole suite
# PHP style and static analysis — run on the host (PHP 8.2+).
composer lint # PHPCS (rtCampWP ruleset)
composer format # PHPCBF: auto-fix what PHPCS can
composer phpstan # PHPStan level 5
composer phpstan # PHPStan level 8

# JavaScript, CSS and package.json. An initialized plugin has no Jest tests until you add one.
npm run test:js
Expand Down
2 changes: 1 addition & 1 deletion docs/scaffolding.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ With `/init` and a feature brief, the same happens during setup: init keeps the

Code should read the same whoever, or whatever, writes it:

- **The same standards, every run.** Generated code is checked against the gates a developer runs locally: [`phpcs.xml.dist`](../phpcs.xml.dist) (the shared `rtCampWP` ruleset: WPCS, VIP, docs, Slevomat), [`phpstan.neon.dist`](../phpstan.neon.dist) (the `rtcamp/wp-phpstan` level-5 baseline), [`eslint.config.mjs`](../eslint.config.mjs) and [`.stylelintrc.json`](../.stylelintrc.json).
- **The same standards, every run.** Generated code is checked against the gates a developer runs locally: [`phpcs.xml.dist`](../phpcs.xml.dist) (the shared `rtCampWP` ruleset: WPCS, VIP, docs, Slevomat), [`phpstan.neon.dist`](../phpstan.neon.dist) (the `rtcamp/wp-phpstan` level-8 baseline), [`eslint.config.mjs`](../eslint.config.mjs) and [`.stylelintrc.json`](../.stylelintrc.json).
- **Verified, not just formatted.** The AI route writes the test first and runs it, then PHPCBF → PHPCS → PHPStan.
- **No drift between developers.** Registration, wiring and lifecycle come from the [`rtcamp/wp-primitives`](https://github.com/rtCamp/wp-primitives/blob/v2.0.0/docs/abstracts.md) abstracts, so the structure is identical whoever generates it; review can focus on the logic.

Expand Down
6 changes: 3 additions & 3 deletions inc/Modules/Blocks/ExampleDynamicBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ protected function get_block_dir(): string {
/**
* {@inheritDoc}
*
* @param array $attributes Block attributes.
* @param string $content Block inner content.
* @param \WP_Block $block Full block instance.
* @param array<string, mixed> $attributes Block attributes.
* @param string $content Block inner content.
* @param \WP_Block $block Full block instance.
*
* @return string Rendered block HTML.
*/
Expand Down
4 changes: 2 additions & 2 deletions inc/Modules/CLI/Healthcheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public static function get_description(): string {
/**
* {@inheritDoc}
*
* @param array $args Positional arguments passed to the command.
* @param array $assoc_args Associative arguments passed to the command.
* @param array<int, mixed> $args Positional arguments passed to the command.
* @param array<string, mixed> $assoc_args Associative arguments passed to the command.
*
* @return void
*/
Expand Down
4 changes: 2 additions & 2 deletions inc/Modules/PostTypes/ExamplePostType.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ public static function get_slug(): string {
* {@inheritDoc}
*/
public function get_singular_label(): string {
return __( 'Post Type Label', 'project-name-features' );
return __( 'Post Type Label', 'project-name-features' ) ?: 'Post Type Label';
}

/**
* {@inheritDoc}
*/
public function get_plural_label(): string {
return __( 'Post Type Labels', 'project-name-features' );
return __( 'Post Type Labels', 'project-name-features' ) ?: 'Post Type Labels';
}

/**
Expand Down
4 changes: 2 additions & 2 deletions inc/Modules/PostTypes/ExamplePostTypeTwo.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ public static function get_slug(): string {
* {@inheritDoc}
*/
public function get_singular_label(): string {
return __( 'Post Type Two Label', 'project-name-features' );
return __( 'Post Type Two Label', 'project-name-features' ) ?: 'Post Type Two Label';
}

/**
* {@inheritDoc}
*/
public function get_plural_label(): string {
return __( 'Post Type Two Labels', 'project-name-features' );
return __( 'Post Type Two Labels', 'project-name-features' ) ?: 'Post Type Two Labels';
}

/**
Expand Down
2 changes: 1 addition & 1 deletion inc/Modules/Roles/ExampleUserRole.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static function get_slug(): string {
* {@inheritDoc}
*/
protected function get_display_name(): string {
return __( 'Content Editor', 'project-name-features' );
return __( 'Content Editor', 'project-name-features' ) ?: 'Content Editor';
}

/**
Expand Down
4 changes: 2 additions & 2 deletions inc/Modules/Shortcodes/ExampleShortcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ protected function default_atts(): array {
/**
* {@inheritDoc}
*
* @param array $atts Shortcode attributes.
* @param string|null $content Shortcode inner content.
* @param array<string, mixed> $atts Shortcode attributes.
* @param string|null $content Shortcode inner content.
*
* @return string Rendered shortcode output.
*/
Expand Down
4 changes: 2 additions & 2 deletions inc/Modules/Taxonomies/ExampleTaxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ public static function get_object_types(): array {
* {@inheritDoc}
*/
public function get_singular_label(): string {
return __( 'Taxonomy Label', 'project-name-features' );
return __( 'Taxonomy Label', 'project-name-features' ) ?: 'Taxonomy Label';
}

/**
* {@inheritDoc}
*/
public function get_plural_label(): string {
return __( 'Taxonomy Labels', 'project-name-features' );
return __( 'Taxonomy Labels', 'project-name-features' ) ?: 'Taxonomy Labels';
}

/**
Expand Down
4 changes: 2 additions & 2 deletions inc/Modules/Taxonomies/ExampleTaxonomyTwo.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ public static function get_object_types(): array {
* {@inheritDoc}
*/
public function get_singular_label(): string {
return __( 'Taxonomy Two Label', 'project-name-features' );
return __( 'Taxonomy Two Label', 'project-name-features' ) ?: 'Taxonomy Two Label';
}

/**
* {@inheritDoc}
*/
public function get_plural_label(): string {
return __( 'Taxonomy Two Labels', 'project-name-features' );
return __( 'Taxonomy Two Labels', 'project-name-features' ) ?: 'Taxonomy Two Labels';
}
}
2 changes: 2 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
parameters:
ignoreErrors: []
Loading
Loading