From 1bc1e59df2a4790e6162d4186bd76acc1b9a2845 Mon Sep 17 00:00:00 2001 From: Aryan Jasala Date: Mon, 28 Sep 2026 05:15:35 +0530 Subject: [PATCH 1/3] chore: rename wp-framework to wp-primitives --- .github/copilot-instructions.md | 10 +++--- .github/instructions/php.instructions.md | 2 +- .wp-env.json | 2 +- AGENTS.md | 14 ++++---- CHANGELOG.md | 19 ++++++++--- CONTRIBUTING.md | 6 ++-- README.md | 18 +++++------ ...ions.md => primitives-php.instructions.md} | 6 ++-- bin/sync-ai-instructions.js | 14 ++++---- composer.json | 12 +++---- docs/ai-review-system.md | 16 +++++----- docs/branding.json | 2 +- docs/contracts.md | 4 +-- docs/getting-started.md | 20 ++++++------ docs/index.md | 4 +-- docs/maintainers.md | 10 +++--- docs/troubleshooting.md | 4 +-- docs/upgrading.md | 4 +-- inc/AssetLoader.php | 14 ++++---- inc/ComponentLoader.php | 8 ++--- inc/Container.php | 4 +-- inc/Contracts/Abstracts/AbstractAbility.php | 4 +-- .../Abstracts/AbstractAbilityRegistrar.php | 6 ++-- inc/Contracts/Abstracts/AbstractAdminPage.php | 6 ++-- inc/Contracts/Abstracts/AbstractBlock.php | 6 ++-- inc/Contracts/Abstracts/AbstractFeature.php | 8 ++--- inc/Contracts/Abstracts/AbstractModule.php | 8 ++--- inc/Contracts/Abstracts/AbstractPostType.php | 6 ++-- .../Abstracts/AbstractRESTController.php | 6 ++-- .../Abstracts/AbstractSettingsPage.php | 6 ++-- inc/Contracts/Abstracts/AbstractShortcode.php | 6 ++-- inc/Contracts/Abstracts/AbstractTaxonomy.php | 6 ++-- inc/Contracts/Abstracts/AbstractUserRole.php | 6 ++-- inc/Contracts/Interfaces/CLICommand.php | 4 +-- .../Interfaces/ConditionallyRegistrable.php | 4 +-- inc/Contracts/Interfaces/Registrable.php | 4 +-- inc/Contracts/Interfaces/Shareable.php | 4 +-- inc/Contracts/Traits/Loader.php | 12 +++---- inc/Contracts/Traits/Singleton.php | 8 ++--- inc/TemplateLoader.php | 4 +-- inc/Utils/Cache.php | 6 ++-- inc/Utils/Encryptor.php | 4 +-- inc/Utils/FeatureSelector.php | 10 +++--- inc/Utils/FeatureSelectorSettingsPage.php | 14 ++++---- inc/Utils/Logger.php | 6 ++-- inc/Utils/Timer.php | 22 ++++++------- inc/Utils/Transients.php | 4 +-- package-lock.json | 4 +-- package.json | 8 ++--- phpcs.xml.dist | 4 +-- phpstan.neon.dist | 2 +- tests/AssetLoaderHandleTest.php | 10 +++--- tests/AssetLoaderTest.php | 18 +++++------ tests/Components/ComponentLoaderTest.php | 32 +++++++++---------- tests/ContainerTest.php | 6 ++-- .../AbstractAbilityRegistrarTest.php | 12 +++---- .../Abstracts/AbstractAbilityTest.php | 8 ++--- .../Abstracts/AbstractAdminPageTest.php | 8 ++--- .../Contracts/Abstracts/AbstractBlockTest.php | 20 ++++++------ .../Abstracts/AbstractFeatureTest.php | 12 +++---- .../Abstracts/AbstractModuleTest.php | 12 +++---- .../Abstracts/AbstractPostTypeTest.php | 8 ++--- .../Abstracts/AbstractRESTControllerTest.php | 8 ++--- .../Abstracts/AbstractSettingsPageTest.php | 8 ++--- .../Abstracts/AbstractShortcodeTest.php | 8 ++--- .../Abstracts/AbstractTaxonomyTest.php | 8 ++--- .../Abstracts/AbstractUserRoleTest.php | 8 ++--- .../Interfaces/InterfaceContractsTest.php | 12 +++---- tests/Fixtures/BareSingleton.php | 6 ++-- tests/Fixtures/FlakySingleton.php | 6 ++-- tests/Fixtures/LoaderFixtures.php | 12 +++---- tests/Fixtures/ReentrantSingleton.php | 6 ++-- tests/Fixtures/SingletonExample.php | 6 ++-- tests/LoaderTest.php | 16 +++++----- tests/SingletonTest.php | 14 ++++---- tests/TemplateLoaderTest.php | 6 ++-- tests/TestCase.php | 4 +-- tests/Utils/CacheTest.php | 8 ++--- tests/Utils/EncryptorTest.php | 8 ++--- .../Utils/FeatureSelectorSettingsPageTest.php | 10 +++--- tests/Utils/FeatureSelectorTest.php | 16 +++++----- tests/Utils/LoggerTest.php | 8 ++--- tests/Utils/TimerTest.php | 8 ++--- tests/Utils/TransientsTest.php | 8 ++--- tests/bootstrap.php | 2 +- 85 files changed, 372 insertions(+), 361 deletions(-) rename ai/{framework-php.instructions.md => primitives-php.instructions.md} (93%) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 9ef72e1..f8e9021 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -1,14 +1,14 @@ -# Copilot instructions — wp-framework +# Copilot instructions — wp-primitives -`rtcamp/wp-framework`: shared base contracts (interfaces, abstracts, traits) and small utilities consumed via Composer by every rtCamp plugin/theme skeleton. **Zero runtime dependencies.** PHP 8.2+. +`rtcamp/wp-primitives`: shared base contracts (interfaces, abstracts, traits) and small utilities consumed via Composer by every rtCamp plugin/theme skeleton. **Zero runtime dependencies.** PHP 8.2+. -This repo defines the framework itself. The rules for *consuming* it live in `ai/framework-php.instructions.md` (shipped to consumers); keep it in sync when contracts change. +This repo defines the framework itself. The rules for *consuming* it live in `ai/primitives-php.instructions.md` (shipped to consumers); keep it in sync when contracts change. Detailed rules: `.github/instructions/php.instructions.md`. ## Stack -- PHP 8.2+, PSR-4 `rtCamp\WPFramework\` → `inc/`; tests `rtCamp\WPFramework\Tests\` → `tests/`. +- PHP 8.2+, PSR-4 `rtCamp\WPPrimitives\` → `inc/`; tests `rtCamp\WPPrimitives\Tests\` → `tests/`. - PHPUnit; PHPCS (WordPress-Core/Extra/Docs + VIPCS); PHPStan. Zero errors before merge. - `require` in `composer.json` holds **only** `php`. Everything else is `require-dev`. @@ -16,7 +16,7 @@ Detailed rules: `.github/instructions/php.instructions.md`. - **TDD**: failing PHPUnit test first (`tests/` mirrors `inc/`), then code. - **`inc/Contracts/` is public API.** Interfaces, abstracts and their method signatures are consumed by every plugin/theme: a signature change breaks all of them. Treat changes as breaking. -- When you change a contract, update `ai/framework-php.instructions.md` so the consumer review rules stay accurate. +- When you change a contract, update `ai/primitives-php.instructions.md` so the consumer review rules stay accurate. - No runtime dependencies. Prefer official WordPress / PHP stdlib. ## Review conduct diff --git a/.github/instructions/php.instructions.md b/.github/instructions/php.instructions.md index 69d16b8..d5064a1 100644 --- a/.github/instructions/php.instructions.md +++ b/.github/instructions/php.instructions.md @@ -1,6 +1,6 @@ --- applyTo: "inc/**/*.php" -description: "Framework-development rules for rtcamp/wp-framework PHP." +description: "Framework-development rules for rtcamp/wp-primitives PHP." --- # Framework PHP rules diff --git a/.wp-env.json b/.wp-env.json index 977ec8a..5c73a34 100644 --- a/.wp-env.json +++ b/.wp-env.json @@ -2,7 +2,7 @@ "core": null, "phpVersion": "8.2", "mappings": { - "wp-content/wp-framework-rt": "." + "wp-content/wp-primitives-rt": "." }, "env": { "tests": { diff --git a/AGENTS.md b/AGENTS.md index 101772d..ed8d25f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,6 +1,6 @@ -# AGENTS.md — wp-framework +# AGENTS.md — wp-primitives -Tool-agnostic brief for AI coding agents (Claude Code, Copilot coding agent, Codex). `rtcamp/wp-framework`: shared base contracts (interfaces, abstracts, traits) and small utilities consumed via Composer by every rtCamp plugin/theme skeleton. **Zero Composer runtime dependencies.** PHP 8.2+, WordPress 6.5+ — the floor is set by the Script Modules API (`wp_register_script_module()`, new in 6.5). The APIs used above 6.5 are `wp_register_block_types_from_metadata_collection()` (6.8+), which `AssetLoader::register_block_manifest()` guards with a per-block fallback for 6.5–6.7, and the Abilities API (6.9+), which the ability abstracts reach only through `wp_abilities_api_*` hooks that never fire on older cores. `Encryptor` requires the OpenSSL PHP extension when used. +Tool-agnostic brief for AI coding agents (Claude Code, Copilot coding agent, Codex). `rtcamp/wp-primitives`: shared base contracts (interfaces, abstracts, traits) and small utilities consumed via Composer by every rtCamp plugin/theme skeleton. **Zero Composer runtime dependencies.** PHP 8.2+, WordPress 6.5+ — the floor is set by the Script Modules API (`wp_register_script_module()`, new in 6.5). The APIs used above 6.5 are `wp_register_block_types_from_metadata_collection()` (6.8+), which `AssetLoader::register_block_manifest()` guards with a per-block fallback for 6.5–6.7, and the Abilities API (6.9+), which the ability abstracts reach only through `wp_abilities_api_*` hooks that never fire on older cores. `Encryptor` requires the OpenSSL PHP extension when used. ## Authoritative rules @@ -12,9 +12,9 @@ Tool-agnostic brief for AI coding agents (Claude Code, Copilot coding agent, Cod - **`inc/Contracts/` is public API.** Interfaces, abstracts, and their method signatures are consumed by every plugin/theme: a signature change breaks all of them. Treat such changes as breaking. - **Zero Composer runtime deps**: `composer.json` `require` holds only `php`; everything else is `require-dev`. - **TDD**: failing PHPUnit test first (`tests/` mirrors `inc/`), then code. -- **Tests run against real WordPress via wp-env** — no WP function mocking. `npm run wp-env start` then `npm run test:php` (a `pretest:php` hook runs `composer install` in the container first). WP-dependent tests extend `rtCamp\WPFramework\Tests\TestCase` (a `WP_UnitTestCase`); pure-logic tests can stay on `PHPUnit\Framework\TestCase`. CI runs a PHP × WP matrix (PHP 8.2+, WP 6.5+). -- `declare( strict_types = 1 );`, full types, `@package`/`@since`, `static::` not `self::`, PSR-4 (`rtCamp\WPFramework\` → `inc/`). -- **When you change a contract, update `ai/framework-php.instructions.md`**: the rules file shipped to consumers and synced into their `.github/` by `bin/sync-ai-instructions.js` (`npm run sync-ai`). +- **Tests run against real WordPress via wp-env** — no WP function mocking. `npm run wp-env start` then `npm run test:php` (a `pretest:php` hook runs `composer install` in the container first). WP-dependent tests extend `rtCamp\WPPrimitives\Tests\TestCase` (a `WP_UnitTestCase`); pure-logic tests can stay on `PHPUnit\Framework\TestCase`. CI runs a PHP × WP matrix (PHP 8.2+, WP 6.5+). +- `declare( strict_types = 1 );`, full types, `@package`/`@since`, `static::` not `self::`, PSR-4 (`rtCamp\WPPrimitives\` → `inc/`). +- **When you change a contract, update `ai/primitives-php.instructions.md`**: the rules file shipped to consumers and synced into their `.github/` by `bin/sync-ai-instructions.js` (`npm run sync-ai`). ## Structure @@ -22,5 +22,5 @@ Tool-agnostic brief for AI coding agents (Claude Code, Copilot coding agent, Cod ## This repo also ships tooling for consumers -- `ai/framework-php.instructions.md`: the canonical framework+WordPress review rules. -- `bin/sync-ai-instructions.js`: run from a consumer via `npm run sync-ai` (chained from `npm run init`). Refreshes each package's `framework-php.instructions.md` from its vendored copy of this doc, then projects every package's instructions up to the `wp-content` repo root for Copilot review. Standalone packages get the refresh only. `--check` for CI. +- `ai/primitives-php.instructions.md`: the canonical framework+WordPress review rules. +- `bin/sync-ai-instructions.js`: run from a consumer via `npm run sync-ai` (chained from `npm run init`). Refreshes each package's `primitives-php.instructions.md` from its vendored copy of this doc, then projects every package's instructions up to the `wp-content` repo root for Copilot review. Standalone packages get the refresh only. `--check` for CI. diff --git a/CHANGELOG.md b/CHANGELOG.md index fc624ef..d44c14d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,23 @@ # Changelog -All notable changes to `rtcamp/wp-framework` are documented here. +All notable changes to `rtcamp/wp-primitives` are documented here. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Changed + +- **BREAKING: renamed the package from `rtcamp/wp-framework` to `rtcamp/wp-primitives`.** + The PHP namespace moves from `rtCamp\WPFramework\` to `rtCamp\WPPrimitives\`, the + repository moves to `rtCamp/wp-primitives`, and the AI rules file shipped to consumers + is renamed from `ai/framework-php.instructions.md` to `ai/primitives-php.instructions.md` + (synced into consumers as `.github/instructions/primitives-php.instructions.md`). + Consumers must move to a `^2.0` constraint; `^1.0` continues to resolve from the + existing `v1.0.0` / `v1.0.1` tags, which keep the old package name. + Reason: `10up/wp-framework` occupies the same name in the same category on Packagist. + ### Documentation - Added implementor getting-started and maintainer workflow guides; corrected @@ -79,6 +90,6 @@ Initial release. Requires PHP 8.2+. - Reference documentation under `docs/`, a GPL-2.0-or-later `LICENSE.md`, and a WordPress integration test suite running against `@wordpress/env`. -[Unreleased]: https://github.com/rtCamp/wp-framework/compare/v1.0.1...HEAD -[1.0.1]: https://github.com/rtCamp/wp-framework/compare/v1.0.0...v1.0.1 -[1.0.0]: https://github.com/rtCamp/wp-framework/releases/tag/v1.0.0 +[Unreleased]: https://github.com/rtCamp/wp-primitives/compare/v1.0.1...HEAD +[1.0.1]: https://github.com/rtCamp/wp-primitives/compare/v1.0.0...v1.0.1 +[1.0.0]: https://github.com/rtCamp/wp-primitives/releases/tag/v1.0.0 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 60936f9..e602c34 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,6 @@ -# Contributing to wp-framework +# Contributing to wp-primitives -Thanks for your interest in improving `rtcamp/wp-framework`. This is a +Thanks for your interest in improving `rtcamp/wp-primitives`. This is a **library** — a shared PHP base consumed as a Composer package by rtCamp WordPress plugins and themes — so its public contract (`inc/Contracts/`) is treated as stable and changes to it are considered breaking. @@ -58,7 +58,7 @@ contract-change, and documentation guidance. - [ ] `composer lint`, `composer analyse`, and `npm run test:php` pass. - [ ] New/changed behavior is covered by tests. - [ ] Any change to `inc/Contracts/` is flagged as breaking in the PR description. -- [ ] Contract changes are reflected in `ai/framework-php.instructions.md`. +- [ ] Contract changes are reflected in `ai/primitives-php.instructions.md`. - [ ] User-visible behavior is reflected in `README.md` or `docs/`. - [ ] A `CHANGELOG.md` entry is added under `## [Unreleased]`. - [ ] Commits follow [Conventional Commits](https://www.conventionalcommits.org/). diff --git a/README.md b/README.md index bf8b426..0bd88cd 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -

