Skip to content

Fix stale/inaccurate PHPDoc in core/ (Auth, Cache, Columns, Common, Concurrency, Config)#24739

Open
sgiehl wants to merge 10 commits into
5.x-devfrom
fix-comments-5
Open

Fix stale/inaccurate PHPDoc in core/ (Auth, Cache, Columns, Common, Concurrency, Config)#24739
sgiehl wants to merge 10 commits into
5.x-devfrom
fix-comments-5

Conversation

@sgiehl

@sgiehl sgiehl commented Jul 1, 2026

Copy link
Copy Markdown
Member

Summary

Part of an ongoing pass to fix PHPDoc comments across core/ and plugins/ (excluding @api-tagged classes/methods and API.php classes) that no longer match the actual code behavior, or whose @param/@return annotations are wrong/incomplete.

This PR covers:

  • core/BaseFactory.php: factory() was documented as always returning a \Piwik\DataTable\Renderer, but this is a generic base class meant to be extended by many different factory types.
  • core/Cache.php: added a missing param type on buildBackend().
  • core/CliMulti.php / core/CliMulti/Process.php: fixed an untyped param, a misordered @param $limit int ... tag (type after the variable name), and added a missing type.
  • core/Columns/DimensionsProvider.php: added a missing param type on factory().
  • core/Columns/Updater.php: added a missing @param on getUpdatesForDimension().
  • core/Common.php: getProcessId() can return false (from getmypid()) but was documented as int|null (a case that never occurs); sanitizeInputValue()/sanitizeLineBreaks() both explicitly handle a null input internally but were documented as accepting only string; added two missing param types.
  • core/Concurrency/LockBackend.php: the entire interface was fully untyped (bare @param $x, @return mixed) despite the implementation and callers consistently using string/int/bool.
  • core/Config.php: getDatatableRowLimits() takes no parameters, but its docblock still documented a $general param that no longer exists.
  • core/Config/Cache.php: the class docblock said "Exception thrown when the config file doesn't exist" — copy-pasted from the neighboring ConfigNotFoundException class, but this class is a file cache backend, not an exception.

One phpstan-baseline.neon entry was removed because the Common.php fix resolved a real, previously-suppressed PHPStan finding.

Many files in this range were skipped because they are @api-tagged (whole class or whole interface): core/Auth.php, core/Auth/Password.php, core/Auth/PasswordStrength.php, core/AuthResult.php, core/Category/Subcategory.php, core/Columns/ComputedMetricFactory.php, core/Columns/Dimension.php, core/Columns/DimensionMetricFactory.php, core/Columns/DimensionSegmentFactory.php, core/Columns/Discriminator.php, core/Columns/Join.php, core/Columns/Join/ActionNameJoin.php, core/Columns/Join/GoalNameJoin.php, core/Columns/Join/SiteNameJoin.php, core/Columns/MetricsList.php. Many other files needed no changes (already accurate/well-documented, or had no docblocks to begin with).

Checklist

  • [✔] I have understood, reviewed, and tested all AI outputs before use
  • [✔] All AI instructions respect security, IP, and privacy rules
sgiehl added 9 commits July 1, 2026 18:30
BaseFactory is a generic base class meant to be extended by many
different factory types (per its own class docblock), but its
factory() method was documented as always returning a
\Piwik\DataTable\Renderer, which only made sense for one specific
subclass's usage.
setAcceptInvalidSSLCertificate()'s param had no type, and
setConcurrentProcessesLimit()'s @param put the type after the variable
name instead of before it. Added a type to Process::writePidFileContent()'s
$content param.
getProcessId() can return false (from getmypid()) but was documented
as returning int|null, a case that never actually occurs.
sanitizeInputValue()/sanitizeLineBreaks() both explicitly handle a
null input internally but were documented as accepting only string;
widening resolves a previously-suppressed PHPStan finding. Added
missing param types on convertUserIdToVisitorIdBin() and
checkValidLanguagesIsSet().
Every method was fully untyped (@param with no type, @return mixed),
even though the single implementation (MySqlLockBackend) and callers
in Lock consistently use string keys/values, int TTLs, and bool/string
return values.
The method takes no parameters, but its docblock still documented a
$general param that no longer exists (the value is now read internally
via $this->General). Also fixed the vague "mixed" return type to array.
This class is a file-based cache backend, not an exception; the
docblock was copy-pasted from the neighboring ConfigNotFoundException
class.
@sgiehl sgiehl added this to the 5.12.0 milestone Jul 1, 2026
@sgiehl sgiehl added Technical debt Issues the will help to reduce technical debt not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. labels Jul 1, 2026
@sgiehl sgiehl requested a review from a team July 1, 2026 16:41
CI caught that widening this to `object` made PHPStan blind to a
known, already-baselined type issue in ScheduledReports.php (a call to
a Renderer-specific method), causing an "ignored error not matched"
failure. BaseFactory has three subclasses (ReportRenderer,
DataTable\Renderer, ImageGraph\StaticGraph) with different concrete
return types that can't be expressed with a single annotation here, so
restore the original, deliberately-tolerated `\Piwik\DataTable\Renderer`
type rather than making the return type unusable for type-checking.
@sgiehl sgiehl marked this pull request as ready for review July 1, 2026 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. Technical debt Issues the will help to reduce technical debt

1 participant