From 293a389a2dc470281472dcdc58718581114004d5 Mon Sep 17 00:00:00 2001 From: Aditya Singh Date: Thu, 3 Dec 2026 10:53:49 +0530 Subject: [PATCH] build(deps-dev): adopt rtcamp/wp-phpstan 2 and run PHPStan level 8 in CI --- .claude/skills/scaffold/SKILL.md | 2 +- .claude/skills/setup/SKILL.md | 2 +- .distignore | 1 + .github/prompts/scaffold.prompt.md | 2 +- .github/workflows/test-measure.yml | 1 + AGENTS.md | 2 +- composer.json | 3 +- composer.lock | 58 +++---------------- docs/features.md | 2 +- docs/internal/maintenance.md | 1 - docs/local-development.md | 2 +- docs/scaffolding.md | 2 +- inc/Modules/Blocks/ExampleDynamicBlock.php | 6 +- inc/Modules/CLI/Healthcheck.php | 4 +- inc/Modules/PostTypes/ExamplePostType.php | 4 +- inc/Modules/PostTypes/ExamplePostTypeTwo.php | 4 +- inc/Modules/Roles/ExampleUserRole.php | 2 +- inc/Modules/Shortcodes/ExampleShortcode.php | 4 +- inc/Modules/Taxonomies/ExampleTaxonomy.php | 4 +- inc/Modules/Taxonomies/ExampleTaxonomyTwo.php | 4 +- phpstan-baseline.neon | 2 + phpstan.neon.dist | 10 +++- 22 files changed, 42 insertions(+), 80 deletions(-) create mode 100644 phpstan-baseline.neon diff --git a/.claude/skills/scaffold/SKILL.md b/.claude/skills/scaffold/SKILL.md index 3462e22..3c36f9b 100644 --- a/.claude/skills/scaffold/SKILL.md +++ b/.claude/skills/scaffold/SKILL.md @@ -164,7 +164,7 @@ For block scaffolds, surface a developer action before testing: "run `npm run bu | D | Re-run. Confirm that one test passes. | | E | Loop B-D one test at a time. | | F | Once green, refactor; re-run. | -| G | Final gates - all must pass: full PHPUnit suite (`npm run test:php`), full Jest suite if JS touched (`npm run test:js`), `composer format` (phpcbf), `composer lint` (phpcs), `composer phpstan` (PHPStan level 5), `npm run lint:js`. Never silence a real phpcs/phpstan finding with a blanket ignore; fix it, or escalate (§8). | +| G | Final gates - all must pass: full PHPUnit suite (`npm run test:php`), full Jest suite if JS touched (`npm run test:js`), `composer format` (phpcbf), `composer lint` (phpcs), `composer phpstan` (PHPStan level 8), `npm run lint:js`. Never silence a real phpcs/phpstan finding with a blanket ignore; fix it, or escalate (§8). | Frameworks per kind: diff --git a/.claude/skills/setup/SKILL.md b/.claude/skills/setup/SKILL.md index 1b886e2..59f4fc2 100644 --- a/.claude/skills/setup/SKILL.md +++ b/.claude/skills/setup/SKILL.md @@ -211,7 +211,7 @@ npx wp-tooling add wp/cli \ The engine emits `ai.wiring` (where to register the command) and a thin test stub at `tests/Cli/OptimizeImagesCommandTest.php`. Show the wiring snippet, get consent, apply. Then turn the stub into a real test suite (happy path, dry-run flag, edge cases, error handling) and implement `__invoke()` test-by-test until the suite is green. Never leave `markTestIncomplete` in the final state. -**Code quality (required).** For any PHP a feature scaffold writes or changes under `inc/` or `tests/`, run the compliance pipeline once the implementation is green, exactly as in the `scaffold` skill (`skills/scaffold.md` §7a): `composer format` (phpcbf) -> `composer lint` (phpcs, `rtCampWP` ruleset via `phpcs.xml.dist`) -> `composer phpstan` (PHPStan level 5 via `phpstan.neon.dist`), resolving every finding in the generated code. Write it compliant in the first place (`declare( strict_types = 1 );`, short arrays, typed signatures, prefixed globals, documented). If a fix is unclear or would change behaviour, public API, or intent, STOP and ask - never silence a real issue with a blanket `phpcs:ignore` / `@phpstan-ignore`. +**Code quality (required).** For any PHP a feature scaffold writes or changes under `inc/` or `tests/`, run the compliance pipeline once the implementation is green, exactly as in the `scaffold` skill (`skills/scaffold.md` §7a): `composer format` (phpcbf) -> `composer lint` (phpcs, `rtCampWP` ruleset via `phpcs.xml.dist`) -> `composer phpstan` (PHPStan level 8 via `phpstan.neon.dist`), resolving every finding in the generated code. Write it compliant in the first place (`declare( strict_types = 1 );`, short arrays, typed signatures, prefixed globals, documented). If a fix is unclear or would change behaviour, public API, or intent, STOP and ask - never silence a real issue with a blanket `phpcs:ignore` / `@phpstan-ignore`. **Phase B feature scaffolds require the matching test framework from Phase A.** If Phase A skipped `setup/phpunit` because the developer did not ask for tests, surface this before running Phase B feature scaffolds: diff --git a/.distignore b/.distignore index a49a3a4..5e466f1 100644 --- a/.distignore +++ b/.distignore @@ -15,6 +15,7 @@ /*.config.js /*.config.mjs /*.dist +/*.neon /AGENTS.md /CLAUDE.md /CONTRIBUTING.md diff --git a/.github/prompts/scaffold.prompt.md b/.github/prompts/scaffold.prompt.md index ae196ac..3bc8d89 100644 --- a/.github/prompts/scaffold.prompt.md +++ b/.github/prompts/scaffold.prompt.md @@ -47,7 +47,7 @@ Apply project-sampled conventions (class suffix, sub-namespace, vendor prefix, b Tests before implementation, no exceptions. A. Expand the engine stub into the full suite from §4; strip every `markTestIncomplete`. B. Run `composer test` (PHP) / `npm run test:js` (JS); expect red. C. Implement just enough to flip ONE test green. D. Re-run. E. Loop B-D one test at a time. F. Refactor, re-run. G. Final gates: full PHPUnit, full Jest if JS touched, PHP compliance (§7a), `npm run lint:js`. For blocks, surface `npm run build` as a developer action before testing. ### 7a. PHP compliance (required, on changed PHP) -Write compliant PHP up front (`declare( strict_types = 1 );`, short arrays, full types, prefixed globals, `@package`/`@since`, `static::`). Then: `composer format` (phpcbf) → `composer lint` (phpcs, `rtCampWP` ruleset) → `composer phpstan` (level 5). Resolve every finding in the generated code. Never silence a real issue with a blanket `phpcs:ignore`/`@phpstan-ignore`; if a fix is unclear or changes behaviour/API, STOP and ask. +Write compliant PHP up front (`declare( strict_types = 1 );`, short arrays, full types, prefixed globals, `@package`/`@since`, `static::`). Then: `composer format` (phpcbf) → `composer lint` (phpcs, `rtCampWP` ruleset) → `composer phpstan` (level 8). Resolve every finding in the generated code. Never silence a real issue with a blanket `phpcs:ignore`/`@phpstan-ignore`; if a fix is unclear or changes behaviour/API, STOP and ask. ### 8. Escalate when stuck (do not guess) Stop and report (what you tried, observed, what's blocking, 1-3 options) after: 3 stuck C-D iterations on one test; a result contradicting your model (re-read the file); conflicting project patterns; ambiguity after one clarification. diff --git a/.github/workflows/test-measure.yml b/.github/workflows/test-measure.yml index 608d430..f5aca52 100644 --- a/.github/workflows/test-measure.yml +++ b/.github/workflows/test-measure.yml @@ -38,5 +38,6 @@ jobs: test-php-exclude: '[]' lint-js-files-command: npm run lint:js:files lint-css-files-command: npm run lint:css:files + enable-phpstan: true # No tokens: every rtCamp dependency is public and the shared workflow falls # back to GITHUB_TOKEN. A PAT here breaks all dist downloads once it expires. diff --git a/AGENTS.md b/AGENTS.md index b61240b..a309cea 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -14,7 +14,7 @@ The review rules ARE the coding rules: the files Copilot reviews against are the ## Stack - **PHP 8.2+**, Composer, PSR-4: `Project_Name\Features\` → `inc/`; tests `Project_Name\Features\Tests\` → `tests/php/` (namespace === directory, filename === class). -- **PHPUnit + `wp-phpunit`** in `tests/php/` (mirrors `inc/`), run under `wp-env`. **PHPCS** (the shared `rtCampWP` ruleset from `rtcamp/wp-phpcs`: WPCS + VIP + Docs + Slevomat) and **PHPStan** (level 5, the `rtcamp/wp-phpstan` baseline): zero errors before merge. +- **PHPUnit + `wp-phpunit`** in `tests/php/` (mirrors `inc/`), run under `wp-env`. **PHPCS** (the shared `rtCampWP` ruleset from `rtcamp/wp-phpcs`: WPCS + VIP + Docs + Slevomat) and **PHPStan** (level 8, the `rtcamp/wp-phpstan` baseline): zero errors before merge. - **Node 24**, build via `@wordpress/scripts` + a custom `webpack.config.js`. Source in `src/{blocks,css,js}`, output in `assets/build/`. ## Structure diff --git a/composer.json b/composer.json index 174380e..19d030e 100644 --- a/composer.json +++ b/composer.json @@ -9,13 +9,12 @@ }, "require-dev": { "dealerdirect/phpcodesniffer-composer-installer": "^1.2", - "php-stubs/wp-cli-stubs": "^2.12", "phpstan/extension-installer": "^1.3", "phpstan/phpstan-deprecation-rules": "^2.0", "phpstan/phpstan-phpunit": "^2.1", "phpunit/phpunit": "^9.6", "rtcamp/wp-phpcs": "^1.0", - "rtcamp/wp-phpstan": "^1.0", + "rtcamp/wp-phpstan": "^2.0", "wp-cli/i18n-command": "^2.4", "wp-phpunit/wp-phpunit": "^7.1", "yoast/phpunit-polyfills": "^4.0" diff --git a/composer.lock b/composer.lock index 289fdf5..1ae2acd 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": "33c98af0f5d8e68c8a5ef22f0cdf34f7", + "content-hash": "886acbbdf102199ec9f83e1cb3b52629", "packages": [ { "name": "rtcamp/wp-primitives", @@ -847,50 +847,6 @@ }, "time": "2026-05-01T20:36:01+00:00" }, - { - "name": "php-stubs/wp-cli-stubs", - "version": "v2.12.0", - "source": { - "type": "git", - "url": "https://github.com/php-stubs/wp-cli-stubs.git", - "reference": "af16401e299a3fd2229bd0fa9a037638a4174a9d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-stubs/wp-cli-stubs/zipball/af16401e299a3fd2229bd0fa9a037638a4174a9d", - "reference": "af16401e299a3fd2229bd0fa9a037638a4174a9d", - "shasum": "" - }, - "require": { - "php-stubs/wordpress-stubs": "^4.7 || ^5.0 || ^6.0" - }, - "require-dev": { - "php": "~7.3 || ~8.0", - "php-stubs/generator": "^0.8.0" - }, - "suggest": { - "symfony/polyfill-php73": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", - "szepeviktor/phpstan-wordpress": "WordPress extensions for PHPStan" - }, - "type": "library", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "WP-CLI function and class declaration stubs for static analysis.", - "homepage": "https://github.com/php-stubs/wp-cli-stubs", - "keywords": [ - "PHPStan", - "static analysis", - "wordpress", - "wp-cli" - ], - "support": { - "issues": "https://github.com/php-stubs/wp-cli-stubs/issues", - "source": "https://github.com/php-stubs/wp-cli-stubs/tree/v2.12.0" - }, - "time": "2025-06-10T09:58:05+00:00" - }, { "name": "phpcompatibility/php-compatibility", "version": "9.3.5", @@ -2015,21 +1971,21 @@ }, { "name": "rtcamp/wp-phpstan", - "version": "v1.0.1", + "version": "v2.0.0", "source": { "type": "git", "url": "https://github.com/rtCamp/wp-phpstan.git", - "reference": "3252dfb4264f3de4a574201ee7f6ec3c0ad2bc26" + "reference": "6a704dc96716b803e86a39d163b9b42e347c212d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/rtCamp/wp-phpstan/zipball/3252dfb4264f3de4a574201ee7f6ec3c0ad2bc26", - "reference": "3252dfb4264f3de4a574201ee7f6ec3c0ad2bc26", + "url": "https://api.github.com/repos/rtCamp/wp-phpstan/zipball/6a704dc96716b803e86a39d163b9b42e347c212d", + "reference": "6a704dc96716b803e86a39d163b9b42e347c212d", "shasum": "" }, "require": { "php": ">=8.2", - "phpstan/phpstan": "^2.0", + "phpstan/phpstan": "^2.3", "szepeviktor/phpstan-wordpress": "^2.0" }, "require-dev": { @@ -2058,7 +2014,7 @@ "issues": "https://github.com/rtCamp/wp-tooling/issues", "source": "https://github.com/rtCamp/wp-tooling/tree/main/composer-packages/phpstan" }, - "time": "2026-10-01T18:10:21+00:00" + "time": "2026-12-02T11:51:32+00:00" }, { "name": "sebastian/cli-parser", diff --git a/docs/features.md b/docs/features.md index aa220ff..4b688d2 100644 --- a/docs/features.md +++ b/docs/features.md @@ -19,7 +19,7 @@ These stay in every project, whichever example sets you remove. Most are thin pl | Encryption | `inc/Core/Encryption.php`, `Util::encryption()` | `Encryptor` ([utilities](https://github.com/rtCamp/wp-primitives/blob/v2.0.0/docs/utilities.md#encryptor)) | Define `ACME_CONTENT_FEATURES_ENCRYPTION_KEY` in `wp-config.php` first; without it, calls throw. `Util::encryption()->encrypt( $secret )` / `->decrypt()`. | | Activation and i18n | `inc/Core/PluginSetup.php` | `Registrable` | Stores `acme_content_features_version` on activation, unschedules the example cron job on deactivation, loads the text domain from `languages/`. | | Helpers | `inc/Helpers/Util.php` | — | Accessors for the shared services above, plus `get_data()` (reads `inc/data/.php`), `is_production()` and `is_mobile()`. | -| Quality checks | `tests/`, `phpcs.xml.dist`, `phpstan.neon.dist`, `eslint.config.mjs`, `.stylelintrc.json` | Shared `rtcamp/wp-phpcs`, `rtcamp/wp-phpstan`, `@rtcamp/eslint-config`, `@rtcamp/stylelint-config` | PHPUnit (one test per module), PHPCS, PHPStan level 5, ESLint, Stylelint, Jest. See [Check a change](local-development.md#check-a-change). | +| Quality checks | `tests/`, `phpcs.xml.dist`, `phpstan.neon.dist`, `eslint.config.mjs`, `.stylelintrc.json` | Shared `rtcamp/wp-phpcs`, `rtcamp/wp-phpstan`, `@rtcamp/eslint-config`, `@rtcamp/stylelint-config` | PHPUnit (one test per module), PHPCS, PHPStan level 8, ESLint, Stylelint, Jest. See [Check a change](local-development.md#check-a-change). | The shared services (`Assets`, `Templates`, `Components`, `Logger`, `Encryption`) implement `Shareable`, so the `Loader` keeps one instance in `Main`'s container. Why that is preferred over singletons is explained in the framework's [sharing vs. singletons](https://github.com/rtCamp/wp-primitives/blob/v2.0.0/docs/architecture.md#sharing-vs-singletons). diff --git a/docs/internal/maintenance.md b/docs/internal/maintenance.md index f7811c3..d0a5149 100644 --- a/docs/internal/maintenance.md +++ b/docs/internal/maintenance.md @@ -170,7 +170,6 @@ None at the moment. Keep implementation follow-ups out of documentation pull requests; record each with a reproduction and revision when it is picked up. -- **Release zip:** no `.distignore` ships, so `release:zip` includes `src/`, `docs/`, `graphify-out/`, AI files and dotfiles. - **Scaffold wiring targets:** `wp/rest` and `wp/cli` suggest `inc/Modules/Rest.php` and `inc/Modules/Cli.php`, but this skeleton's modules are `REST.php` and `CLI.php`, which are different files on case-sensitive filesystems. Keep the uppercase names (they match WordPress acronym style and the framework's `AbstractRESTController` / `CLICommand`); the skill adapts, and CLI users edit the existing file. Fix upstream in wp-tooling. - **Block scaffolder:** `npm run create:block` writes meta blocks to `src/blocks/meta-blocks/`, which `Assets::STATIC_BLOCKS` cannot register. - **Dangling references:** `PluginSetup::deactivate()` mentions a root `uninstall.php` and `Util::get_data()` reads `inc/data/`; neither ships. diff --git a/docs/local-development.md b/docs/local-development.md index 44e046a..01a75e1 100644 --- a/docs/local-development.md +++ b/docs/local-development.md @@ -58,7 +58,7 @@ npm run test:php # the whole suite # PHP style and static analysis — run on the host (PHP 8.2+). composer lint # PHPCS (rtCampWP ruleset) composer format # PHPCBF: auto-fix what PHPCS can -composer phpstan # PHPStan level 5 +composer phpstan # PHPStan level 8 # JavaScript, CSS and package.json. An initialized plugin has no Jest tests until you add one. npm run test:js diff --git a/docs/scaffolding.md b/docs/scaffolding.md index bcc23e6..46dae68 100644 --- a/docs/scaffolding.md +++ b/docs/scaffolding.md @@ -107,7 +107,7 @@ With `/init` and a feature brief, the same happens during setup: init keeps the Code should read the same whoever, or whatever, writes it: -- **The same standards, every run.** Generated code is checked against the gates a developer runs locally: [`phpcs.xml.dist`](../phpcs.xml.dist) (the shared `rtCampWP` ruleset: WPCS, VIP, docs, Slevomat), [`phpstan.neon.dist`](../phpstan.neon.dist) (the `rtcamp/wp-phpstan` level-5 baseline), [`eslint.config.mjs`](../eslint.config.mjs) and [`.stylelintrc.json`](../.stylelintrc.json). +- **The same standards, every run.** Generated code is checked against the gates a developer runs locally: [`phpcs.xml.dist`](../phpcs.xml.dist) (the shared `rtCampWP` ruleset: WPCS, VIP, docs, Slevomat), [`phpstan.neon.dist`](../phpstan.neon.dist) (the `rtcamp/wp-phpstan` level-8 baseline), [`eslint.config.mjs`](../eslint.config.mjs) and [`.stylelintrc.json`](../.stylelintrc.json). - **Verified, not just formatted.** The AI route writes the test first and runs it, then PHPCBF → PHPCS → PHPStan. - **No drift between developers.** Registration, wiring and lifecycle come from the [`rtcamp/wp-primitives`](https://github.com/rtCamp/wp-primitives/blob/v2.0.0/docs/abstracts.md) abstracts, so the structure is identical whoever generates it; review can focus on the logic. diff --git a/inc/Modules/Blocks/ExampleDynamicBlock.php b/inc/Modules/Blocks/ExampleDynamicBlock.php index 265ea32..e9cc2b9 100644 --- a/inc/Modules/Blocks/ExampleDynamicBlock.php +++ b/inc/Modules/Blocks/ExampleDynamicBlock.php @@ -35,9 +35,9 @@ protected function get_block_dir(): string { /** * {@inheritDoc} * - * @param array $attributes Block attributes. - * @param string $content Block inner content. - * @param \WP_Block $block Full block instance. + * @param array $attributes Block attributes. + * @param string $content Block inner content. + * @param \WP_Block $block Full block instance. * * @return string Rendered block HTML. */ diff --git a/inc/Modules/CLI/Healthcheck.php b/inc/Modules/CLI/Healthcheck.php index 1234be4..27840c9 100644 --- a/inc/Modules/CLI/Healthcheck.php +++ b/inc/Modules/CLI/Healthcheck.php @@ -35,8 +35,8 @@ public static function get_description(): string { /** * {@inheritDoc} * - * @param array $args Positional arguments passed to the command. - * @param array $assoc_args Associative arguments passed to the command. + * @param array $args Positional arguments passed to the command. + * @param array $assoc_args Associative arguments passed to the command. * * @return void */ diff --git a/inc/Modules/PostTypes/ExamplePostType.php b/inc/Modules/PostTypes/ExamplePostType.php index 537f83c..a2afe5f 100644 --- a/inc/Modules/PostTypes/ExamplePostType.php +++ b/inc/Modules/PostTypes/ExamplePostType.php @@ -27,14 +27,14 @@ public static function get_slug(): string { * {@inheritDoc} */ public function get_singular_label(): string { - return __( 'Post Type Label', 'project-name-features' ); + return __( 'Post Type Label', 'project-name-features' ) ?: 'Post Type Label'; } /** * {@inheritDoc} */ public function get_plural_label(): string { - return __( 'Post Type Labels', 'project-name-features' ); + return __( 'Post Type Labels', 'project-name-features' ) ?: 'Post Type Labels'; } /** diff --git a/inc/Modules/PostTypes/ExamplePostTypeTwo.php b/inc/Modules/PostTypes/ExamplePostTypeTwo.php index ddcf1c0..a8bbece 100644 --- a/inc/Modules/PostTypes/ExamplePostTypeTwo.php +++ b/inc/Modules/PostTypes/ExamplePostTypeTwo.php @@ -27,14 +27,14 @@ public static function get_slug(): string { * {@inheritDoc} */ public function get_singular_label(): string { - return __( 'Post Type Two Label', 'project-name-features' ); + return __( 'Post Type Two Label', 'project-name-features' ) ?: 'Post Type Two Label'; } /** * {@inheritDoc} */ public function get_plural_label(): string { - return __( 'Post Type Two Labels', 'project-name-features' ); + return __( 'Post Type Two Labels', 'project-name-features' ) ?: 'Post Type Two Labels'; } /** diff --git a/inc/Modules/Roles/ExampleUserRole.php b/inc/Modules/Roles/ExampleUserRole.php index 6ff0497..5182e12 100644 --- a/inc/Modules/Roles/ExampleUserRole.php +++ b/inc/Modules/Roles/ExampleUserRole.php @@ -31,7 +31,7 @@ public static function get_slug(): string { * {@inheritDoc} */ protected function get_display_name(): string { - return __( 'Content Editor', 'project-name-features' ); + return __( 'Content Editor', 'project-name-features' ) ?: 'Content Editor'; } /** diff --git a/inc/Modules/Shortcodes/ExampleShortcode.php b/inc/Modules/Shortcodes/ExampleShortcode.php index 8daaaa7..7aeab36 100644 --- a/inc/Modules/Shortcodes/ExampleShortcode.php +++ b/inc/Modules/Shortcodes/ExampleShortcode.php @@ -38,8 +38,8 @@ protected function default_atts(): array { /** * {@inheritDoc} * - * @param array $atts Shortcode attributes. - * @param string|null $content Shortcode inner content. + * @param array $atts Shortcode attributes. + * @param string|null $content Shortcode inner content. * * @return string Rendered shortcode output. */ diff --git a/inc/Modules/Taxonomies/ExampleTaxonomy.php b/inc/Modules/Taxonomies/ExampleTaxonomy.php index 783e972..d97a5b0 100644 --- a/inc/Modules/Taxonomies/ExampleTaxonomy.php +++ b/inc/Modules/Taxonomies/ExampleTaxonomy.php @@ -35,14 +35,14 @@ public static function get_object_types(): array { * {@inheritDoc} */ public function get_singular_label(): string { - return __( 'Taxonomy Label', 'project-name-features' ); + return __( 'Taxonomy Label', 'project-name-features' ) ?: 'Taxonomy Label'; } /** * {@inheritDoc} */ public function get_plural_label(): string { - return __( 'Taxonomy Labels', 'project-name-features' ); + return __( 'Taxonomy Labels', 'project-name-features' ) ?: 'Taxonomy Labels'; } /** diff --git a/inc/Modules/Taxonomies/ExampleTaxonomyTwo.php b/inc/Modules/Taxonomies/ExampleTaxonomyTwo.php index d7feca4..667a378 100644 --- a/inc/Modules/Taxonomies/ExampleTaxonomyTwo.php +++ b/inc/Modules/Taxonomies/ExampleTaxonomyTwo.php @@ -35,13 +35,13 @@ public static function get_object_types(): array { * {@inheritDoc} */ public function get_singular_label(): string { - return __( 'Taxonomy Two Label', 'project-name-features' ); + return __( 'Taxonomy Two Label', 'project-name-features' ) ?: 'Taxonomy Two Label'; } /** * {@inheritDoc} */ public function get_plural_label(): string { - return __( 'Taxonomy Two Labels', 'project-name-features' ); + return __( 'Taxonomy Two Labels', 'project-name-features' ) ?: 'Taxonomy Two Labels'; } } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 0000000..f51e71c --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,2 @@ +parameters: + ignoreErrors: [] diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 8e789eb..70196f6 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,18 +1,22 @@ # PHPStan configuration for this features plugin. # -# Extends the shared rtCamp baseline (level 5, WordPress-aware). The baseline +# Extends the shared rtCamp baseline (level 8, WordPress-aware). The baseline # already loads the szepeviktor/phpstan-wordpress extension exactly once, so do # NOT include extension.neon here and do NOT rely on extension-installer for it # (composer.json ignores it for extension-installer). includes: - vendor/rtcamp/wp-phpstan/phpstan.neon.dist + - phpstan-baseline.neon parameters: - # The plugin constants (PROJECT_NAME_FEATURES_*) are define()d in the root - # plugin file, which is not under `paths: inc`. Load it so PHPStan knows them. + # Runs the root file so PHPStan knows the PROJECT_NAME_FEATURES_* constants. bootstrapFiles: - project-name-features.php + # Overridable in wp-config.php, so not fixed to the bootstrap value. + dynamicConstantNames: + - PROJECT_NAME_FEATURES_ENABLE_TAILWIND paths: + - project-name-features.php - inc excludePaths: # `assets/build` only exists after a block build; mark optional so PHPStan