Skip to content

Add PHPStan CI check and pre-push hook, PG-4897 [no_release] - #229

Open
snake14 wants to merge 4 commits into
5.x-devfrom
PG-4897-phpstan
Open

Add PHPStan CI check and pre-push hook, PG-4897 [no_release]#229
snake14 wants to merge 4 commits into
5.x-devfrom
PG-4897-phpstan

Conversation

@snake14

@snake14 snake14 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Description

Enforces the PHPStan static analysis this plugin already had configured: a phpstan.neon existed at level 1 but no CI check or git hook ran it. This adds the same setup used by other Matomo plugins (e.g. plugin-Slack, plugin-LoginLdap): a GitHub Actions check on every pull request, plus an optional pre-push git hook that analyses changed files (enable it with git config core.hooksPath .git-hooks-matomo).

The analysis level is raised from 1 to 5, the highest level the existing code passes (level 6 reports 104 errors). No behaviour changes: the two findings in API.php are a same-shape invariant between two DataTables that the analysis cannot see, the RecordBuilders finding is a compatibility guard for Matomo < 5.2.0-b6 that the declared support range still needs, and the finding in the released Updates/5.1.0.php is ignored via a path-scoped config entry because released update files are immutable history. New files are held to level 9 and modified files to level 5 by the hook, matching the other plugins.

Issue No

PG-4897

Steps to Replicate the Issue

  1. Run PHPStan for this plugin in a Matomo checkout: composer run phpstan -- -c plugins/MarketingCampaignsReporting/phpstan.neon.
  2. Expected: the configured analysis level is enforced somewhere.
  3. Actual: nothing ran it, and the configured level understated what the code supports.

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?

snake14 added 4 commits August 4, 2026 13:48
The level-1 phpstan.neon existed but nothing enforced it; the code
passes level 5 with targeted ignores for two invariants the analysis
cannot see and one finding in an immutable released update file.
Uncommitted local changes were analyzed and could block a push for
files the push doesn't contain. Also corrects the hook's log label.
Pushing another local branch, or several refs at once, analysed the
checked-out branch instead of what was actually pushed.
A plugin cloned outside a Matomo checkout cannot be checked, which is
no reason to block its pushes.
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