Skip to content

Run PHPStan at level 5 [ignore_release] - #94

Merged
snake14 merged 2 commits into
6.x-devfrom
enable-phpstan
Sep 14, 2026
Merged

snake14 merged 2 commits into
6.x-devfrom
enable-phpstan

Conversation

@snake14

@snake14 snake14 commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Description

This plugin had no phpstan.neon, so the umbrella skipped the check and it has never been analysed. The configuration matches the one the rest of the fleet uses; level 5 is what the comparably sized plugins already run at, and the plugin is clean at that level.

Six findings, which turned out to be three causes — all fixed in their own commit.

getRegexMatchEntry() and getNumEntriesToCache() are annotated @return string but both return (int)…. That one wrong annotation accounted for three of the six: the two return-type findings, and the int - non-falsy-string on the subtraction in WarmDeviceDetectorCache, which reads $numEntriesToCache from that method.

writeToCache() has taken a single parameter since 0c205c38, but every call site — one in the command and twelve in the tests — still passed a second empty array. PHP discards extra arguments to a userland function, so nothing broke; the calls now match the signature.

CachedEntry::__construct() left $clientHints untyped, so its type was inherited from DeviceDetector::__construct(..., ?ClientHints $clientHints = null). The class actually takes an array of headers and converts it with ClientHints::factory(), and all five call sites pass arrays. Declaring it array states the real contract and resolves both remaining findings.

No version bump or changelog entry: the substance is static-analysis setup.

Issue No

No GitHub issue.

Steps to Replicate the Issue

  1. Note that the umbrella passes skip-phpstan for this plugin because there is no config to run.
  2. Expected result: static analysis runs, as it does for the other migrated plugins.
  3. Actual result: the check is skipped.

Checklist

  • [✔] Tested locally or on demo2/demo3?
  • [NA] New test case added/updated?
  • [NA] Are all newly added texts included via translation?
  • [NA] Are text sanitized properly? (Eg use of v-text v/s v-html for vue)
  • [NA] Version bumped?
  • [✔] I have understood, reviewed, and tested all AI outputs before use
  • [✔] All AI instructions respect security, IP, and privacy rules
  • [NA] Documentation updated?

…ase]

getRegexMatchEntry() and getNumEntriesToCache() are annotated @return string but cast to int; the annotation also made the subtraction in WarmDeviceDetectorCache read as int minus string. writeToCache() has taken one parameter since 0c205c3, yet every call site still passed a second empty array, which PHP discarded. The constructor takes an array of client-hint headers and converts it with ClientHints::factory(), so declaring it array stops the parent signature being inherited as ?ClientHints.
The findings that would have failed it are fixed in the previous commit.
@snake14
snake14 requested a review from a team September 14, 2026 01:58
@snake14
snake14 enabled auto-merge (squash) September 14, 2026 02:30
@snake14
snake14 merged commit da0723e into 6.x-dev Sep 14, 2026
22 of 23 checks passed
@snake14
snake14 deleted the enable-phpstan branch September 14, 2026 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants