Skip to content

fix(types): make PHPStan blocking and fix the tag slug, date builder and sub-query types - #33

Merged
ogorzalka merged 2 commits into
mainfrom
fix/phpstan-blocking
Nov 18, 2026
Merged

ogorzalka merged 2 commits into
mainfrom
fix/phpstan-blocking

Conversation

@ogorzalka

Copy link
Copy Markdown
Member

Fixes the 26 errors PHPStan reports on this package (level 5, no baseline, no ignoreErrors, no @phpstan-ignore) and removes Static analysis from the observed gates of .harness.json: the gate now blocks.

Errors and decisions

  • Real typing defects (1-2). Tag.php: the slugs of tagSlugAnd() / tagSlugIn() and their properties were documented as array<int> in one place and array<string> in another; slugs are strings (the existing test sends ['dev', 'qa']). Now array<string> everywhere.
  • False annotations in DateQueryBuilder (3-6). $after / $before were declared string but every setter stores the array extractFromDate() returns; the return shapes of extractDateDetails() and handleDefault() listed string values and required keys that are int and optional.
  • QueryBuilder (7-8). The by-reference parameter of applyRelation() was too narrow; SubQuery::get() was called but the abstraction did not declare it (the three subclasses implement it): abstract public function get(): array.
  • Traits/Query/SubQuery.php (9-26). One cause repeated for the Comment, Post, Site, Term and User queries: $this->{$field} read a property that not every host class has. The dynamic access is gone: addSubQuery() becomes mergeSubQuery($type, $current, $callback): array and each trait assigns its own property.

Behaviour. No change at run time (types and an internal refactoring; the existing Tag, Date, Meta and Tax tests cover it). addSubQuery() was protected: a subclass outside this package that called it would have to follow; no usage in the other Pollora repositories (searched). Listed in the CHANGELOG.

Checked (re-run by the maintainer, not only by the author): PHPStan 0 error and 0 baseline line; 429 tests on macOS, with 5 random seeds, and on Linux (php:8.4-cli); Pint and Rector (--dry-run) clean; pollora-qa check: Static analysis passes without being observed, with the ratchet, Rector, style and architecture.

@ogorzalka
ogorzalka merged commit bb27592 into main Nov 18, 2026
17 checks passed
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