Skip to content

fix(scaffolds): ask for lint/phpstan paths instead of hardcoding them - #84

Open
Adi-ty wants to merge 3 commits into
feat/wp-phpstan-level-8from
fix/wp-tooling-phpstan-scaffold-paths
Open

Adi-ty wants to merge 3 commits into
feat/wp-phpstan-level-8from
fix/wp-tooling-phpstan-scaffold-paths

Conversation

@Adi-ty

@Adi-ty Adi-ty commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

What this PR does

Fixes the lint/phpstan scaffold. Its config hardcoded src and includes, and PHPStan stops on a listed path that doesn't exist, so composer analyse failed in any project without both. The scaffold now asks for the paths to analyse through a required paths input, so it works on any PHP project: plugins, themes, or Composer packages like rtcamp/wp-primitives.

Stacked on #83: merge that first.

Closes

N/A

Changes

  • Required paths input: comma-separated (--paths='inc/, my-plugin.php') and rendered as a NEON inline list, paths: [inc/, my-plugin.php]. It has no default, so interactive runs prompt for it and --non-interactive runs without it fail with EMISSINGINPUT instead of writing a broken config.
  • Excludes shrink to optional vendor and node_modules: they only matter when paths includes ..
  • Docs: the setup skill and docs/examples.md pass --paths in their lint/phpstan commands.
  • Tests: supplied paths render verbatim; a missing paths is refused.

How I verified

❯ npm run check

Test Suites: 82 passed, 82 total
Tests:       1377 passed, 1377 total
Snapshots:   0 total

PHPStan 2.3.1 on scaffolded projects: --paths='inc/, acme.php' analyses with no errors, and --paths=. reports the project's own errors and nothing from vendor/.

Acceptance criteria

Runtime behavior

  • Fresh scaffold + composer analyse runs with no path errors, whatever the project layout
  • A missing paths input is refused, never guessed

Code quality

  • Lint — zero errors
  • Static analysis — zero errors
  • Tests pass

Housekeeping

  • CHANGELOG.md entry under ## Unreleased

Reviewer notes

  • This replaces the first approach on this PR, which discovered paths through two new engine sources (entry-file:, exists:). Guessing silently skipped PHP outside its list and rendered an empty paths: when nothing matched, so that code is reverted.
  • rtcamp/wp-phpstan stays ^1.0 — the ^2.0 bump follows the wp-phpstan release that ships level 8, as its own change.
  • Constants defined at runtime (define() inside a function) still need the project's own bootstrapFiles.

@Adi-ty
Adi-ty added this pull request to stack #85 October 21, 2026 21:10
@Adi-ty
Adi-ty force-pushed the fix/wp-tooling-phpstan-scaffold-paths branch from 3ded7ac to 722f243 Compare October 22, 2026 07:32
@Adi-ty
Adi-ty marked this pull request as ready for review October 22, 2026 07:33
@Adi-ty
Adi-ty requested review from AnuragVasanwala and a balanced review from Copilot October 22, 2026 07:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Symlinks bypass project containment, and projects without matching paths receive an invalid PHPStan configuration.

2 open issues
What changed in this PR

Updates the PHPStan scaffold to discover existing project paths instead of hardcoding src and includes, using reusable scaffold-engine discovery sources.

Changes:

  • Adds entry-file:<type> and exists:<path> discovery sources and validation support.
  • Conditionally renders PHPStan analysis paths and removes the previous exclusions.
  • Adds discovery and rendering tests, authoring documentation, and a changelog entry.
File Description
node-packages/​wp-tooling/​tests/​scaffolds/​discover-sources.test.js Tests entry-file and existing-path discovery.
node-packages/​wp-tooling/​tests/​scaffolds/​bundled-manifests.test.js Tests generated PHPStan paths for plugins and themes.
node-packages/​wp-tooling/​src/​scaffolds/​validate.js Allows both new discovery sources.
node-packages/​wp-tooling/​src/​scaffolds/​registry.js Implements entry-file and existing-path resolution.
node-packages/​wp-tooling/​scaffolds/​lint/​phpstan/​templates/​phpstan.neon.dist.mustache Renders analysis paths conditionally.
node-packages/​wp-tooling/​scaffolds/​lint/​phpstan/​scaffold.json Declares inputs for conventional PHP paths.
node-packages/​wp-tooling/​docs/​authoring-scaffolds.md Documents the new discovery sources.
node-packages/​wp-tooling/​docs/​ai-orchestration.md Updates engine discovery guarantees and responsibilities.
node-packages/​wp-tooling/​CHANGELOG.md Records discovery additions and the scaffold fix.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 22, 2026 08:57
@Adi-ty Adi-ty changed the title fix(scaffolds): list only existing PHP paths in the lint/phpstan config fix(scaffolds): ask for lint/phpstan paths instead of hardcoding them Oct 22, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Blank-input validation and literal path serialization remain unresolved and can produce unusable PHPStan configurations.

2 open issues
2 resolved since last review

Review effort: Balanced

{
"key": "paths",
"description": "Files and directories holding your own PHP, comma-separated, e.g. `inc/, my-plugin.php`. PHPStan stops on one that doesn't exist.",
"required": true
- src
- includes
# Your own PHP. A path that doesn't exist stops PHPStan.
paths: [{{paths}}]
Copilot AI balanced review requested due to automatic review settings October 22, 2026 09:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Escaping occurs before required-input validation, allowing whitespace-only values to bypass the new check.

2 open issues
1 previously missed issue

In code that hasn't changed since last review

Medium severity Validate required inputs before applying escaping

node-packages/​wp-tooling/​src/​scaffolds/​registry.js:1219

This checks the value after resolveDeclared() has applied its transform. Both setup/pa11y and setup/perf declare a required base_url with json-escape, so an actual tab-only or newline-only input becomes the nonblank text \t or \n. It therefore bypasses this check and renders an unusable URL instead of raising EMISSINGINPUT. Validate required values before escaping, while preserving post-transform enum validation and the resolver's partial-resolution behavior. Add regression cases for tab-only and newline-only values on a transformed required input.

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants