Skip to content

chore: add PHPStan deprecation rules - #78

Merged
turegjorup merged 4 commits into
developfrom
feature/deprecation-rules
Nov 8, 2026
Merged

turegjorup merged 4 commits into
developfrom
feature/deprecation-rules

Conversation

@turegjorup

Copy link
Copy Markdown
Contributor

Add PHPStan deprecation rules, and ignore the API Platform 4.4 #[ApiFilter] deprecations with a commented rule. This is step 8 of the quarterly update.

Changes

  • Add phpstan/phpstan-deprecation-rules (^2.0) to require-dev.
  • Add an ignoreErrors rule with a comment to phpstan.dist.neon. It ignores attribute.deprecated for ApiPlatform\Metadata\ApiFilter in src/Api/Dto/* only (20 findings in 7 DTOs).
  • phpstan-baseline.neon does not change.

Why

The tests find only deprecations that occur at runtime. A class with only a @deprecated docblock does not trigger a deprecation. The deprecation rules let PHPStan find these, and CI now fails on new deprecations.

PHPStan finds only the #[ApiFilter] deprecation. API Platform 4.4 deprecates #[ApiFilter] and replaces it with #[QueryParameter]. #[ApiFilter] is removed in API Platform 6.0. The change needs application code changes: the 7 DTOs, and AbstractProvider::getFilters(), which reads the #[ApiFilter] attributes through api_platform.filter_locator. The quarterly update includes only deprecations that Rector fixes or that are easy.

The ignore rule is in phpstan.dist.neon and not in the baseline, so the comment explains the reason and tells when to remove the rule. The rule matches only the ApiFilter message in src/Api/Dto/*, so PHPStan still reports all other deprecations.

bin/console debug:container --deprecations shows the same 20 deprecations at container compile time.

Checks before the release

  • composer audit: no advisories.
  • composer outdated --direct --minor-only: only versions that are still in the cooldown remain (api-platform/core 4.4.7, friendsofphp/php-cs-fixer 3.95.29, phpstan/phpstan 2.3.5, phpstan/phpstan-strict-rules 2.1.1, rector/rector 2.8.4).
  • composer recipes --outdated: no outdated recipes.
  • PHPStan: no errors. Rector dry-run: no changes. composer normalize: no changes.
  • PHPUnit with coverage on PHP 8.5.12, as in CI: all tests pass.

Add phpstan/phpstan-deprecation-rules. Put the 20 #[ApiFilter] deprecations (API Platform 4.4) in the baseline, because the change to #[QueryParameter] needs application code changes. CI now finds new deprecations.
Use an ignoreErrors rule in phpstan.dist.neon instead of baseline entries, so the reason is documented.
@turegjorup
turegjorup merged commit eb1811e into develop Nov 8, 2026
12 checks passed
@turegjorup
turegjorup deleted the feature/deprecation-rules branch November 8, 2026 20:51
@turegjorup turegjorup mentioned this pull request Nov 8, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.39%. Comparing base (7136c17) to head (ac018d6).
⚠️ Report is 29 commits behind head on develop.

Additional details and impacted files
@@            Coverage Diff             @@
##             develop      #78   +/-   ##
==========================================
  Coverage      74.39%   74.39%           
  Complexity       264      264           
==========================================
  Files             30       30           
  Lines            738      738           
==========================================
  Hits             549      549           
  Misses           189      189           
Flag Coverage Δ
unittests 74.39% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants