Skip to content

Drop a null coalesce phpstan proved unreachable - #183

Merged
dave-green-uk merged 2 commits into
mainfrom
fix/phpstan-get-plugin-data
Jul 27, 2026
Merged

Drop a null coalesce phpstan proved unreachable#183
dave-green-uk merged 2 commits into
mainfrom
fix/phpstan-get-plugin-data

Conversation

@dave-green-uk

Copy link
Copy Markdown
Contributor

Pulled out of #181 at @d4mation's request — it is unrelated to that feature and was only in there to get CI green.

What

Features/Types/Plugin.php returned $plugin_data['Version'] ?? null. get_plugin_data() fills every header key, defaulting to an empty string, so the Version index is always set and the coalesce never applied. Newer WordPress stubs describe that, so phpstan now reports it as unreachable.

Behaviour is unchanged. The is_installed() guard above still covers the null return the docblock promises.

Why it started failing now

composer.lock is untracked and .github/workflows/static-analysis.yml resolves dependency-versions: highest, with loose constraints (phpstan/phpstan: ^2, szepeviktor/phpstan-wordpress: >=1.0). Every run therefore picks up the newest matching releases, and a stub release surfaced this latent finding on pull requests that never touched the file.

This is not specific to any one branch — it fails on any PR until fixed, which is why @d4mation hit it while preparing #180 too.

Worth a separate ticket for the underlying cause: while dependencies float like this, an upstream release can redden an unrelated PR at any time. Tracking the lock, or pinning the analysis dependencies, would stop it.

Base

Targeting bucket/activation-flow-api rather than main, since release/1.5.1 (#180) is mid-merge.

Unrelated to this branch's feature work, but it fails static analysis on
every pull request so it blocks this one.

get_plugin_data() fills every header key, defaulting to an empty string,
so the Version index is always set. Newer WordPress stubs describe that,
which makes the coalesce dead code. Behaviour is unchanged; the guard on
is_installed() above still covers the null return the docblock promises.

The underlying cause is that composer.lock is untracked and the analysis
workflow resolves dependency-versions: highest, so any stub release can
surface a latent finding like this on an unrelated pull request.

Claude-Session: https://claude.ai/code/session_019G9uUzMJSWzoFatSxvzGoW
d4mation
d4mation previously approved these changes Jul 27, 2026

@d4mation d4mation left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This particular PR I think could be merged directly to main now that #180 is out :)

Any upcoming release(s) would include this change and get QA'd accordingly.

The issue we had before with #181 merging to main was because it was a larger change and could conflict with #180. But this change, now that the already QA'd #180 release is merged, won't impact anything going to main.

@dave-green-uk
dave-green-uk changed the base branch from bucket/activation-flow-api to main July 27, 2026 15:47
@dave-green-uk
dave-green-uk dismissed d4mation’s stale review July 27, 2026 15:47

The base branch was changed.

@dave-green-uk
dave-green-uk merged commit 9092c04 into main Jul 27, 2026
24 checks passed
@dave-green-uk
dave-green-uk deleted the fix/phpstan-get-plugin-data branch July 27, 2026 15:51
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