Skip to content

Make the toolchain work, and the docs match it - #1

Merged
mralaminahamed merged 2 commits into
mainfrom
chore/working-toolchain-and-docs
Aug 19, 2026
Merged

Make the toolchain work, and the docs match it#1
mralaminahamed merged 2 commits into
mainfrom
chore/working-toolchain-and-docs

Conversation

@mralaminahamed

Copy link
Copy Markdown
Owner

Three of the documented composer scripts did not run, and composer analyze reported errors inherent to stubs rather than defects here.

Broken tooling

phpunit had no configuration; phpcs had no ruleset. composer check chains both, so it failed twice over.

composer analyze had the generated stubs in PHPStan paths, which asks it to check the bodies of declarations that are empty by definitionshould return X but return statement is missing for every one, plus unknown-class errors for whatever WordPress internals upstream touches. PHPStan 2.x classifies several of those as non-ignorable, so neither an ignoreErrors pattern nor a baseline can hold them.

The stubs are scanFiles now — symbols become known without any claim about bodies a stub cannot have. paths covers the hand-written PHP instead.

What replaces it

tests/StubsTest.php asserts the two properties a generated file must hold whatever it contains:

  • it parsesTOKEN_PARSE, so invalid source raises rather than returning a best-effort token list
  • it declares something — a file that is nothing but its header is what a truncated generation looks like

Stub files are discovered by glob, so a repo that grows another one is covered without anyone remembering.

CI

  • ci.ymlcs, analyze, test on push and PR, across PHP 7.4 and 8.3. Nothing ran on a change before.
  • upstream-check.yml (where the plugin is on WordPress.org) — weekly comparison of the latest release against the newest tag here, opening one issue when this package falls behind. Staleness is the failure a stubs package actually has, and it is silent. Both version strings are validated as numeric before reaching an issue body.

Plus CHANGELOG.md, reconstructed from the tags.

The composer scripts this repo documents did not run. `phpunit` had no
configuration, `phpcs` had no ruleset, and `composer check` chains both, so it
failed twice over.

`composer analyze` reported errors that are inherent to stubs rather than
defects here: the generated files sat in PHPStan's `paths`, which asks it to
check the bodies of declarations that are empty by definition. They are
`scanFiles` now -- the symbols become known without any claim about bodies a
stub cannot have -- and `paths` covers the hand-written PHP instead.

tests/StubsTest.php asserts the two properties a generated file must hold
whatever it contains: it parses (TOKEN_PARSE, so invalid source raises rather
than returning a best-effort token list), and it declares something. Those are
the two shapes a failed regeneration takes -- a truncated file, and a file that
is nothing but its header.

Adds CI on push and pull request across PHP 7.4 and 8.3. Nothing ran on a change
before.

Where the upstream plugin is on WordPress.org, adds a weekly check comparing its
latest release against the newest tag here, opening one issue when this package
falls behind. Staleness is the failure a stubs package actually has, and it is
silent: upstream ships a symbol, this package does not, and the only sign of it
appears in somebody else's static analysis. Both version strings are validated as
numeric before either reaches an issue body.

Adds CHANGELOG.md, reconstructed from the tags.
Follow-ups from the first CI run on this branch:

- token_get_all()'s result is asserted rather than discarded; PHPStan reports a
  bare call as having no effect.
- A constants stub is allowed to be empty. Four of these repositories ship one
  that is header-only, and a plugin defining no constants is legitimate output --
  so the declaration check applies to the declaration stubs, where a truncated
  file is unambiguous.
- divi-theme had no cs/analyze/test scripts at all; added, with the phpunit and
  phpcs dev dependencies they need.
- forminator declared php >=7.4 while its stubs use constructor property
  promotion, which 7.4 cannot parse. The floor is >=8.0, and CI now tests what
  the package claims.
@mralaminahamed
mralaminahamed merged commit 939601e into main Aug 19, 2026
2 checks passed
@mralaminahamed
mralaminahamed deleted the chore/working-toolchain-and-docs branch August 19, 2026 04:35
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.

1 participant