wp-framework

+

wp-primitives

License: GPL-2.0-or-later @@ -8,14 +8,14 @@

A shared PHP base for WordPress projects, distributed as a Composer package - (rtcamp/wp-framework). It ships the contracts, loaders, and + (rtcamp/wp-primitives). It ships the contracts, loaders, and utilities that plugins and themes boot through — so you write intent instead of registration boilerplate.

--- -`wp-framework` is a **library, not a plugin**. It ships contracts (interfaces, +`wp-primitives` is a **library, not a plugin**. It ships contracts (interfaces, abstracts, traits) plus concrete loaders and utilities; consuming plugins and themes build their features on top. It has **zero Composer runtime dependencies**. @@ -34,26 +34,26 @@ Not on public Packagist — add the repository to the consuming project's ```json { "repositories": [ - { "type": "vcs", "url": "https://github.com/rtCamp/wp-framework" } + { "type": "vcs", "url": "https://github.com/rtCamp/wp-primitives" } ] } ``` ```bash -composer require rtcamp/wp-framework:^1.0 +composer require rtcamp/wp-primitives:^1.0 ``` (The `repositories` entry is unnecessary when the project already resolves this package through an rtCamp-hosted Composer registry.) -PSR-4 autoloading: `rtCamp\WPFramework\` → `inc/`. +PSR-4 autoloading: `rtCamp\WPPrimitives\` → `inc/`. ## Quick look ```php -use rtCamp\WPFramework\Contracts\Abstracts\AbstractPostType; -use rtCamp\WPFramework\Contracts\Traits\Loader; -use rtCamp\WPFramework\Contracts\Traits\Singleton; +use rtCamp\WPPrimitives\Contracts\Abstracts\AbstractPostType; +use rtCamp\WPPrimitives\Contracts\Traits\Loader; +use rtCamp\WPPrimitives\Contracts\Traits\Singleton; final class ArticlePostType extends AbstractPostType { public static function get_slug(): string { return 'article'; } diff --git a/ai/framework-php.instructions.md b/ai/primitives-php.instructions.md similarity index 93% rename from ai/framework-php.instructions.md rename to ai/primitives-php.instructions.md index 2f02949..768ea87 100644 --- a/ai/framework-php.instructions.md +++ b/ai/primitives-php.instructions.md @@ -1,11 +1,11 @@ --- applyTo: "**/*.php" -description: "Framework + WordPress rules for PHP. Canonical source, shipped by rtcamp/wp-framework." +description: "Framework + WordPress rules for PHP. Canonical source, shipped by rtcamp/wp-primitives." --- # PHP rules: framework, WordPress, security, tests -`rtcamp/wp-framework` (`rtCamp\WPFramework`) is in gitignored `vendor/` (invisible at review). These rules ARE its contract. +`rtcamp/wp-primitives` (`rtCamp\WPPrimitives`) is in gitignored `vendor/` (invisible at review). These rules ARE its contract. ## Architecture @@ -51,4 +51,4 @@ Flag genuine contract/security violations, not style. Allow any correct implemen 5. 🚩 A class calling `register_post_type`/`register_taxonomy`/`register_rest_route`/`add_menu_page`/`add_shortcode`/`register_block_type`/`wp_register_ability` directly instead of extending the matching `Abstract*` (`AbstractPostType`, `AbstractRESTController`, `AbstractAdminPage`, …). Name the abstract to extend. 6. 🚩 Missing `strict_types`/types/docblocks; PSR-4 mismatch; `self::` for LSB. 7. 🚩 Missing escape/sanitize/nonce/capability; raw `$wpdb` without `prepare()`; REST without a real `permission_callback`; inline assets; wrong/absent text domain. -8. 🚩 Edit under `vendor/rtcamp/wp-framework` or WordPress core. +8. 🚩 Edit under `vendor/rtcamp/wp-primitives` or WordPress core. diff --git a/bin/sync-ai-instructions.js b/bin/sync-ai-instructions.js index 908859b..88b2b10 100644 --- a/bin/sync-ai-instructions.js +++ b/bin/sync-ai-instructions.js @@ -5,12 +5,12 @@ /** * Sync AI / Copilot instructions for rtCamp WordPress projects. * - * Shipped by rtcamp/wp-framework; run from a consuming package via `npm run sync-ai` + * Shipped by rtcamp/wp-primitives; run from a consuming package via `npm run sync-ai` * (chained from `npm run init`). Does two jobs in one pass: * * 1. Refresh: copy the canonical framework rules from each package's - * vendor/rtcamp/wp-framework/ai/framework-php.instructions.md into that - * package's .github/instructions/framework-php.instructions.md. + * vendor/rtcamp/wp-primitives/ai/primitives-php.instructions.md into that + * package's .github/instructions/primitives-php.instructions.md. * 2. Project: if the package sits inside a wp-content root (an ancestor * containing plugins/), write every package's instructions to that root's * .github/instructions/ with applyTo globs re-scoped to the root, so GitHub @@ -29,8 +29,8 @@ const fs = require( 'fs' ); const path = require( 'path' ); const PACKAGE_DIRS = [ 'plugins', 'themes' ]; -const FRAMEWORK_SRC = 'vendor/rtcamp/wp-framework/ai/framework-php.instructions.md'; -const MARKER = ''; +const FRAMEWORK_SRC = 'vendor/rtcamp/wp-primitives/ai/primitives-php.instructions.md'; +const MARKER = ''; // Copilot code review reads only the first ~4000 chars of an instruction file. const COPILOT_CHAR_LIMIT = 4000; @@ -174,7 +174,7 @@ const writeIfChanged = ( outPath, content, relRoot, verb ) => { }; /** - * Step 1 — refresh a package's framework-php copy from its vendored framework. + * Step 1 — refresh a package's primitives-php copy from its vendored package. * * @param {string} base Package root. * @param {string} relRoot Root for log labels. @@ -185,7 +185,7 @@ const refreshPackage = ( base, relRoot ) => { if ( ! fs.existsSync( src ) ) { return false; } - const dest = path.join( base, '.github', 'instructions', 'framework-php.instructions.md' ); + const dest = path.join( base, '.github', 'instructions', 'primitives-php.instructions.md' ); writeIfChanged( dest, withMarker( fs.readFileSync( src, 'utf8' ) ), relRoot, 'refresh' ); return true; }; diff --git a/composer.json b/composer.json index 279e9c6..0ec49ac 100644 --- a/composer.json +++ b/composer.json @@ -1,12 +1,12 @@ { - "name": "rtcamp/wp-framework", + "name": "rtcamp/wp-primitives", "description": "Shared PHP utilities for rtCamp WordPress projects", "type": "library", "license": "GPL-2.0-or-later", - "homepage": "https://github.com/rtCamp/wp-framework", + "homepage": "https://github.com/rtCamp/wp-primitives", "support": { - "issues": "https://github.com/rtCamp/wp-framework/issues", - "source": "https://github.com/rtCamp/wp-framework" + "issues": "https://github.com/rtCamp/wp-primitives/issues", + "source": "https://github.com/rtCamp/wp-primitives" }, "require": { "php": ">=8.2" @@ -25,12 +25,12 @@ }, "autoload": { "psr-4": { - "rtCamp\\WPFramework\\": "inc/" + "rtCamp\\WPPrimitives\\": "inc/" } }, "autoload-dev": { "psr-4": { - "rtCamp\\WPFramework\\Tests\\": "tests/" + "rtCamp\\WPPrimitives\\Tests\\": "tests/" } }, "config": { diff --git a/docs/ai-review-system.md b/docs/ai-review-system.md index b2df9dc..bbae1d6 100644 --- a/docs/ai-review-system.md +++ b/docs/ai-review-system.md @@ -20,31 +20,31 @@ How GitHub Copilot code-review instructions and AI-agent guidance are authored, | File | Repo | Role | |---|---|---| -| `ai/framework-php.instructions.md` | framework | Canonical framework + WordPress review rules. Single source of truth. | +| `ai/primitives-php.instructions.md` | framework | Canonical framework + WordPress review rules. Single source of truth. | | `bin/sync-ai-instructions.js` | framework | One tool, run by the consumer via `npm run sync-ai`. Refreshes each package's framework rules from its vendored copy, then projects every package's instructions to the `wp-content` root. `--check` for a CI drift gate; `--root DIR` forces the `wp-content` root instead of detecting it from the current directory. | | `.github/copilot-instructions.md` | each package | Repo-wide overview + review conduct (skeleton-authored). | | `.github/instructions/structure.instructions.md` | each package | Package layout + wiring (skeleton-authored, carries the package's names). | -| `.github/instructions/framework-php.instructions.md` | each package | Generated from the package's vendored framework. Banner-marked; do not hand-edit. | +| `.github/instructions/primitives-php.instructions.md` | each package | Generated from the package's vendored framework. Banner-marked; do not hand-edit. | | `AGENTS.md` | each package | Tool-agnostic brief for coding agents. Inlines key principles + points to `.github/`. | | `CLAUDE.md` | each package | Thin; defers to `AGENTS.md`, holds any Claude-only overrides. | ## Data flow ``` -framework ai/framework-php.instructions.md (edit rules here) +framework ai/primitives-php.instructions.md (edit rules here) | | composer require/update -> lands in each package's vendor/ v -plugins//vendor/rtcamp/wp-framework/ai/framework-php.instructions.md +plugins//vendor/rtcamp/wp-primitives/ai/primitives-php.instructions.md | | npm run sync-ai (chained from npm run init) -> bin/sync-ai-instructions.js | step 1 (refresh): copy vendored rules into the package's .github/instructions/ | step 2 (project): walk up to the wp-content root, write every package's | instructions with applyTo re-scoped to that root v -plugins//.github/instructions/{framework-php,structure}.instructions.md (committed) +plugins//.github/instructions/{primitives-php,structure}.instructions.md (committed) wp-content/.github/instructions/ - framework-php.instructions.md applyTo: plugins/a/**/*.php,plugins/b/**/*.php,themes/c/**/*.php (MERGED) + primitives-php.instructions.md applyTo: plugins/a/**/*.php,plugins/b/**/*.php,themes/c/**/*.php (MERGED) -structure.instructions.md applyTo: plugins//inc/** (per package) ``` @@ -73,13 +73,13 @@ The framework repo itself has its **own** `.github/` with framework-*development - **Assemble a project**: drop packages into `wp-content/{plugins,themes}/`, then `composer install` and `npm install && npm run init`. `init` sets names and runs `sync-ai`, which refreshes each package's framework rules and writes the wp-content root `.github/`. - **Add another plugin later**: run `npm run sync-ai`; it discovers the new package, refreshes it, and merges it into the projected output. - **Remove a plugin**: run `npm run sync-ai` after removing it; the merged `applyTo` globs are recomputed and now-orphaned generated files are pruned (only files carrying the `GENERATED` banner are deleted). -- **Change a shared rule**: edit `ai/framework-php.instructions.md` in the framework, publish, then in the project run `composer update` + `npm run sync-ai`. +- **Change a shared rule**: edit `ai/primitives-php.instructions.md` in the framework, publish, then in the project run `composer update` + `npm run sync-ai`. - **Change a package-specific rule**: edit that package's `.github/instructions/structure.instructions.md`, then `npm run sync-ai`. - **CI gate**: `npm run sync-ai -- --check` fails the build if the committed instructions are stale. Copilot reads instructions from the **base branch**, so keeping `main` current is what matters. ## Constraints & guards -- **~4000 characters per instruction file**: Copilot only reads the first ~4000. The banner is appended after the rules so it never eats the window; the tool warns (STDERR) when the rules themselves exceed it. Keep `ai/framework-php.instructions.md` lean. +- **~4000 characters per instruction file**: Copilot only reads the first ~4000. The banner is appended after the rules so it never eats the window; the tool warns (STDERR) when the rules themselves exceed it. Keep `ai/primitives-php.instructions.md` lean. - **`applyTo` accepts comma-separated globs**: relied on by the merge. - Generated files carry a `GENERATED` banner; never hand-edit them. Edit the source in the framework (shared rules) or the skeleton (structure). - Third-party plugins in `wp-content` are not governed by these rules; exclude them from review via Copilot content-exclusion settings if needed. diff --git a/docs/branding.json b/docs/branding.json index 46dee19..03008c6 100644 --- a/docs/branding.json +++ b/docs/branding.json @@ -1,6 +1,6 @@ { "tagline": "A shared PHP base for WordPress projects", "navbar": { - "title": "WP Framework" + "title": "WP Primitives" } } diff --git a/docs/contracts.md b/docs/contracts.md index e5bc846..3b6db3c 100644 --- a/docs/contracts.md +++ b/docs/contracts.md @@ -100,7 +100,7 @@ methods to supply the name, description, and callback. It standardises the The command itself is a plain static class: ```php -use rtCamp\WPFramework\Contracts\Interfaces\CLICommand; +use rtCamp\WPPrimitives\Contracts\Interfaces\CLICommand; final class ReindexCommand implements CLICommand { public static function get_name(): string { @@ -127,7 +127,7 @@ place for the `WP_CLI` check — the loader then skips the class entirely outsid WP-CLI instead of the class guarding itself: ```php -use rtCamp\WPFramework\Contracts\Interfaces\ConditionallyRegistrable; +use rtCamp\WPPrimitives\Contracts\Interfaces\ConditionallyRegistrable; final class CliCommands implements ConditionallyRegistrable { /** @var array> */ diff --git a/docs/getting-started.md b/docs/getting-started.md index bd455c0..e90c687 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -29,26 +29,26 @@ consuming project's `composer.json` first, then require it: "repositories": [ { "type": "vcs", - "url": "https://github.com/rtCamp/wp-framework" + "url": "https://github.com/rtCamp/wp-primitives" } ] } ``` ```bash -composer require rtcamp/wp-framework:^1.0 +composer require rtcamp/wp-primitives:^1.0 ``` If the project is already wired to an rtCamp-hosted Composer registry that serves this package, the `repositories` entry is unnecessary and -`composer require rtcamp/wp-framework:^1.0` is enough on its own. +`composer require rtcamp/wp-primitives:^1.0` is enough on its own. Pin with a caret constraint. `inc/Contracts/` is the public API and the project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html), so `^1.0` accepts additive releases and refuses the next major. Read [upgrading.md](upgrading.md) before moving across a major. -Composer exposes framework classes through the `rtCamp\WPFramework\` namespace. +Composer exposes framework classes through the `rtCamp\WPPrimitives\` namespace. The consuming plugin or theme remains responsible for requiring its own Composer autoload file and starting its entry class. @@ -63,7 +63,7 @@ declare( strict_types = 1 ); namespace Acme\Example; -use rtCamp\WPFramework\Contracts\Interfaces\Registrable; +use rtCamp\WPPrimitives\Contracts\Interfaces\Registrable; final class ContentFilters implements Registrable { public function register_hooks(): void { @@ -91,7 +91,7 @@ declare( strict_types = 1 ); namespace Acme\Example; -use rtCamp\WPFramework\Contracts\Abstracts\AbstractModule; +use rtCamp\WPPrimitives\Contracts\Abstracts\AbstractModule; final class ContentModule extends AbstractModule { protected function get_classes(): array { @@ -119,8 +119,8 @@ declare( strict_types = 1 ); namespace Acme\Example; -use rtCamp\WPFramework\Contracts\Traits\Loader; -use rtCamp\WPFramework\Contracts\Traits\Singleton; +use rtCamp\WPPrimitives\Contracts\Traits\Loader; +use rtCamp\WPPrimitives\Contracts\Traits\Singleton; require_once __DIR__ . '/vendor/autoload.php'; @@ -158,8 +158,8 @@ Classes are not retained by default. Add the `Shareable` marker only when anothe class must retrieve the exact instance that was loaded: ```php -use rtCamp\WPFramework\Contracts\Interfaces\Shareable; -use rtCamp\WPFramework\Utils\Cache; +use rtCamp\WPPrimitives\Contracts\Interfaces\Shareable; +use rtCamp\WPPrimitives\Utils\Cache; final class PluginCache extends Cache implements Shareable { public function __construct() { diff --git a/docs/index.md b/docs/index.md index f48bc65..40de1cb 100644 --- a/docs/index.md +++ b/docs/index.md @@ -3,9 +3,9 @@ sidebar_position: 1 sidebar_label: Overview --- -# wp-framework +# wp-primitives -`rtcamp/wp-framework` is the shared PHP base that every rtCamp plugin and theme +`rtcamp/wp-primitives` is the shared PHP base that every rtCamp plugin and theme skeleton is built on. It is a Composer **library**, not a plugin: it ships a set of contracts (interfaces, abstracts, traits) plus concrete loaders and utilities, and the skeletons consume it through `vendor/`. diff --git a/docs/maintainers.md b/docs/maintainers.md index 6f3bc65..1c92029 100644 --- a/docs/maintainers.md +++ b/docs/maintainers.md @@ -5,7 +5,7 @@ sidebar_label: Maintainer guide # Maintainer guide -This guide covers work on `rtcamp/wp-framework` itself. For consuming the +This guide covers work on `rtcamp/wp-primitives` itself. For consuming the library, start with [getting-started.md](getting-started.md). ## Local environment @@ -56,7 +56,7 @@ npm run wp-env stop - Follow TDD: add a failing test, then implement the behavior. - Mirror `inc/` under `tests/` for new classes and traits. -- Extend `rtCamp\WPFramework\Tests\TestCase` for code that calls WordPress APIs. +- Extend `rtCamp\WPPrimitives\Tests\TestCase` for code that calls WordPress APIs. - A pure-logic test may extend `PHPUnit\Framework\TestCase`. - Exercise actual WordPress registrations and registries rather than mocking WordPress functions. @@ -74,7 +74,7 @@ Before editing, identify which surface is affected: plugins and themes. Signature changes here are breaking. - `inc/` contains the container and concrete asset/render loaders. - `inc/Utils/` contains reusable services and utilities. -- `ai/framework-php.instructions.md` is shipped to consumers as their canonical +- `ai/primitives-php.instructions.md` is shipped to consumers as their canonical framework and WordPress review guidance. - `bin/sync-ai-instructions.js` refreshes and projects those instructions in consuming repositories. @@ -90,7 +90,7 @@ For every behavior change: For a change under `inc/Contracts/`, also: - call out the compatibility impact in the pull request; -- update `ai/framework-php.instructions.md` when consumer guidance or the +- update `ai/primitives-php.instructions.md` when consumer guidance or the documented contract changes; - check every abstract subclass signature and every documented example affected by the change. @@ -100,7 +100,7 @@ limited to PHP. Development-only tooling belongs in `require-dev`. ## Adding a class, interface, or trait -- Use PSR-4 paths: `rtCamp\WPFramework\` maps to `inc/`. +- Use PSR-4 paths: `rtCamp\WPPrimitives\` maps to `inc/`. - Add `declare( strict_types = 1 );`. - Fully type parameters and return values. - Add `@package` and `@since` documentation. diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 1d408cb..f39adc5 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -38,7 +38,7 @@ one you get is deliberate: | `_doing_it_wrong`: *Asset manifest "…" is invalid; the file modification time will be used as the version.* | `app.asset.php` exists but doesn't return an array. | Regenerate the build. Harmless otherwise — registration continues with a `filemtime()` version. | | `_doing_it_wrong`: *Block manifest file is missing. Blocks will not be registered.* | `register_block_manifest()` got a manifest path that doesn't resolve under the base dir. | Pass the path **relative to the base dir**, e.g. `build/blocks-manifest.php`. | | Script registers but never loads | Registration is not enqueueing. | Call `wp_enqueue_script()` with the handle. `ComponentLoader` does this for component assets; `AssetLoader` never does. | -| Handles collide with another package | `HANDLE_PREFIX` left at its `wp-framework-` default. | Override the constant in the consumer's `AssetLoader` subclass. | +| Handles collide with another package | `HANDLE_PREFIX` left at its `wp-primitives-` default. | Override the constant in the consumer's `AssetLoader` subclass. | | `RuntimeException: Acme\Components requires an AssetLoader: inject one via the constructor or override get_asset_loader().` | The `ComponentLoader` subclass was constructed with no asset loader — typical when the framework `Loader` instantiates it with no arguments. | Build one in the subclass constructor, or override `get_asset_loader()` to resolve a shared instance lazily. | | `_doing_it_wrong`: *Component "Foo" could not be resolved.* | No `Foo/Foo.php` under any layer of the hierarchy, **or the name was rejected**: names must match `^[A-Za-z0-9_-]+$` and be ≤128 characters. A slash or `..` is refused outright — that check is a security boundary, not a convenience. | Fix the path or the name. | | A theme override isn't picked up | The render passed `allow_override => false`, or the override sits in a layer the loader doesn't search (a plugin-owned loader searches child → parent → package; a theme's own loader collapses the redundant layers). | Drop the option, or place the file in a searched layer. | @@ -69,7 +69,7 @@ one you get is deliberate: | Symptom | Cause | Fix | |---|---|---| -| `Class "rtCamp\WPFramework\…" not found` | The consumer's `vendor/autoload.php` was never required, or the package resolved from a stale `vendor/`. | Require the autoloader in the plugin/theme entry point; `composer update rtcamp/wp-framework`. | +| `Class "rtCamp\WPPrimitives\…" not found` | The consumer's `vendor/autoload.php` was never required, or the package resolved from a stale `vendor/`. | Require the autoloader in the plugin/theme entry point; `composer update rtcamp/wp-primitives`. | | Composer can't find the package | It is not on public Packagist. | Add the VCS `repositories` entry — see [getting-started.md](getting-started.md#install). | | A missing abstract method only surfaces at runtime | The subclass doesn't implement everything the abstract declares. | Run PHPStan in the consuming package; it catches contract breaks before a request does. | diff --git a/docs/upgrading.md b/docs/upgrading.md index 68cb65c..9cc947f 100644 --- a/docs/upgrading.md +++ b/docs/upgrading.md @@ -5,7 +5,7 @@ sidebar_label: Upgrading # Upgrading -What changes between releases of `rtcamp/wp-framework`, and what a consuming +What changes between releases of `rtcamp/wp-primitives`, and what a consuming plugin or theme has to do about it. [`CHANGELOG.md`](../CHANGELOG.md) is the complete per-release record; this page carries only the entries that require a code change on the consumer side. @@ -30,7 +30,7 @@ Read this page and the changelog before widening a constraint across a major. ## Upgrade routine ```bash -composer update rtcamp/wp-framework +composer update rtcamp/wp-primitives composer lint && composer analyse # in the consuming package ``` diff --git a/inc/AssetLoader.php b/inc/AssetLoader.php index 65b241a..0e37e81 100644 --- a/inc/AssetLoader.php +++ b/inc/AssetLoader.php @@ -11,14 +11,14 @@ * construction: the source URL is built from the base URL and the dependency + * version metadata is read from the sibling `*.asset.php` manifest on disk. * - * @package rtCamp\WPFramework + * @package rtCamp\WPPrimitives * * @since 1.0.0 */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework; +namespace rtCamp\WPPrimitives; /** * Class AssetLoader @@ -30,7 +30,7 @@ class AssetLoader { * Default asset handle prefix. Subclasses override this constant to namespace * their handles; handle() reads it via late static binding. */ - public const HANDLE_PREFIX = 'wp-framework-'; + public const HANDLE_PREFIX = 'wp-primitives-'; /** * Base directory path (plugin or theme root). Readable by subclasses that @@ -78,7 +78,7 @@ public function get_assets_dir(): string { /** * Prefix a short name with HANDLE_PREFIX to form an asset handle. With the - * default prefix, handle( 'frontend' ) returns 'wp-framework-frontend'. + * default prefix, handle( 'frontend' ) returns 'wp-primitives-frontend'. * Subclasses namespace their handles by overriding the HANDLE_PREFIX * constant; uniqueness is the caller's responsibility (pass distinct names). * @@ -203,7 +203,7 @@ public function register_block_manifest( string $block_path, string $manifest_fi if ( ! file_exists( $manifest_path ) ) { _doing_it_wrong( static::class, - esc_html__( 'Block manifest file is missing. Blocks will not be registered.', 'wp-framework' ), + esc_html__( 'Block manifest file is missing. Blocks will not be registered.', 'wp-primitives' ), '1.0.0' ); return; @@ -359,7 +359,7 @@ private function get_asset_meta( string $filename, string $extension ): ?array { static::class, sprintf( /* translators: 1: The asset filename. 2: The asset extension. */ - esc_html__( 'Asset file "%1$s.%2$s" is missing. The asset will not be registered.', 'wp-framework' ), + esc_html__( 'Asset file "%1$s.%2$s" is missing. The asset will not be registered.', 'wp-primitives' ), esc_html( $filename ), esc_html( $extension ) ), @@ -389,7 +389,7 @@ private function read_asset_manifest( string $manifest_file, string $asset_file static::class, sprintf( /* translators: %s: The asset manifest path. */ - esc_html__( 'Asset manifest "%s" is invalid; the file modification time will be used as the version.', 'wp-framework' ), + esc_html__( 'Asset manifest "%s" is invalid; the file modification time will be used as the version.', 'wp-primitives' ), esc_html( $manifest_file ) ), '1.0.0' diff --git a/inc/ComponentLoader.php b/inc/ComponentLoader.php index 2f8e0b3..f3f0e53 100644 --- a/inc/ComponentLoader.php +++ b/inc/ComponentLoader.php @@ -10,13 +10,13 @@ * Each consuming package (a theme, a plugin) loads its own subclass with a * distinct context, so their components and asset handles never collide. * - * @package rtCamp\WPFramework + * @package rtCamp\WPPrimitives * @since 1.0.0 */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework; +namespace rtCamp\WPPrimitives; /** * Class ComponentLoader @@ -107,7 +107,7 @@ public function __construct( ?AssetLoader $asset_loader = null ) { * @return string Context slug. */ protected function get_context(): string { - return 'wp-framework'; + return 'wp-primitives'; } /** @@ -274,7 +274,7 @@ protected function render_component( string $name, array $args = [], array $opti $caller ?? __METHOD__, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- This is a function name, not rendered output. sprintf( /* translators: %s: Component name. */ - esc_html__( 'Component "%s" could not be resolved.', 'wp-framework' ), + esc_html__( 'Component "%s" could not be resolved.', 'wp-primitives' ), esc_html( $name ) ), '1.0.0' diff --git a/inc/Container.php b/inc/Container.php index 9583dad..fe574b0 100644 --- a/inc/Container.php +++ b/inc/Container.php @@ -4,13 +4,13 @@ * * Simple container that stores object instances and retrieves them by class name. * - * @package rtCamp\WPFramework + * @package rtCamp\WPPrimitives * @since 1.0.0 */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework; +namespace rtCamp\WPPrimitives; /** * Class - Container diff --git a/inc/Contracts/Abstracts/AbstractAbility.php b/inc/Contracts/Abstracts/AbstractAbility.php index e194f83..5e3932d 100644 --- a/inc/Contracts/Abstracts/AbstractAbility.php +++ b/inc/Contracts/Abstracts/AbstractAbility.php @@ -2,13 +2,13 @@ /** * Abstract Ability. * - * @package rtCamp\WPFramework\Contracts\Abstracts + * @package rtCamp\WPPrimitives\Contracts\Abstracts * @since 1.0.0 */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Contracts\Abstracts; +namespace rtCamp\WPPrimitives\Contracts\Abstracts; /** * Class AbstractAbility diff --git a/inc/Contracts/Abstracts/AbstractAbilityRegistrar.php b/inc/Contracts/Abstracts/AbstractAbilityRegistrar.php index 51e460f..9baaa6d 100644 --- a/inc/Contracts/Abstracts/AbstractAbilityRegistrar.php +++ b/inc/Contracts/Abstracts/AbstractAbilityRegistrar.php @@ -2,15 +2,15 @@ /** * Abstract Ability Registrar. * - * @package rtCamp\WPFramework\Contracts\Abstracts + * @package rtCamp\WPPrimitives\Contracts\Abstracts * @since 1.0.0 */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Contracts\Abstracts; +namespace rtCamp\WPPrimitives\Contracts\Abstracts; -use rtCamp\WPFramework\Contracts\Interfaces\Registrable; +use rtCamp\WPPrimitives\Contracts\Interfaces\Registrable; /** * Class AbstractAbilityRegistrar diff --git a/inc/Contracts/Abstracts/AbstractAdminPage.php b/inc/Contracts/Abstracts/AbstractAdminPage.php index 1cbff74..e324aed 100644 --- a/inc/Contracts/Abstracts/AbstractAdminPage.php +++ b/inc/Contracts/Abstracts/AbstractAdminPage.php @@ -4,15 +4,15 @@ * * Provides a clean interface for registering WordPress admin menu pages. * - * @package rtCamp\WPFramework\Contracts\Abstracts + * @package rtCamp\WPPrimitives\Contracts\Abstracts * @since 1.0.0 */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Contracts\Abstracts; +namespace rtCamp\WPPrimitives\Contracts\Abstracts; -use rtCamp\WPFramework\Contracts\Interfaces\Registrable; +use rtCamp\WPPrimitives\Contracts\Interfaces\Registrable; /** * Class - AbstractAdminPage diff --git a/inc/Contracts/Abstracts/AbstractBlock.php b/inc/Contracts/Abstracts/AbstractBlock.php index 4c37d68..88627f8 100644 --- a/inc/Contracts/Abstracts/AbstractBlock.php +++ b/inc/Contracts/Abstracts/AbstractBlock.php @@ -6,15 +6,15 @@ * For static blocks (JSON-only, no server-side render), use the AssetLoader * class with `register_block_manifest()` directly. * - * @package rtCamp\WPFramework\Contracts\Abstracts + * @package rtCamp\WPPrimitives\Contracts\Abstracts * @since 1.0.0 */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Contracts\Abstracts; +namespace rtCamp\WPPrimitives\Contracts\Abstracts; -use rtCamp\WPFramework\Contracts\Interfaces\Registrable; +use rtCamp\WPPrimitives\Contracts\Interfaces\Registrable; /** * Class - AbstractBlock diff --git a/inc/Contracts/Abstracts/AbstractFeature.php b/inc/Contracts/Abstracts/AbstractFeature.php index 3cf399c..7482cb3 100644 --- a/inc/Contracts/Abstracts/AbstractFeature.php +++ b/inc/Contracts/Abstracts/AbstractFeature.php @@ -2,16 +2,16 @@ /** * Abstract Feature. * - * @package rtCamp\WPFramework\Contracts\Abstracts + * @package rtCamp\WPPrimitives\Contracts\Abstracts * @since 1.0.0 */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Contracts\Abstracts; +namespace rtCamp\WPPrimitives\Contracts\Abstracts; -use rtCamp\WPFramework\Contracts\Interfaces\ConditionallyRegistrable; -use rtCamp\WPFramework\Utils\FeatureSelector; +use rtCamp\WPPrimitives\Contracts\Interfaces\ConditionallyRegistrable; +use rtCamp\WPPrimitives\Utils\FeatureSelector; /** * Class AbstractFeature diff --git a/inc/Contracts/Abstracts/AbstractModule.php b/inc/Contracts/Abstracts/AbstractModule.php index f05e742..5e367be 100644 --- a/inc/Contracts/Abstracts/AbstractModule.php +++ b/inc/Contracts/Abstracts/AbstractModule.php @@ -5,16 +5,16 @@ * A module groups related Registrable classes together, acting as an * intermediary between the plugin's Main class and individual services. * - * @package rtCamp\WPFramework\Contracts\Abstracts + * @package rtCamp\WPPrimitives\Contracts\Abstracts * @since 1.0.0 */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Contracts\Abstracts; +namespace rtCamp\WPPrimitives\Contracts\Abstracts; -use rtCamp\WPFramework\Contracts\Interfaces\Registrable; -use rtCamp\WPFramework\Contracts\Traits\Loader; +use rtCamp\WPPrimitives\Contracts\Interfaces\Registrable; +use rtCamp\WPPrimitives\Contracts\Traits\Loader; /** * Class - AbstractModule diff --git a/inc/Contracts/Abstracts/AbstractPostType.php b/inc/Contracts/Abstracts/AbstractPostType.php index fb8b487..8bb4d85 100644 --- a/inc/Contracts/Abstracts/AbstractPostType.php +++ b/inc/Contracts/Abstracts/AbstractPostType.php @@ -16,15 +16,15 @@ * public function get_menu_icon(): string { return 'dashicons-admin-post'; } * } * - * @package rtCamp\WPFramework\Contracts\Abstracts + * @package rtCamp\WPPrimitives\Contracts\Abstracts * @since 1.0.0 */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Contracts\Abstracts; +namespace rtCamp\WPPrimitives\Contracts\Abstracts; -use rtCamp\WPFramework\Contracts\Interfaces\Registrable; +use rtCamp\WPPrimitives\Contracts\Interfaces\Registrable; /** * Class - AbstractPostType diff --git a/inc/Contracts/Abstracts/AbstractRESTController.php b/inc/Contracts/Abstracts/AbstractRESTController.php index e130c08..2e4b2c4 100644 --- a/inc/Contracts/Abstracts/AbstractRESTController.php +++ b/inc/Contracts/Abstracts/AbstractRESTController.php @@ -4,16 +4,16 @@ * * Includes the shared namespace, version and hook registration. * - * @package rtCamp\WPFramework\Contracts\Abstracts + * @package rtCamp\WPPrimitives\Contracts\Abstracts * @since 1.0.0 */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Contracts\Abstracts; +namespace rtCamp\WPPrimitives\Contracts\Abstracts; use WP_REST_Controller; -use rtCamp\WPFramework\Contracts\Interfaces\Registrable; +use rtCamp\WPPrimitives\Contracts\Interfaces\Registrable; /** * Class - AbstractRESTController diff --git a/inc/Contracts/Abstracts/AbstractSettingsPage.php b/inc/Contracts/Abstracts/AbstractSettingsPage.php index 0c4de40..94c96a7 100644 --- a/inc/Contracts/Abstracts/AbstractSettingsPage.php +++ b/inc/Contracts/Abstracts/AbstractSettingsPage.php @@ -6,15 +6,15 @@ * with the Settings API. Handles menu registration, settings registration, * and rendering in a single class. * - * @package rtCamp\WPFramework\Contracts\Abstracts + * @package rtCamp\WPPrimitives\Contracts\Abstracts * @since 1.0.0 */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Contracts\Abstracts; +namespace rtCamp\WPPrimitives\Contracts\Abstracts; -use rtCamp\WPFramework\Contracts\Interfaces\Registrable; +use rtCamp\WPPrimitives\Contracts\Interfaces\Registrable; /** * Class - AbstractSettingsPage diff --git a/inc/Contracts/Abstracts/AbstractShortcode.php b/inc/Contracts/Abstracts/AbstractShortcode.php index 4b1df02..827252e 100644 --- a/inc/Contracts/Abstracts/AbstractShortcode.php +++ b/inc/Contracts/Abstracts/AbstractShortcode.php @@ -4,15 +4,15 @@ * * Class to be extended by all shortcodes. Handles registration and provides a clean render interface. * - * @package rtCamp\WPFramework\Contracts\Abstracts + * @package rtCamp\WPPrimitives\Contracts\Abstracts * @since 1.0.0 */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Contracts\Abstracts; +namespace rtCamp\WPPrimitives\Contracts\Abstracts; -use rtCamp\WPFramework\Contracts\Interfaces\Registrable; +use rtCamp\WPPrimitives\Contracts\Interfaces\Registrable; /** * Class - AbstractShortcode diff --git a/inc/Contracts/Abstracts/AbstractTaxonomy.php b/inc/Contracts/Abstracts/AbstractTaxonomy.php index 5019bbb..2d9ff30 100644 --- a/inc/Contracts/Abstracts/AbstractTaxonomy.php +++ b/inc/Contracts/Abstracts/AbstractTaxonomy.php @@ -15,15 +15,15 @@ * public function get_plural_label(): string { return 'Foos'; } * } * - * @package rtCamp\WPFramework\Contracts\Abstracts + * @package rtCamp\WPPrimitives\Contracts\Abstracts * @since 1.0.0 */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Contracts\Abstracts; +namespace rtCamp\WPPrimitives\Contracts\Abstracts; -use rtCamp\WPFramework\Contracts\Interfaces\Registrable; +use rtCamp\WPPrimitives\Contracts\Interfaces\Registrable; /** * Class - AbstractTaxonomy diff --git a/inc/Contracts/Abstracts/AbstractUserRole.php b/inc/Contracts/Abstracts/AbstractUserRole.php index 9b6c640..22443f4 100644 --- a/inc/Contracts/Abstracts/AbstractUserRole.php +++ b/inc/Contracts/Abstracts/AbstractUserRole.php @@ -6,15 +6,15 @@ * Uses an option in the database to track the version, so roles are only * re-registered when the definition changes. * - * @package rtCamp\WPFramework\Contracts\Abstracts + * @package rtCamp\WPPrimitives\Contracts\Abstracts * @since 1.0.0 */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Contracts\Abstracts; +namespace rtCamp\WPPrimitives\Contracts\Abstracts; -use rtCamp\WPFramework\Contracts\Interfaces\Registrable; +use rtCamp\WPPrimitives\Contracts\Interfaces\Registrable; /** * Class - AbstractUserRole diff --git a/inc/Contracts/Interfaces/CLICommand.php b/inc/Contracts/Interfaces/CLICommand.php index d8382e9..91ef5aa 100644 --- a/inc/Contracts/Interfaces/CLICommand.php +++ b/inc/Contracts/Interfaces/CLICommand.php @@ -2,13 +2,13 @@ /** * Interface for WP_CLI commands. * - * @package rtCamp\WPFramework\Contracts\Interfaces + * @package rtCamp\WPPrimitives\Contracts\Interfaces * @since 1.0.0 */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Contracts\Interfaces; +namespace rtCamp\WPPrimitives\Contracts\Interfaces; /** * Interface - CLICommand diff --git a/inc/Contracts/Interfaces/ConditionallyRegistrable.php b/inc/Contracts/Interfaces/ConditionallyRegistrable.php index e600cf9..7384ce3 100644 --- a/inc/Contracts/Interfaces/ConditionallyRegistrable.php +++ b/inc/Contracts/Interfaces/ConditionallyRegistrable.php @@ -10,13 +10,13 @@ * Classes that always register can keep implementing the plain Registrable * interface instead; this one is strictly opt-in. * - * @package rtCamp\WPFramework\Contracts\Interfaces + * @package rtCamp\WPPrimitives\Contracts\Interfaces * @since 1.0.0 */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Contracts\Interfaces; +namespace rtCamp\WPPrimitives\Contracts\Interfaces; /** * Interface - ConditionallyRegistrable diff --git a/inc/Contracts/Interfaces/Registrable.php b/inc/Contracts/Interfaces/Registrable.php index 3c5f5c3..ec40a0b 100644 --- a/inc/Contracts/Interfaces/Registrable.php +++ b/inc/Contracts/Interfaces/Registrable.php @@ -4,13 +4,13 @@ * * Registrable classes are those that register hooks (actions/filters) with WordPress. * - * @package rtCamp\WPFramework\Contracts\Interfaces + * @package rtCamp\WPPrimitives\Contracts\Interfaces * @since 1.0.0 */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Contracts\Interfaces; +namespace rtCamp\WPPrimitives\Contracts\Interfaces; /** * Interface - Registrable diff --git a/inc/Contracts/Interfaces/Shareable.php b/inc/Contracts/Interfaces/Shareable.php index e5c89e1..ef7bc67 100644 --- a/inc/Contracts/Interfaces/Shareable.php +++ b/inc/Contracts/Interfaces/Shareable.php @@ -14,13 +14,13 @@ * Implemented alongside Registrable when a hooked class must also be shared, * or on its own for a plain shared service. * - * @package rtCamp\WPFramework\Contracts\Interfaces + * @package rtCamp\WPPrimitives\Contracts\Interfaces * @since 1.0.0 */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Contracts\Interfaces; +namespace rtCamp\WPPrimitives\Contracts\Interfaces; /** * Interface - Shareable diff --git a/inc/Contracts/Traits/Loader.php b/inc/Contracts/Traits/Loader.php index 61f1bc5..06a71f1 100644 --- a/inc/Contracts/Traits/Loader.php +++ b/inc/Contracts/Traits/Loader.php @@ -6,18 +6,18 @@ * Registrable, and caches any Shareable instance in a per-host Container. * Plain classes (neither Registrable nor Shareable) are just instantiated. * - * @package rtCamp\WPFramework\Contracts\Traits + * @package rtCamp\WPPrimitives\Contracts\Traits * @since 1.0.0 */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Contracts\Traits; +namespace rtCamp\WPPrimitives\Contracts\Traits; -use rtCamp\WPFramework\Container; -use rtCamp\WPFramework\Contracts\Interfaces\ConditionallyRegistrable; -use rtCamp\WPFramework\Contracts\Interfaces\Registrable; -use rtCamp\WPFramework\Contracts\Interfaces\Shareable; +use rtCamp\WPPrimitives\Container; +use rtCamp\WPPrimitives\Contracts\Interfaces\ConditionallyRegistrable; +use rtCamp\WPPrimitives\Contracts\Interfaces\Registrable; +use rtCamp\WPPrimitives\Contracts\Interfaces\Shareable; /** * Loader trait. diff --git a/inc/Contracts/Traits/Singleton.php b/inc/Contracts/Traits/Singleton.php index 6ebea9d..9ff4053 100644 --- a/inc/Contracts/Traits/Singleton.php +++ b/inc/Contracts/Traits/Singleton.php @@ -5,13 +5,13 @@ * Singletons are an ANTI-PATTERN. Use with caution and only when necessary. * In most cases, it's better to use dependency injection. * - * @package rtCamp\WPFramework\Contracts\Traits + * @package rtCamp\WPPrimitives\Contracts\Traits * @since 1.0.0 */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Contracts\Traits; +namespace rtCamp\WPPrimitives\Contracts\Traits; /** * Singleton trait. @@ -69,7 +69,7 @@ final public function __clone() { __FUNCTION__, sprintf( // translators: %s: Class name. - esc_html__( 'The %s class should not be cloned.', 'wp-framework' ), + esc_html__( 'The %s class should not be cloned.', 'wp-primitives' ), esc_html( static::class ), ), '1.0.0' @@ -84,7 +84,7 @@ final public function __wakeup() { __FUNCTION__, sprintf( // translators: %s: Class name. - esc_html__( 'De-serializing instances of %s is not allowed.', 'wp-framework' ), + esc_html__( 'De-serializing instances of %s is not allowed.', 'wp-primitives' ), esc_html( static::class ), ), '1.0.0' diff --git a/inc/TemplateLoader.php b/inc/TemplateLoader.php index 157e6b7..d023518 100644 --- a/inc/TemplateLoader.php +++ b/inc/TemplateLoader.php @@ -33,13 +33,13 @@ * $templates->render( 'content', 'card', [ 'title' => 'Hello' ] ); // echo * $html = $templates->get( 'content', 'card', [ 'title' => 'Hello' ] ); // string * - * @package rtCamp\WPFramework + * @package rtCamp\WPPrimitives * @since 1.0.0 */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework; +namespace rtCamp\WPPrimitives; /** * Class TemplateLoader diff --git a/inc/Utils/Cache.php b/inc/Utils/Cache.php index ef599c5..cc9e835 100644 --- a/inc/Utils/Cache.php +++ b/inc/Utils/Cache.php @@ -2,13 +2,13 @@ /** * Cache utility. * - * @package rtCamp\WPFramework\Utils + * @package rtCamp\WPPrimitives\Utils * @since 1.0.0 */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Utils; +namespace rtCamp\WPPrimitives\Utils; /** * Class - Cache @@ -27,7 +27,7 @@ * Designed to be a service: construct it with the package's slug, register an * instance as Shareable in a consumer's container, or extend it to change the * namespacing by overriding the {@see Cache::resolve_group()} seam (the same - * pattern as {@see \rtCamp\WPFramework\ComponentLoader::get_context()}). + * pattern as {@see \rtCamp\WPPrimitives\ComponentLoader::get_context()}). * * Centralises calls to `wp_cache_get`, `wp_cache_set`, `wp_cache_delete`, and * `wp_cache_flush_group` so consumers have a single typed API and one place to diff --git a/inc/Utils/Encryptor.php b/inc/Utils/Encryptor.php index 1eaf3dd..23a22e6 100644 --- a/inc/Utils/Encryptor.php +++ b/inc/Utils/Encryptor.php @@ -4,13 +4,13 @@ * * Useful for encrypting sensitive data before storing it in the database. * - * @package rtCamp\WPFramework\Utils + * @package rtCamp\WPPrimitives\Utils * @since 1.0.0 */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Utils; +namespace rtCamp\WPPrimitives\Utils; /** * Class - Encryptor diff --git a/inc/Utils/FeatureSelector.php b/inc/Utils/FeatureSelector.php index 3780eee..a07ece7 100644 --- a/inc/Utils/FeatureSelector.php +++ b/inc/Utils/FeatureSelector.php @@ -2,13 +2,13 @@ /** * FeatureSelector utility. * - * @package rtCamp\WPFramework\Utils + * @package rtCamp\WPPrimitives\Utils * @since 1.0.0 */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Utils; +namespace rtCamp\WPPrimitives\Utils; /** * Feature-flag registry for a single package. @@ -115,7 +115,7 @@ public function register( array|string $features ): void { __METHOD__, sprintf( /* translators: 1: slug being registered. 2: already-registered slug it collides with. 3: shared normalized key. */ - esc_html__( 'Feature flag "%1$s" collides with already-registered "%2$s" (both normalize to "%3$s"); keeping the first registration.', 'wp-framework' ), + esc_html__( 'Feature flag "%1$s" collides with already-registered "%2$s" (both normalize to "%3$s"); keeping the first registration.', 'wp-primitives' ), esc_html( $slug ), esc_html( $this->flag_keys[ $flag_key ] ), esc_html( $flag_key ) @@ -177,7 +177,7 @@ public function enable( string $flag ): bool { __METHOD__, sprintf( /* translators: %s: flag slug that was not registered. */ - esc_html__( 'Feature flag "%s" is not registered; enable() ignored.', 'wp-framework' ), + esc_html__( 'Feature flag "%s" is not registered; enable() ignored.', 'wp-primitives' ), esc_html( $flag ) ), '1.0.0' @@ -208,7 +208,7 @@ public function disable( string $flag ): bool { __METHOD__, sprintf( /* translators: %s: flag slug that was not registered. */ - esc_html__( 'Feature flag "%s" is not registered; disable() ignored.', 'wp-framework' ), + esc_html__( 'Feature flag "%s" is not registered; disable() ignored.', 'wp-primitives' ), esc_html( $flag ) ), '1.0.0' diff --git a/inc/Utils/FeatureSelectorSettingsPage.php b/inc/Utils/FeatureSelectorSettingsPage.php index facf02b..caea736 100644 --- a/inc/Utils/FeatureSelectorSettingsPage.php +++ b/inc/Utils/FeatureSelectorSettingsPage.php @@ -2,15 +2,15 @@ /** * FeatureSelectorSettingsPage utility. * - * @package rtCamp\WPFramework\Utils + * @package rtCamp\WPPrimitives\Utils * @since 1.0.0 */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Utils; +namespace rtCamp\WPPrimitives\Utils; -use rtCamp\WPFramework\Contracts\Abstracts\AbstractSettingsPage; +use rtCamp\WPPrimitives\Contracts\Abstracts\AbstractSettingsPage; /** * Admin settings page for a FeatureSelector registry. @@ -116,13 +116,13 @@ protected function get_page_title(): string { $context = $this->get_selector()->get_context(); if ( '' === $context ) { - return __( 'Features', 'wp-framework' ); + return __( 'Features', 'wp-primitives' ); } $package = ucwords( str_replace( [ '-', '_' ], ' ', $context ) ); /* translators: %s: package name derived from the selector's context. */ - return sprintf( __( '%s Features', 'wp-framework' ), $package ); + return sprintf( __( '%s Features', 'wp-primitives' ), $package ); } /** @@ -281,7 +281,7 @@ public function render_field( array $args ): void { get_selector()->is_enabled( $args['slug'] ) ); ?> /> - +

@@ -291,7 +291,7 @@ public function render_field( array $args ): void { diff --git a/inc/Utils/Logger.php b/inc/Utils/Logger.php index 6e72188..908453c 100644 --- a/inc/Utils/Logger.php +++ b/inc/Utils/Logger.php @@ -2,13 +2,13 @@ /** * Logger utility. * - * @package rtCamp\WPFramework\Utils + * @package rtCamp\WPPrimitives\Utils * @since 1.0.0 */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Utils; +namespace rtCamp\WPPrimitives\Utils; /** * PSR-3-style logger that writes to error_log() — but only when logging is enabled. @@ -39,7 +39,7 @@ * gate on an env var or feature flag instead of `WP_DEBUG`, or to force logging on for a * specific subsystem. Internal calls go through `$this` so such overrides take effect. * - * @package rtCamp\WPFramework\Utils + * @package rtCamp\WPPrimitives\Utils * @since 1.0.0 */ class Logger { diff --git a/inc/Utils/Timer.php b/inc/Utils/Timer.php index b0f55de..0b4f973 100644 --- a/inc/Utils/Timer.php +++ b/inc/Utils/Timer.php @@ -2,13 +2,13 @@ /** * Timer utility. * - * @package rtCamp\WPFramework\Utils + * @package rtCamp\WPPrimitives\Utils * @since 1.0.0 */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Utils; +namespace rtCamp\WPPrimitives\Utils; /** * Class - Timer @@ -61,7 +61,7 @@ public function start( string $label ): void { if ( '' === $label ) { _doing_it_wrong( __METHOD__, - esc_html__( 'Timer label must not be empty.', 'wp-framework' ), + esc_html__( 'Timer label must not be empty.', 'wp-primitives' ), '1.0.0' ); return; @@ -72,7 +72,7 @@ public function start( string $label ): void { __METHOD__, sprintf( /* translators: %s: timer label. */ - esc_html__( 'Timer "%s" has already been started.', 'wp-framework' ), + esc_html__( 'Timer "%s" has already been started.', 'wp-primitives' ), esc_html( $label ) ), '1.0.0' @@ -104,7 +104,7 @@ public function stop( string $label ): float { if ( '' === $label ) { _doing_it_wrong( __METHOD__, - esc_html__( 'Timer label must not be empty.', 'wp-framework' ), + esc_html__( 'Timer label must not be empty.', 'wp-primitives' ), '1.0.0' ); return 0.0; @@ -115,7 +115,7 @@ public function stop( string $label ): float { __METHOD__, sprintf( /* translators: %s: timer label. */ - esc_html__( 'Timer "%s" was never started.', 'wp-framework' ), + esc_html__( 'Timer "%s" was never started.', 'wp-primitives' ), esc_html( $label ) ), '1.0.0' @@ -128,7 +128,7 @@ public function stop( string $label ): float { __METHOD__, sprintf( /* translators: %s: timer label. */ - esc_html__( 'Timer "%s" has already been stopped.', 'wp-framework' ), + esc_html__( 'Timer "%s" has already been stopped.', 'wp-primitives' ), esc_html( $label ) ), '1.0.0' @@ -157,7 +157,7 @@ public function lap( string $label, string $name ): void { if ( '' === $label ) { _doing_it_wrong( __METHOD__, - esc_html__( 'Timer label must not be empty.', 'wp-framework' ), + esc_html__( 'Timer label must not be empty.', 'wp-primitives' ), '1.0.0' ); return; @@ -166,7 +166,7 @@ public function lap( string $label, string $name ): void { if ( '' === $name ) { _doing_it_wrong( __METHOD__, - esc_html__( 'Lap name must not be empty.', 'wp-framework' ), + esc_html__( 'Lap name must not be empty.', 'wp-primitives' ), '1.0.0' ); return; @@ -177,7 +177,7 @@ public function lap( string $label, string $name ): void { __METHOD__, sprintf( /* translators: %s: timer label. */ - esc_html__( 'Timer "%s" was never started.', 'wp-framework' ), + esc_html__( 'Timer "%s" was never started.', 'wp-primitives' ), esc_html( $label ) ), '1.0.0' @@ -190,7 +190,7 @@ public function lap( string $label, string $name ): void { __METHOD__, sprintf( /* translators: %s: timer label. */ - esc_html__( 'Timer "%s" has already been stopped.', 'wp-framework' ), + esc_html__( 'Timer "%s" has already been stopped.', 'wp-primitives' ), esc_html( $label ) ), '1.0.0' diff --git a/inc/Utils/Transients.php b/inc/Utils/Transients.php index eac4d35..d2c015d 100644 --- a/inc/Utils/Transients.php +++ b/inc/Utils/Transients.php @@ -2,13 +2,13 @@ /** * Transients utility. * - * @package rtCamp\WPFramework\Utils + * @package rtCamp\WPPrimitives\Utils * @since 1.0.0 */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Utils; +namespace rtCamp\WPPrimitives\Utils; /** * Class - Transients diff --git a/package-lock.json b/package-lock.json index 68d1282..6e58386 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "wp-framework", + "name": "wp-primitives", "version": "0.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "wp-framework", + "name": "wp-primitives", "version": "0.0.1", "license": "GPL-2.0-or-later", "devDependencies": { diff --git a/package.json b/package.json index e49f380..d633eef 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "wp-framework", + "name": "wp-primitives", "version": "0.0.1", "description": "Tooling for the rtCamp WordPress framework: wp-env integration test harness.", "private": true, @@ -7,9 +7,9 @@ "license": "GPL-2.0-or-later", "scripts": { "wp-env": "wp-env", - "pretest:php": "wp-env run tests-cli --env-cwd=wp-content/wp-framework-rt -- composer install --no-interaction", - "test:php": "wp-env run tests-cli --env-cwd=wp-content/wp-framework-rt -- vendor/bin/phpunit -c phpunit.xml.dist", - "test:php:coverage": "wp-env run tests-cli --env-cwd=wp-content/wp-framework-rt -- vendor/bin/phpunit -c phpunit.xml.dist --coverage-html coverage" + "pretest:php": "wp-env run tests-cli --env-cwd=wp-content/wp-primitives-rt -- composer install --no-interaction", + "test:php": "wp-env run tests-cli --env-cwd=wp-content/wp-primitives-rt -- vendor/bin/phpunit -c phpunit.xml.dist", + "test:php:coverage": "wp-env run tests-cli --env-cwd=wp-content/wp-primitives-rt -- vendor/bin/phpunit -c phpunit.xml.dist --coverage-html coverage" }, "devDependencies": { "@wordpress/env": "11.7.0" diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 949f531..4a148ba 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -1,6 +1,6 @@ - - PHPCS rules for rtcamp/wp-framework — WordPress-Core + Extra + Docs + VIP Minimum + PHP 8.2+ compatibility. + + PHPCS rules for rtcamp/wp-primitives — WordPress-Core + Extra + Docs + VIP Minimum + PHP 8.2+ compatibility. inc diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 08fc030..ac2d988 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,4 +1,4 @@ -# PHPStan configuration — wp-framework +# PHPStan configuration — wp-primitives # Docs: https://phpstan.org/config-reference includes: diff --git a/tests/AssetLoaderHandleTest.php b/tests/AssetLoaderHandleTest.php index a0718d0..ea678f7 100644 --- a/tests/AssetLoaderHandleTest.php +++ b/tests/AssetLoaderHandleTest.php @@ -2,23 +2,23 @@ /** * Tests for AssetLoader::handle() and the overridable HANDLE_PREFIX constant. * - * @package rtCamp\WPFramework\Tests + * @package rtCamp\WPPrimitives\Tests */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Tests; +namespace rtCamp\WPPrimitives\Tests; use PHPUnit\Framework\TestCase; -use rtCamp\WPFramework\AssetLoader; +use rtCamp\WPPrimitives\AssetLoader; final class AssetLoaderHandleTest extends TestCase { public function test_handle_applies_the_default_prefix(): void { $loader = new AssetLoader( '', '', 'assets' ); - $this->assertSame( 'wp-framework-frontend', $loader->handle( 'frontend' ) ); - $this->assertSame( 'wp-framework-my-script', $loader->handle( 'my-script' ) ); + $this->assertSame( 'wp-primitives-frontend', $loader->handle( 'frontend' ) ); + $this->assertSame( 'wp-primitives-my-script', $loader->handle( 'my-script' ) ); } public function test_subclass_prefix_wins_via_late_static_binding(): void { diff --git a/tests/AssetLoaderTest.php b/tests/AssetLoaderTest.php index 23bfeb9..88391b3 100644 --- a/tests/AssetLoaderTest.php +++ b/tests/AssetLoaderTest.php @@ -7,16 +7,16 @@ * rather than stubbed globals, and incorrect-usage notices via * WP_UnitTestCase::setExpectedIncorrectUsage(). * - * @package rtCamp\WPFramework\Tests + * @package rtCamp\WPPrimitives\Tests */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Tests; +namespace rtCamp\WPPrimitives\Tests; use RecursiveDirectoryIterator; use RecursiveIteratorIterator; -use rtCamp\WPFramework\AssetLoader; +use rtCamp\WPPrimitives\AssetLoader; final class AssetLoaderTest extends TestCase { @@ -36,7 +36,7 @@ public function set_up(): void { $GLOBALS['wp_styles'] = null; $this->reset_script_modules(); - $this->temp_dir = sys_get_temp_dir() . '/wp-framework-asset-loader-' . str_replace( '.', '', uniqid( '', true ) ); + $this->temp_dir = sys_get_temp_dir() . '/wp-primitives-asset-loader-' . str_replace( '.', '', uniqid( '', true ) ); mkdir( $this->temp_dir, 0777, true ); $this->loader = new AssetLoader( $this->temp_dir, $this->base_url, 'assets/build' ); @@ -188,20 +188,20 @@ public function test_register_block_manifest_registers_collection(): void { // (which reads the block.json), so both paths register the same block. $this->write_asset( 'build/blocks/example/block.json', - '{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":3,"name":"wp-framework/example","title":"Example","category":"widgets"}' + '{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":3,"name":"wp-primitives/example","title":"Example","category":"widgets"}' ); $this->write_asset( 'build/blocks-manifest.php', - ' ["name" => "wp-framework/example", "title" => "Example", "category" => "widgets", "apiVersion" => 3]];' + ' ["name" => "wp-primitives/example", "title" => "Example", "category" => "widgets", "apiVersion" => 3]];' ); $this->loader->register_block_manifest( 'build/blocks', 'build/blocks-manifest.php' ); $this->assertTrue( - \WP_Block_Type_Registry::get_instance()->is_registered( 'wp-framework/example' ) + \WP_Block_Type_Registry::get_instance()->is_registered( 'wp-primitives/example' ) ); - \WP_Block_Type_Registry::get_instance()->unregister( 'wp-framework/example' ); + \WP_Block_Type_Registry::get_instance()->unregister( 'wp-primitives/example' ); } public function test_missing_block_manifest_warns_and_skips_registration(): void { @@ -210,7 +210,7 @@ public function test_missing_block_manifest_warns_and_skips_registration(): void $this->loader->register_block_manifest( 'build/blocks', 'build/blocks-manifest.php' ); $this->assertFalse( - \WP_Block_Type_Registry::get_instance()->is_registered( 'wp-framework/example' ) + \WP_Block_Type_Registry::get_instance()->is_registered( 'wp-primitives/example' ) ); } diff --git a/tests/Components/ComponentLoaderTest.php b/tests/Components/ComponentLoaderTest.php index d1b5ff1..3b4e7e5 100644 --- a/tests/Components/ComponentLoaderTest.php +++ b/tests/Components/ComponentLoaderTest.php @@ -8,23 +8,23 @@ * hooks are captured with a real add_action() recorder, and incorrect usage * via WP_UnitTestCase::setExpectedIncorrectUsage(). * - * @package rtCamp\WPFramework\Tests\Components + * @package rtCamp\WPPrimitives\Tests\Components */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Tests\Components; +namespace rtCamp\WPPrimitives\Tests\Components; use RecursiveDirectoryIterator; use RecursiveIteratorIterator; -use rtCamp\WPFramework\AssetLoader; -use rtCamp\WPFramework\ComponentLoader; -use rtCamp\WPFramework\Tests\TestCase; +use rtCamp\WPPrimitives\AssetLoader; +use rtCamp\WPPrimitives\ComponentLoader; +use rtCamp\WPPrimitives\Tests\TestCase; final class ComponentLoaderTest extends TestCase { - private const STYLE_HANDLE = 'wp-framework-component-alert-style'; - private const SCRIPT_HANDLE = 'wp-framework-component-alert-script'; + private const STYLE_HANDLE = 'wp-primitives-component-alert-style'; + private const SCRIPT_HANDLE = 'wp-primitives-component-alert-script'; private string $temp_dir; @@ -48,7 +48,7 @@ final class ComponentLoaderTest extends TestCase { public function set_up(): void { parent::set_up(); - $this->temp_dir = sys_get_temp_dir() . '/wp-framework-component-loader-' . str_replace( '.', '', uniqid( '', true ) ); + $this->temp_dir = sys_get_temp_dir() . '/wp-primitives-component-loader-' . str_replace( '.', '', uniqid( '', true ) ); $this->parent_dir = $this->temp_dir . '/parent-theme'; $this->child_dir = $this->temp_dir . '/child-theme'; @@ -63,12 +63,12 @@ public function set_up(): void { $GLOBALS['wp_scripts'] = null; $GLOBALS['wp_styles'] = null; - TestComponentLoader::$test_context = 'wp-framework'; + TestComponentLoader::$test_context = 'wp-primitives'; // Record the render actions so tests can assert they fired. $this->rendered_hooks = []; foreach ( [ 'before', 'after' ] as $phase ) { - $hook = "wp-framework/component_{$phase}_render"; + $hook = "wp-primitives/component_{$phase}_render"; add_action( $hook, function () use ( $hook ): void { @@ -115,14 +115,14 @@ public function test_renders_component_with_arguments(): void { ); $this->assertSame( - [ 'wp-framework/component_before_render', 'wp-framework/component_after_render' ], + [ 'wp-primitives/component_before_render', 'wp-primitives/component_after_render' ], $this->rendered_hooks ); } public function test_render_hooks_are_isolated_per_loader_context(): void { // The point of namespacing the hooks is that one package's listeners do not - // fire for another's loader. Asserting only the default `wp-framework` + // fire for another's loader. Asserting only the default `wp-primitives` // names would pass even if the context were ignored entirely. $this->write_parent_component( 'alert', 'write_parent_component( 'alert', 'theme_asset_loader() ); @@ -338,7 +338,7 @@ public function test_should_enqueue_filter_can_suppress_a_component_asset(): voi $this->write_parent_asset( 'css/components/alert.css', '.alert{}' ); add_filter( - 'wp-framework/component_should_enqueue', + 'wp-primitives/component_should_enqueue', static fn ( bool $enqueue, string $name, string $type ): bool => 'style' === $type ? false : $enqueue, 10, 3 @@ -355,7 +355,7 @@ public function test_asset_handle_filter_overrides_the_handle(): void { $this->write_parent_asset( 'css/components/alert.css', '.alert{}' ); add_filter( - 'wp-framework/component_asset_handle', + 'wp-primitives/component_asset_handle', static fn ( string $handle, string $name, string $type ): string => "custom-{$name}-{$type}", 10, 3 @@ -490,7 +490,7 @@ private function write_file( string $file, string $contents ): void { } class TestComponentLoader extends ComponentLoader { - public static string $test_context = 'wp-framework'; + public static string $test_context = 'wp-primitives'; protected function get_context(): string { return self::$test_context; diff --git a/tests/ContainerTest.php b/tests/ContainerTest.php index 4f64e2d..01d5af5 100644 --- a/tests/ContainerTest.php +++ b/tests/ContainerTest.php @@ -2,16 +2,16 @@ /** * Container tests. * - * @package rtCamp\WPFramework\Tests + * @package rtCamp\WPPrimitives\Tests */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Tests; +namespace rtCamp\WPPrimitives\Tests; use PHPUnit\Framework\TestCase; use RuntimeException; -use rtCamp\WPFramework\Container; +use rtCamp\WPPrimitives\Container; use stdClass; final class ContainerTest extends TestCase { diff --git a/tests/Contracts/Abstracts/AbstractAbilityRegistrarTest.php b/tests/Contracts/Abstracts/AbstractAbilityRegistrarTest.php index c0ba8a8..26e8f58 100644 --- a/tests/Contracts/Abstracts/AbstractAbilityRegistrarTest.php +++ b/tests/Contracts/Abstracts/AbstractAbilityRegistrarTest.php @@ -11,17 +11,17 @@ * $wp_filter wholesale after every test. Tests use anonymous classes * throughout so each scenario is self-contained. * - * @package rtCamp\WPFramework\Tests\Contracts\Abstracts + * @package rtCamp\WPPrimitives\Tests\Contracts\Abstracts */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Tests\Contracts\Abstracts; +namespace rtCamp\WPPrimitives\Tests\Contracts\Abstracts; -use rtCamp\WPFramework\Contracts\Abstracts\AbstractAbility; -use rtCamp\WPFramework\Contracts\Abstracts\AbstractAbilityRegistrar; -use rtCamp\WPFramework\Contracts\Interfaces\Registrable; -use rtCamp\WPFramework\Tests\TestCase; +use rtCamp\WPPrimitives\Contracts\Abstracts\AbstractAbility; +use rtCamp\WPPrimitives\Contracts\Abstracts\AbstractAbilityRegistrar; +use rtCamp\WPPrimitives\Contracts\Interfaces\Registrable; +use rtCamp\WPPrimitives\Tests\TestCase; /** * Tests for AbstractAbilityRegistrar. diff --git a/tests/Contracts/Abstracts/AbstractAbilityTest.php b/tests/Contracts/Abstracts/AbstractAbilityTest.php index 9740b17..c398f30 100644 --- a/tests/Contracts/Abstracts/AbstractAbilityTest.php +++ b/tests/Contracts/Abstracts/AbstractAbilityTest.php @@ -7,15 +7,15 @@ * registration round-trip lives in AbstractAbilityRegistrarTest. Tests use * anonymous classes throughout so each scenario is self-contained. * - * @package rtCamp\WPFramework\Tests\Contracts\Abstracts + * @package rtCamp\WPPrimitives\Tests\Contracts\Abstracts */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Tests\Contracts\Abstracts; +namespace rtCamp\WPPrimitives\Tests\Contracts\Abstracts; -use rtCamp\WPFramework\Contracts\Abstracts\AbstractAbility; -use rtCamp\WPFramework\Tests\TestCase; +use rtCamp\WPPrimitives\Contracts\Abstracts\AbstractAbility; +use rtCamp\WPPrimitives\Tests\TestCase; /** * Tests for AbstractAbility. diff --git a/tests/Contracts/Abstracts/AbstractAdminPageTest.php b/tests/Contracts/Abstracts/AbstractAdminPageTest.php index 0d85e69..81eb9ee 100644 --- a/tests/Contracts/Abstracts/AbstractAdminPageTest.php +++ b/tests/Contracts/Abstracts/AbstractAdminPageTest.php @@ -7,15 +7,15 @@ * lives in wp-admin/includes/plugin.php and checks the current user's capability, * so both are set up here. * - * @package rtCamp\WPFramework\Tests\Contracts\Abstracts + * @package rtCamp\WPPrimitives\Tests\Contracts\Abstracts */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Tests\Contracts\Abstracts; +namespace rtCamp\WPPrimitives\Tests\Contracts\Abstracts; -use rtCamp\WPFramework\Contracts\Abstracts\AbstractAdminPage; -use rtCamp\WPFramework\Tests\TestCase; +use rtCamp\WPPrimitives\Contracts\Abstracts\AbstractAdminPage; +use rtCamp\WPPrimitives\Tests\TestCase; final class AbstractAdminPageTest extends TestCase { diff --git a/tests/Contracts/Abstracts/AbstractBlockTest.php b/tests/Contracts/Abstracts/AbstractBlockTest.php index 3d3fb4c..3f90490 100644 --- a/tests/Contracts/Abstracts/AbstractBlockTest.php +++ b/tests/Contracts/Abstracts/AbstractBlockTest.php @@ -6,25 +6,25 @@ * registered with WP_Block_Type_Registry and wired to the instance's render * callback. * - * @package rtCamp\WPFramework\Tests\Contracts\Abstracts + * @package rtCamp\WPPrimitives\Tests\Contracts\Abstracts */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Tests\Contracts\Abstracts; +namespace rtCamp\WPPrimitives\Tests\Contracts\Abstracts; -use rtCamp\WPFramework\Contracts\Abstracts\AbstractBlock; -use rtCamp\WPFramework\Tests\TestCase; +use rtCamp\WPPrimitives\Contracts\Abstracts\AbstractBlock; +use rtCamp\WPPrimitives\Tests\TestCase; use WP_Block_Type_Registry; final class AbstractBlockTest extends TestCase { - private const BLOCK_NAME = 'wp-framework-test/block'; + private const BLOCK_NAME = 'wp-primitives-test/block'; private function block(): AbstractBlock { return new class() extends AbstractBlock { public static function get_name(): string { - return 'wp-framework-test/block'; + return 'wp-primitives-test/block'; } public function render( array $attributes, string $content, \WP_Block $block ): string { @@ -77,14 +77,14 @@ public function test_register_block_uses_block_dir_when_provided(): void { mkdir( $dir, 0777, true ); file_put_contents( $dir . '/block.json', - '{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":3,"name":"wp-framework-test/dir-block","title":"Dir Block","category":"widgets"}' + '{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":3,"name":"wp-primitives-test/dir-block","title":"Dir Block","category":"widgets"}' ); $block = new class( $dir ) extends AbstractBlock { public function __construct( private string $dir ) {} public static function get_name(): string { - return 'wp-framework-test/dir-block'; + return 'wp-primitives-test/dir-block'; } public function render( array $attributes, string $content, \WP_Block $block ): string { @@ -99,10 +99,10 @@ protected function get_block_dir(): ?string { $block->register_block(); $this->assertTrue( - WP_Block_Type_Registry::get_instance()->is_registered( 'wp-framework-test/dir-block' ) + WP_Block_Type_Registry::get_instance()->is_registered( 'wp-primitives-test/dir-block' ) ); - unregister_block_type( 'wp-framework-test/dir-block' ); + unregister_block_type( 'wp-primitives-test/dir-block' ); unlink( $dir . '/block.json' ); rmdir( $dir ); } diff --git a/tests/Contracts/Abstracts/AbstractFeatureTest.php b/tests/Contracts/Abstracts/AbstractFeatureTest.php index 3fe54be..3f17cad 100644 --- a/tests/Contracts/Abstracts/AbstractFeatureTest.php +++ b/tests/Contracts/Abstracts/AbstractFeatureTest.php @@ -6,17 +6,17 @@ * the abstract get_slug() / get_feature_registry() are the moving parts. * Tests use anonymous classes throughout so each scenario is self-contained. * - * @package rtCamp\WPFramework\Tests\Contracts\Abstracts + * @package rtCamp\WPPrimitives\Tests\Contracts\Abstracts */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Tests\Contracts\Abstracts; +namespace rtCamp\WPPrimitives\Tests\Contracts\Abstracts; -use rtCamp\WPFramework\Contracts\Abstracts\AbstractFeature; -use rtCamp\WPFramework\Contracts\Interfaces\ConditionallyRegistrable; -use rtCamp\WPFramework\Tests\TestCase; -use rtCamp\WPFramework\Utils\FeatureSelector; +use rtCamp\WPPrimitives\Contracts\Abstracts\AbstractFeature; +use rtCamp\WPPrimitives\Contracts\Interfaces\ConditionallyRegistrable; +use rtCamp\WPPrimitives\Tests\TestCase; +use rtCamp\WPPrimitives\Utils\FeatureSelector; /** * Tests for AbstractFeature. diff --git a/tests/Contracts/Abstracts/AbstractModuleTest.php b/tests/Contracts/Abstracts/AbstractModuleTest.php index 15f8331..ceb9142 100644 --- a/tests/Contracts/Abstracts/AbstractModuleTest.php +++ b/tests/Contracts/Abstracts/AbstractModuleTest.php @@ -6,17 +6,17 @@ * it delegates to the Registrable classes from get_classes() via the Loader * trait. Verified with the shared Loader fixtures. * - * @package rtCamp\WPFramework\Tests\Contracts\Abstracts + * @package rtCamp\WPPrimitives\Tests\Contracts\Abstracts */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Tests\Contracts\Abstracts; +namespace rtCamp\WPPrimitives\Tests\Contracts\Abstracts; -use rtCamp\WPFramework\Contracts\Abstracts\AbstractModule; -use rtCamp\WPFramework\Tests\Fixtures\PlainRegistrable; -use rtCamp\WPFramework\Tests\Fixtures\ShareableRegistrable; -use rtCamp\WPFramework\Tests\TestCase; +use rtCamp\WPPrimitives\Contracts\Abstracts\AbstractModule; +use rtCamp\WPPrimitives\Tests\Fixtures\PlainRegistrable; +use rtCamp\WPPrimitives\Tests\Fixtures\ShareableRegistrable; +use rtCamp\WPPrimitives\Tests\TestCase; final class AbstractModuleTest extends TestCase { diff --git a/tests/Contracts/Abstracts/AbstractPostTypeTest.php b/tests/Contracts/Abstracts/AbstractPostTypeTest.php index 161c8d3..39f9884 100644 --- a/tests/Contracts/Abstracts/AbstractPostTypeTest.php +++ b/tests/Contracts/Abstracts/AbstractPostTypeTest.php @@ -6,15 +6,15 @@ * get_custom_options() override merge) and the real WordPress registration: * register() actually registers the post type and associates its taxonomies. * - * @package rtCamp\WPFramework\Tests\Contracts\Abstracts + * @package rtCamp\WPPrimitives\Tests\Contracts\Abstracts */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Tests\Contracts\Abstracts; +namespace rtCamp\WPPrimitives\Tests\Contracts\Abstracts; -use rtCamp\WPFramework\Contracts\Abstracts\AbstractPostType; -use rtCamp\WPFramework\Tests\TestCase; +use rtCamp\WPPrimitives\Contracts\Abstracts\AbstractPostType; +use rtCamp\WPPrimitives\Tests\TestCase; final class AbstractPostTypeTest extends TestCase { diff --git a/tests/Contracts/Abstracts/AbstractRESTControllerTest.php b/tests/Contracts/Abstracts/AbstractRESTControllerTest.php index c2b4449..6b7c197 100644 --- a/tests/Contracts/Abstracts/AbstractRESTControllerTest.php +++ b/tests/Contracts/Abstracts/AbstractRESTControllerTest.php @@ -6,15 +6,15 @@ * on rest_api_init, the endpoint dispatches, and the base register_routes() * throws to force subclass implementation. * - * @package rtCamp\WPFramework\Tests\Contracts\Abstracts + * @package rtCamp\WPPrimitives\Tests\Contracts\Abstracts */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Tests\Contracts\Abstracts; +namespace rtCamp\WPPrimitives\Tests\Contracts\Abstracts; -use rtCamp\WPFramework\Contracts\Abstracts\AbstractRESTController; -use rtCamp\WPFramework\Tests\TestCase; +use rtCamp\WPPrimitives\Contracts\Abstracts\AbstractRESTController; +use rtCamp\WPPrimitives\Tests\TestCase; use WP_REST_Request; final class AbstractRESTControllerTest extends TestCase { diff --git a/tests/Contracts/Abstracts/AbstractSettingsPageTest.php b/tests/Contracts/Abstracts/AbstractSettingsPageTest.php index fb59deb..281c554 100644 --- a/tests/Contracts/Abstracts/AbstractSettingsPageTest.php +++ b/tests/Contracts/Abstracts/AbstractSettingsPageTest.php @@ -7,15 +7,15 @@ * submenu under its parent, and the get_menu_slug() seam redirects the slug * registered with the admin menu. * - * @package rtCamp\WPFramework\Tests\Contracts\Abstracts + * @package rtCamp\WPPrimitives\Tests\Contracts\Abstracts */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Tests\Contracts\Abstracts; +namespace rtCamp\WPPrimitives\Tests\Contracts\Abstracts; -use rtCamp\WPFramework\Contracts\Abstracts\AbstractSettingsPage; -use rtCamp\WPFramework\Tests\TestCase; +use rtCamp\WPPrimitives\Contracts\Abstracts\AbstractSettingsPage; +use rtCamp\WPPrimitives\Tests\TestCase; final class AbstractSettingsPageTest extends TestCase { diff --git a/tests/Contracts/Abstracts/AbstractShortcodeTest.php b/tests/Contracts/Abstracts/AbstractShortcodeTest.php index e23d3a3..86d1be5 100644 --- a/tests/Contracts/Abstracts/AbstractShortcodeTest.php +++ b/tests/Contracts/Abstracts/AbstractShortcodeTest.php @@ -6,15 +6,15 @@ * registered and that do_shortcode() renders through the callback with the * default attributes merged. * - * @package rtCamp\WPFramework\Tests\Contracts\Abstracts + * @package rtCamp\WPPrimitives\Tests\Contracts\Abstracts */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Tests\Contracts\Abstracts; +namespace rtCamp\WPPrimitives\Tests\Contracts\Abstracts; -use rtCamp\WPFramework\Contracts\Abstracts\AbstractShortcode; -use rtCamp\WPFramework\Tests\TestCase; +use rtCamp\WPPrimitives\Contracts\Abstracts\AbstractShortcode; +use rtCamp\WPPrimitives\Tests\TestCase; final class AbstractShortcodeTest extends TestCase { diff --git a/tests/Contracts/Abstracts/AbstractTaxonomyTest.php b/tests/Contracts/Abstracts/AbstractTaxonomyTest.php index 79e6383..05c79b7 100644 --- a/tests/Contracts/Abstracts/AbstractTaxonomyTest.php +++ b/tests/Contracts/Abstracts/AbstractTaxonomyTest.php @@ -2,15 +2,15 @@ /** * AbstractTaxonomy tests. * - * @package rtCamp\WPFramework\Tests\Contracts\Abstracts + * @package rtCamp\WPPrimitives\Tests\Contracts\Abstracts */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Tests\Contracts\Abstracts; +namespace rtCamp\WPPrimitives\Tests\Contracts\Abstracts; -use rtCamp\WPFramework\Contracts\Abstracts\AbstractTaxonomy; -use rtCamp\WPFramework\Tests\TestCase; +use rtCamp\WPPrimitives\Contracts\Abstracts\AbstractTaxonomy; +use rtCamp\WPPrimitives\Tests\TestCase; final class AbstractTaxonomyTest extends TestCase { diff --git a/tests/Contracts/Abstracts/AbstractUserRoleTest.php b/tests/Contracts/Abstracts/AbstractUserRoleTest.php index 129e53b..20c0a86 100644 --- a/tests/Contracts/Abstracts/AbstractUserRoleTest.php +++ b/tests/Contracts/Abstracts/AbstractUserRoleTest.php @@ -6,15 +6,15 @@ * role registration — capabilities applied, version stored, gating on the * stored version, and full removal. * - * @package rtCamp\WPFramework\Tests\Contracts\Abstracts + * @package rtCamp\WPPrimitives\Tests\Contracts\Abstracts */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Tests\Contracts\Abstracts; +namespace rtCamp\WPPrimitives\Tests\Contracts\Abstracts; -use rtCamp\WPFramework\Contracts\Abstracts\AbstractUserRole; -use rtCamp\WPFramework\Tests\TestCase; +use rtCamp\WPPrimitives\Contracts\Abstracts\AbstractUserRole; +use rtCamp\WPPrimitives\Tests\TestCase; final class AbstractUserRoleTest extends TestCase { diff --git a/tests/Contracts/Interfaces/InterfaceContractsTest.php b/tests/Contracts/Interfaces/InterfaceContractsTest.php index f573119..5492ee1 100644 --- a/tests/Contracts/Interfaces/InterfaceContractsTest.php +++ b/tests/Contracts/Interfaces/InterfaceContractsTest.php @@ -6,19 +6,19 @@ * accidentally changed by a refactor. These are cheap and catch the * most common breakage (renames, missing methods, inheritance changes). * - * @package rtCamp\WPFramework\Tests\Contracts\Interfaces + * @package rtCamp\WPPrimitives\Tests\Contracts\Interfaces */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Tests\Contracts\Interfaces; +namespace rtCamp\WPPrimitives\Tests\Contracts\Interfaces; use PHPUnit\Framework\TestCase; use ReflectionClass; -use rtCamp\WPFramework\Contracts\Interfaces\CLICommand; -use rtCamp\WPFramework\Contracts\Interfaces\ConditionallyRegistrable; -use rtCamp\WPFramework\Contracts\Interfaces\Registrable; -use rtCamp\WPFramework\Contracts\Interfaces\Shareable; +use rtCamp\WPPrimitives\Contracts\Interfaces\CLICommand; +use rtCamp\WPPrimitives\Contracts\Interfaces\ConditionallyRegistrable; +use rtCamp\WPPrimitives\Contracts\Interfaces\Registrable; +use rtCamp\WPPrimitives\Contracts\Interfaces\Shareable; final class InterfaceContractsTest extends TestCase { diff --git a/tests/Fixtures/BareSingleton.php b/tests/Fixtures/BareSingleton.php index 4d74aad..12b31c5 100644 --- a/tests/Fixtures/BareSingleton.php +++ b/tests/Fixtures/BareSingleton.php @@ -5,14 +5,14 @@ * Exercises the trait's default protected __construct (SingletonExample * overrides it, so the default body would otherwise never run). * - * @package rtCamp\WPFramework\Tests\Fixtures + * @package rtCamp\WPPrimitives\Tests\Fixtures */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Tests\Fixtures; +namespace rtCamp\WPPrimitives\Tests\Fixtures; -use rtCamp\WPFramework\Contracts\Traits\Singleton; +use rtCamp\WPPrimitives\Contracts\Traits\Singleton; /** * Class - BareSingleton diff --git a/tests/Fixtures/FlakySingleton.php b/tests/Fixtures/FlakySingleton.php index 2c79629..57f263f 100644 --- a/tests/Fixtures/FlakySingleton.php +++ b/tests/Fixtures/FlakySingleton.php @@ -5,14 +5,14 @@ * Exercises the rollback path: a failed construction must not leave a * half-built instance published, and a later call must construct again. * - * @package rtCamp\WPFramework\Tests\Fixtures + * @package rtCamp\WPPrimitives\Tests\Fixtures */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Tests\Fixtures; +namespace rtCamp\WPPrimitives\Tests\Fixtures; -use rtCamp\WPFramework\Contracts\Traits\Singleton; +use rtCamp\WPPrimitives\Contracts\Traits\Singleton; /** * Class - FlakySingleton diff --git a/tests/Fixtures/LoaderFixtures.php b/tests/Fixtures/LoaderFixtures.php index a56d8d7..74f1b02 100644 --- a/tests/Fixtures/LoaderFixtures.php +++ b/tests/Fixtures/LoaderFixtures.php @@ -5,17 +5,17 @@ * Multiple classes per file — explicitly required from bootstrap.php * since PSR-4 cannot autoload them. * - * @package rtCamp\WPFramework\Tests\Fixtures + * @package rtCamp\WPPrimitives\Tests\Fixtures */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Tests\Fixtures; +namespace rtCamp\WPPrimitives\Tests\Fixtures; -use rtCamp\WPFramework\Contracts\Interfaces\ConditionallyRegistrable; -use rtCamp\WPFramework\Contracts\Interfaces\Registrable; -use rtCamp\WPFramework\Contracts\Interfaces\Shareable; -use rtCamp\WPFramework\Contracts\Traits\Loader; +use rtCamp\WPPrimitives\Contracts\Interfaces\ConditionallyRegistrable; +use rtCamp\WPPrimitives\Contracts\Interfaces\Registrable; +use rtCamp\WPPrimitives\Contracts\Interfaces\Shareable; +use rtCamp\WPPrimitives\Contracts\Traits\Loader; /** * Public wrapper around the Loader trait so tests can call load() and diff --git a/tests/Fixtures/ReentrantSingleton.php b/tests/Fixtures/ReentrantSingleton.php index d204303..7dfc90a 100644 --- a/tests/Fixtures/ReentrantSingleton.php +++ b/tests/Fixtures/ReentrantSingleton.php @@ -8,14 +8,14 @@ * constructing. The early assignment is the trait's documented re-entrancy * guard; this fixture pins that the property stays protected and assignable. * - * @package rtCamp\WPFramework\Tests\Fixtures + * @package rtCamp\WPPrimitives\Tests\Fixtures */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Tests\Fixtures; +namespace rtCamp\WPPrimitives\Tests\Fixtures; -use rtCamp\WPFramework\Contracts\Traits\Singleton; +use rtCamp\WPPrimitives\Contracts\Traits\Singleton; /** * Class - ReentrantSingleton diff --git a/tests/Fixtures/SingletonExample.php b/tests/Fixtures/SingletonExample.php index 75f5342..862ed21 100644 --- a/tests/Fixtures/SingletonExample.php +++ b/tests/Fixtures/SingletonExample.php @@ -2,14 +2,14 @@ /** * Singleton fixture class for SingletonTest. * - * @package rtCamp\WPFramework\Tests\Fixtures + * @package rtCamp\WPPrimitives\Tests\Fixtures */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Tests\Fixtures; +namespace rtCamp\WPPrimitives\Tests\Fixtures; -use rtCamp\WPFramework\Contracts\Traits\Singleton; +use rtCamp\WPPrimitives\Contracts\Traits\Singleton; /** * Class - SingletonExample diff --git a/tests/LoaderTest.php b/tests/LoaderTest.php index d35b5c3..8b24764 100644 --- a/tests/LoaderTest.php +++ b/tests/LoaderTest.php @@ -9,21 +9,21 @@ * - Shareable → instance cached, retrievable via get_shared() * - A class that is both Shareable and Registrable gets both treatments * - * @package rtCamp\WPFramework\Tests + * @package rtCamp\WPPrimitives\Tests */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Tests; +namespace rtCamp\WPPrimitives\Tests; use PHPUnit\Framework\TestCase; use RuntimeException; -use rtCamp\WPFramework\Tests\Fixtures\ConditionalAllowed; -use rtCamp\WPFramework\Tests\Fixtures\CountingRegistrable; -use rtCamp\WPFramework\Tests\Fixtures\ConditionalDenied; -use rtCamp\WPFramework\Tests\Fixtures\LoaderRunner; -use rtCamp\WPFramework\Tests\Fixtures\PlainRegistrable; -use rtCamp\WPFramework\Tests\Fixtures\ShareableRegistrable; +use rtCamp\WPPrimitives\Tests\Fixtures\ConditionalAllowed; +use rtCamp\WPPrimitives\Tests\Fixtures\CountingRegistrable; +use rtCamp\WPPrimitives\Tests\Fixtures\ConditionalDenied; +use rtCamp\WPPrimitives\Tests\Fixtures\LoaderRunner; +use rtCamp\WPPrimitives\Tests\Fixtures\PlainRegistrable; +use rtCamp\WPPrimitives\Tests\Fixtures\ShareableRegistrable; final class LoaderTest extends TestCase { diff --git a/tests/SingletonTest.php b/tests/SingletonTest.php index 653b08a..bd37ef6 100644 --- a/tests/SingletonTest.php +++ b/tests/SingletonTest.php @@ -2,18 +2,18 @@ /** * Singleton trait tests. * - * @package rtCamp\WPFramework\Tests + * @package rtCamp\WPPrimitives\Tests */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Tests; +namespace rtCamp\WPPrimitives\Tests; -use rtCamp\WPFramework\Tests\Fixtures\BareSingleton; -use rtCamp\WPFramework\Tests\Fixtures\FlakySingleton; -use rtCamp\WPFramework\Tests\Fixtures\ReentrantSingleton; -use rtCamp\WPFramework\Tests\Fixtures\SingletonExample; -use rtCamp\WPFramework\Tests\TestCase; +use rtCamp\WPPrimitives\Tests\Fixtures\BareSingleton; +use rtCamp\WPPrimitives\Tests\Fixtures\FlakySingleton; +use rtCamp\WPPrimitives\Tests\Fixtures\ReentrantSingleton; +use rtCamp\WPPrimitives\Tests\Fixtures\SingletonExample; +use rtCamp\WPPrimitives\Tests\TestCase; final class SingletonTest extends TestCase { diff --git a/tests/TemplateLoaderTest.php b/tests/TemplateLoaderTest.php index 3ad0a14..ef221f8 100644 --- a/tests/TemplateLoaderTest.php +++ b/tests/TemplateLoaderTest.php @@ -7,14 +7,14 @@ * filters (TestCase::set_theme_dirs), and rendering is asserted through real * load_template() output rather than a stub call log. * - * @package rtCamp\WPFramework\Tests + * @package rtCamp\WPPrimitives\Tests */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Tests; +namespace rtCamp\WPPrimitives\Tests; -use rtCamp\WPFramework\TemplateLoader; +use rtCamp\WPPrimitives\TemplateLoader; /** * Class TemplateLoaderTest diff --git a/tests/TestCase.php b/tests/TestCase.php index fb00419..53f13c5 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -7,12 +7,12 @@ * tests need repeatedly: pointing the theme hierarchy at fixture directories * and reading back the real script/style/module registries. * - * @package rtCamp\WPFramework\Tests + * @package rtCamp\WPPrimitives\Tests */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Tests; +namespace rtCamp\WPPrimitives\Tests; use WP_UnitTestCase; diff --git a/tests/Utils/CacheTest.php b/tests/Utils/CacheTest.php index b7f3569..c5f9bb9 100644 --- a/tests/Utils/CacheTest.php +++ b/tests/Utils/CacheTest.php @@ -2,15 +2,15 @@ /** * Cache utility tests. * - * @package rtCamp\WPFramework\Tests\Utils + * @package rtCamp\WPPrimitives\Tests\Utils */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Tests\Utils; +namespace rtCamp\WPPrimitives\Tests\Utils; -use rtCamp\WPFramework\Tests\TestCase; -use rtCamp\WPFramework\Utils\Cache; +use rtCamp\WPPrimitives\Tests\TestCase; +use rtCamp\WPPrimitives\Utils\Cache; /** * Tests for Cache. diff --git a/tests/Utils/EncryptorTest.php b/tests/Utils/EncryptorTest.php index 6717c24..1509efb 100644 --- a/tests/Utils/EncryptorTest.php +++ b/tests/Utils/EncryptorTest.php @@ -2,15 +2,15 @@ /** * Encryptor tests. * - * @package rtCamp\WPFramework\Tests + * @package rtCamp\WPPrimitives\Tests */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Tests\Utils; +namespace rtCamp\WPPrimitives\Tests\Utils; -use rtCamp\WPFramework\Tests\TestCase; -use rtCamp\WPFramework\Utils\Encryptor; +use rtCamp\WPPrimitives\Tests\TestCase; +use rtCamp\WPPrimitives\Utils\Encryptor; /** * Tests for Encryptor. diff --git a/tests/Utils/FeatureSelectorSettingsPageTest.php b/tests/Utils/FeatureSelectorSettingsPageTest.php index 632c286..e3ffca9 100644 --- a/tests/Utils/FeatureSelectorSettingsPageTest.php +++ b/tests/Utils/FeatureSelectorSettingsPageTest.php @@ -2,16 +2,16 @@ /** * FeatureSelectorSettingsPage utility tests. * - * @package rtCamp\WPFramework\Tests + * @package rtCamp\WPPrimitives\Tests */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Tests\Utils; +namespace rtCamp\WPPrimitives\Tests\Utils; -use rtCamp\WPFramework\Tests\TestCase; -use rtCamp\WPFramework\Utils\FeatureSelector; -use rtCamp\WPFramework\Utils\FeatureSelectorSettingsPage; +use rtCamp\WPPrimitives\Tests\TestCase; +use rtCamp\WPPrimitives\Utils\FeatureSelector; +use rtCamp\WPPrimitives\Utils\FeatureSelectorSettingsPage; /** * Tests for FeatureSelectorSettingsPage. diff --git a/tests/Utils/FeatureSelectorTest.php b/tests/Utils/FeatureSelectorTest.php index cbf176b..82d8e91 100644 --- a/tests/Utils/FeatureSelectorTest.php +++ b/tests/Utils/FeatureSelectorTest.php @@ -2,15 +2,15 @@ /** * FeatureSelector utility tests. * - * @package rtCamp\WPFramework\Tests + * @package rtCamp\WPPrimitives\Tests */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Tests\Utils; +namespace rtCamp\WPPrimitives\Tests\Utils; -use rtCamp\WPFramework\Tests\TestCase; -use rtCamp\WPFramework\Utils\FeatureSelector; +use rtCamp\WPPrimitives\Tests\TestCase; +use rtCamp\WPPrimitives\Utils\FeatureSelector; /** * Tests for FeatureSelector. @@ -80,7 +80,7 @@ public function test_register_accepts_a_bare_slug_string(): void { } public function test_register_keeps_first_registration_and_warns_on_duplicate(): void { - $this->setExpectedIncorrectUsage( 'rtCamp\WPFramework\Utils\FeatureSelector::register' ); + $this->setExpectedIncorrectUsage( 'rtCamp\WPPrimitives\Utils\FeatureSelector::register' ); $this->selector->register( [ 'my-flag' => [ 'name' => 'Original' ] ] ); $this->selector->register( [ 'my-flag' => [ 'name' => 'Updated' ] ] ); @@ -90,7 +90,7 @@ public function test_register_keeps_first_registration_and_warns_on_duplicate(): } public function test_register_warns_on_slugs_that_normalize_to_the_same_key(): void { - $this->setExpectedIncorrectUsage( 'rtCamp\WPFramework\Utils\FeatureSelector::register' ); + $this->setExpectedIncorrectUsage( 'rtCamp\WPPrimitives\Utils\FeatureSelector::register' ); $this->selector->register( [ 'beta-search' ] ); $this->selector->register( [ 'beta search' ] ); // Normalizes to the same key. @@ -136,14 +136,14 @@ public function test_enable_and_disable_persist_to_option(): void { public function test_enable_refuses_and_warns_for_an_unregistered_flag(): void { // A typo'd toggle is a programming error: nothing is persisted, and the // caller is flagged loudly rather than silently believing it took effect. - $this->setExpectedIncorrectUsage( 'rtCamp\WPFramework\Utils\FeatureSelector::enable' ); + $this->setExpectedIncorrectUsage( 'rtCamp\WPPrimitives\Utils\FeatureSelector::enable' ); $this->assertFalse( $this->selector->enable( 'drak-mode' ) ); $this->assertFalse( get_option( 'my_plugin_features', false ) ); } public function test_disable_refuses_and_warns_for_an_unregistered_flag(): void { - $this->setExpectedIncorrectUsage( 'rtCamp\WPFramework\Utils\FeatureSelector::disable' ); + $this->setExpectedIncorrectUsage( 'rtCamp\WPPrimitives\Utils\FeatureSelector::disable' ); $this->assertFalse( $this->selector->disable( 'drak-mode' ) ); $this->assertFalse( get_option( 'my_plugin_features', false ) ); diff --git a/tests/Utils/LoggerTest.php b/tests/Utils/LoggerTest.php index c09c8ea..7bcf688 100644 --- a/tests/Utils/LoggerTest.php +++ b/tests/Utils/LoggerTest.php @@ -2,15 +2,15 @@ /** * Logger utility tests. * - * @package rtCamp\WPFramework\Tests\Utils + * @package rtCamp\WPPrimitives\Tests\Utils */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Tests\Utils; +namespace rtCamp\WPPrimitives\Tests\Utils; -use rtCamp\WPFramework\Tests\TestCase; -use rtCamp\WPFramework\Utils\Logger; +use rtCamp\WPPrimitives\Tests\TestCase; +use rtCamp\WPPrimitives\Utils\Logger; /** * Tests for Logger. diff --git a/tests/Utils/TimerTest.php b/tests/Utils/TimerTest.php index 080ab5b..a3372bd 100644 --- a/tests/Utils/TimerTest.php +++ b/tests/Utils/TimerTest.php @@ -2,15 +2,15 @@ /** * Timer utility tests. * - * @package rtCamp\WPFramework\Tests\Utils + * @package rtCamp\WPPrimitives\Tests\Utils */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Tests\Utils; +namespace rtCamp\WPPrimitives\Tests\Utils; -use rtCamp\WPFramework\Tests\TestCase; -use rtCamp\WPFramework\Utils\Timer; +use rtCamp\WPPrimitives\Tests\TestCase; +use rtCamp\WPPrimitives\Utils\Timer; /** * Tests for Timer. diff --git a/tests/Utils/TransientsTest.php b/tests/Utils/TransientsTest.php index d8b7dab..2a105ac 100644 --- a/tests/Utils/TransientsTest.php +++ b/tests/Utils/TransientsTest.php @@ -2,15 +2,15 @@ /** * Transients utility tests. * - * @package rtCamp\WPFramework\Tests\Utils + * @package rtCamp\WPPrimitives\Tests\Utils */ declare( strict_types = 1 ); -namespace rtCamp\WPFramework\Tests\Utils; +namespace rtCamp\WPPrimitives\Tests\Utils; -use rtCamp\WPFramework\Tests\TestCase; -use rtCamp\WPFramework\Utils\Transients; +use rtCamp\WPPrimitives\Tests\TestCase; +use rtCamp\WPPrimitives\Utils\Transients; /** * Tests for Transients. diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 17ecbcd..e3e72d2 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -7,7 +7,7 @@ * The framework is a library — there is no plugin or theme to activate; tests * instantiate its classes directly once WordPress is loaded. * - * @package rtCamp\WPFramework\Tests + * @package rtCamp\WPPrimitives\Tests */ declare( strict_types = 1 ); From 560b1895d2c94c07639d4f459b52c5f6013069d9 Mon Sep 17 00:00:00 2001 From: Aryan Jasala Date: Mon, 28 Sep 2026 05:35:14 +0530 Subject: [PATCH 2/3] fix: address rename audit findings - restore truthful composer.lock where the rename had falsified it - correct unresolvable ^1.0 constraints in install docs - document the HANDLE_PREFIX and text-domain breaks - add the 1.0.x to 2.0.0 migration guide - prune the superseded instructions file on sync --- CHANGELOG.md | 13 +++++++++++- README.md | 2 +- bin/sync-ai-instructions.js | 26 ++++++++++++++++++++++- composer.json | 5 +++++ composer.lock | 8 +++---- docs/getting-started.md | 6 +++--- docs/upgrading.md | 42 ++++++++++++++++++++++++++++++++++++- 7 files changed, 91 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d44c14d..4bc83e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 existing `v1.0.0` / `v1.0.1` tags, which keep the old package name. Reason: `10up/wp-framework` occupies the same name in the same category on Packagist. +- **BREAKING: `AssetLoader::HANDLE_PREFIX` default changes from `wp-framework-` to + `wp-primitives-`.** Any consumer that did not override the constant will see every + default asset handle change, so `wp_add_inline_script()`, `wp_localize_script()`, + dependency arrays and dequeue calls that referenced a `wp-framework-*` handle by + string must be updated. Override `HANDLE_PREFIX` in your subclass to keep the old + handles. +- **BREAKING: the gettext text domain changes from `wp-framework` to `wp-primitives`** + across the 23 translated strings in `inc/`. No `.pot`, `.po` or `.mo` files ship with + this package, so nothing in-repo breaks, but any consumer shipping translations for + the old domain must retarget them. + ### Documentation - Added implementor getting-started and maintainer workflow guides; corrected @@ -27,7 +38,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 migration) and `docs/troubleshooting.md` (symptom → cause for the framework's exceptions, `_doing_it_wrong()` notices, and silent no-ops). - Documented the real install path: the package is not on public Packagist, so - the consumer needs a VCS `repositories` entry and a `^1.0` constraint. + the consumer needs a VCS `repositories` entry and a `^2.0` constraint. - Added a worked WP-CLI example to `docs/contracts.md`, the only contract that had none, and a quick-look snippet to the README. - Corrected the `Loader::load()` snippet in `docs/architecture.md` to match the diff --git a/README.md b/README.md index 0bd88cd..371c822 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Not on public Packagist — add the repository to the consuming project's ``` ```bash -composer require rtcamp/wp-primitives:^1.0 +composer require rtcamp/wp-primitives:^2.0 ``` (The `repositories` entry is unnecessary when the project already resolves this diff --git a/bin/sync-ai-instructions.js b/bin/sync-ai-instructions.js index 88b2b10..20e0c32 100644 --- a/bin/sync-ai-instructions.js +++ b/bin/sync-ai-instructions.js @@ -32,6 +32,12 @@ const PACKAGE_DIRS = [ 'plugins', 'themes' ]; const FRAMEWORK_SRC = 'vendor/rtcamp/wp-primitives/ai/primitives-php.instructions.md'; const MARKER = ''; +// Pre-2.0 this package was rtcamp/wp-framework and shipped framework-php.instructions.md. +// Consumers upgrading across the rename still have the old file committed; recognise it so +// refreshPackage() can delete it and the root prune step can sweep any projected copies. +const LEGACY_INSTRUCTION_FILE = 'framework-php.instructions.md'; +const LEGACY_MARKER = ''; + // Copilot code review reads only the first ~4000 chars of an instruction file. const COPILOT_CHAR_LIMIT = 4000; @@ -187,6 +193,18 @@ const refreshPackage = ( base, relRoot ) => { } const dest = path.join( base, '.github', 'instructions', 'primitives-php.instructions.md' ); writeIfChanged( dest, withMarker( fs.readFileSync( src, 'utf8' ) ), relRoot, 'refresh' ); + + // Migration from <2.0: drop the superseded filename so it is not projected to the root + // and so Copilot does not read two copies of the same rules. + const legacy = path.join( base, '.github', 'instructions', LEGACY_INSTRUCTION_FILE ); + if ( fs.existsSync( legacy ) ) { + drift = true; + log.push( color.red( ` prune ${ relRoot }/.github/instructions/${ LEGACY_INSTRUCTION_FILE }` ) ); + if ( ! isCheck ) { + fs.unlinkSync( legacy ); + } + } + return true; }; @@ -226,7 +244,13 @@ const projectToRoot = ( root, packages ) => { if ( fs.existsSync( outDir ) ) { const wanted = new Set( Object.keys( outputs ) ); fs.readdirSync( outDir ) - .filter( ( f ) => ! wanted.has( f ) && fs.readFileSync( path.join( outDir, f ), 'utf8' ).includes( MARKER ) ) + .filter( ( f ) => { + if ( wanted.has( f ) ) { + return false; + } + const body = fs.readFileSync( path.join( outDir, f ), 'utf8' ); + return body.includes( MARKER ) || body.includes( LEGACY_MARKER ); + } ) .forEach( ( f ) => { drift = true; log.push( color.red( ` prune .github/instructions/${ f }` ) ); diff --git a/composer.json b/composer.json index 0ec49ac..1c02ee8 100644 --- a/composer.json +++ b/composer.json @@ -58,6 +58,11 @@ "test": "Run the PHPUnit test suite.", "check": "Run lint + analyse + test in sequence. Exit code 0 if all green." }, + "extra": { + "branch-alias": { + "dev-main": "2.0.x-dev" + } + }, "minimum-stability": "stable", "prefer-stable": true } diff --git a/composer.lock b/composer.lock index 4a82d5a..ad7ebbe 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "11e30dd51c7bf66e7f860fc7eca4d36b", + "content-hash": "90832f0a54275b28f76520bf5a51f693", "packages": [], "packages-dev": [ { @@ -2836,12 +2836,12 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": {}, + "stability-flags": [], "prefer-stable": true, "prefer-lowest": false, "platform": { "php": ">=8.2" }, - "platform-dev": {}, - "plugin-api-version": "2.9.0" + "platform-dev": [], + "plugin-api-version": "2.6.0" } diff --git a/docs/getting-started.md b/docs/getting-started.md index e90c687..f1b0987 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -36,15 +36,15 @@ consuming project's `composer.json` first, then require it: ``` ```bash -composer require rtcamp/wp-primitives:^1.0 +composer require rtcamp/wp-primitives:^2.0 ``` If the project is already wired to an rtCamp-hosted Composer registry that serves this package, the `repositories` entry is unnecessary and -`composer require rtcamp/wp-primitives:^1.0` is enough on its own. +`composer require rtcamp/wp-primitives:^2.0` is enough on its own. Pin with a caret constraint. `inc/Contracts/` is the public API and the project -follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html), so `^1.0` +follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html), so `^2.0` accepts additive releases and refuses the next major. Read [upgrading.md](upgrading.md) before moving across a major. diff --git a/docs/upgrading.md b/docs/upgrading.md index 9cc947f..38283a5 100644 --- a/docs/upgrading.md +++ b/docs/upgrading.md @@ -24,7 +24,7 @@ interface, abstract, trait, and public method signature under it. | New `abstract` method on an existing abstract | major | Every subclass must implement it. | | Behavior fix inside an existing method | patch | Usually none — read the entry. | -Pin with `^1.0` so Composer takes minors and patches and refuses the next major. +Pin with `^2.0` so Composer takes minors and patches and refuses the next major. Read this page and the changelog before widening a constraint across a major. ## Upgrade routine @@ -38,6 +38,46 @@ Then run the consumer's own test suite. Static analysis catches the majority of contract breaks (a missing abstract implementation, a changed signature) before runtime does. +## 1.0.x → 2.0.0 (package rename) + +**Affects:** every consumer. 2.0.0 renames the package, so `composer update` alone +cannot cross it. + +1. Replace the requirement and the VCS repository entry in the consumer's + `composer.json`: + + ```diff + -"rtcamp/wp-framework": "^1.0" + +"rtcamp/wp-primitives": "^2.0" + ``` + + ```diff + -{ "type": "vcs", "url": "https://github.com/rtCamp/wp-framework.git", "no-api": true } + +{ "type": "vcs", "url": "https://github.com/rtCamp/wp-primitives.git", "no-api": true } + ``` + + Then `composer remove rtcamp/wp-framework && composer require rtcamp/wp-primitives:^2.0`. + The GitHub redirect keeps the old URL resolving, but the package name it serves has + changed, so the requirement must be edited by hand. + +2. Rewrite the namespace across the consumer: `rtCamp\WPFramework\` becomes + `rtCamp\WPPrimitives\` in every `namespace` declaration, `use` statement, PHPDoc + annotation and class-string. + +3. If you subclass `AssetLoader` without overriding `HANDLE_PREFIX`, every default + asset handle changes from `wp-framework-*` to `wp-primitives-*`. Audit any handle + referenced as a literal string. + +4. Retarget any translations from the `wp-framework` text domain to `wp-primitives`. + +5. Run `npm run sync-ai`. It now writes + `.github/instructions/primitives-php.instructions.md` and deletes the superseded + `framework-php.instructions.md`. + +Projects that are not ready can stay on `^1.0`, which continues to resolve from the +`v1.0.0` and `v1.0.1` tags. Those tags are immutable and still declare the old package +name, so they keep working; they will not receive further releases. + ## 1.0.0 → 1.0.1 **Affects:** any class using the `Singleton` trait. From d1ec6568523161675dde8a8dad48401ca6205f5a Mon Sep 17 00:00:00 2001 From: Aryan Jasala Date: Thu, 1 Oct 2026 19:22:23 +0530 Subject: [PATCH 3/3] docs(changelog): drop the rename rationale from the 2.0.0 entry --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bc83e9..354ad36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 (synced into consumers as `.github/instructions/primitives-php.instructions.md`). Consumers must move to a `^2.0` constraint; `^1.0` continues to resolve from the existing `v1.0.0` / `v1.0.1` tags, which keep the old package name. - Reason: `10up/wp-framework` occupies the same name in the same category on Packagist. - **BREAKING: `AssetLoader::HANDLE_PREFIX` default changes from `wp-framework-` to `wp-primitives-`.** Any consumer that did not override the constant will see every