Skip to content

chore: pay down PHPStan baseline (34 → 10) - #32

Merged
turegjorup merged 2 commits into
developfrom
chore/phpstan-baseline-paydown
Jul 7, 2026
Merged

chore: pay down PHPStan baseline (34 → 10)#32
turegjorup merged 2 commits into
developfrom
chore/phpstan-baseline-paydown

Conversation

@turegjorup

Copy link
Copy Markdown
Contributor

Follow-up to #31: fix the mechanical strict-rule findings so the PHPStan baseline shrinks from 34 to 10 entries.

Fixed (behaviour-preserving)

  • empty() → explicit comparisons across the six ES filters, AbstractProvider, and ElasticSearchIndex. The filters still skip unset / '' / [] exactly as before (a literal "0" query value is now treated as a real value rather than silently skipped — the only behavioural nuance, and arguably a fix).
  • !$this->propertiesnull === … || [] === … (the booleanNot findings).
  • Short ternary → explicit in the paginator's getLastPage().
  • in_array(…, true) strict flag in FixturesLoadCommand and FixtureLoader.
  • FixtureLoader: guard file_get_contents()/json_decode(), 1 === preg_match(...), and narrow the client response with /** @var Elasticsearch */ (same pattern ElasticSearchIndex already uses).
  • ApiUser::$username annotated non-empty-string; paginator count() wrapped in max(0, …).

Left in the baseline (10 — genuine typing work for a separate pass)

  • offsetAccess.notFound$response['_source'] on array|null in the 5 providers (real ES-response null-safety).
  • method.childReturnTypeprovide() return-type covariance vs ProviderInterface (3 providers).
  • classConstant.nameType — dynamic DateLimit::{…} fetch in DateRangeFilter.
  • argument.type — console addArgument()suggestedValues closure signature.

Verification

phpstan analyse (level 8 + strict) → No errors (baseline: 10) · php-cs-fixer check → clean · bin/phpunit19 tests, 44 assertions, OK.

Fix the mechanical strict-rule findings so the baseline drops from 34 to 10
entries; the remaining 10 are genuine typing work left for a follow-up
(offset-access null-safety on ES responses, provider return-type covariance,
one dynamic enum-constant fetch, and a console suggestedValues closure).
- Replace banned empty()/short-ternary/negated-array constructs with explicit
comparisons (behaviour-preserving; filters skip unset/''/[] as before).
- Pass the strict flag to in_array().
- Narrow the Elasticsearch client response with @var (as ElasticSearchIndex
already does) and guard file_get_contents()/json_decode() in the fixture
loader.
- Annotate ApiUser::$username as non-empty-string; make the paginator count
non-negative.
phpstan (level 8 + strict), php-cs-fixer, and the API test suite (19 tests)
all pass.
@github-actions

Copy link
Copy Markdown

No changes detected in API specification

@turegjorupturegjorup self-assigned this Jul 7, 2026
@turegjorup
turegjorup merged commit da27308 into developJul 7, 2026
12 checks passed
@turegjorup
turegjorup deleted the chore/phpstan-baseline-paydown branch July 7, 2026 12:57
Sign up for freeto 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

@turegjorup