From 61f44c59e0368ea47a27a7e497c6aeceb981e424 Mon Sep 17 00:00:00 2001 From: turegjorup Date: Sun, 8 Nov 2026 21:49:09 +0100 Subject: [PATCH 1/4] chore: add PHPStan deprecation rules 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. --- composer.json | 1 + composer.lock | 54 ++++++++++++++++++++++++++++++++++++++++++- phpstan-baseline.neon | 42 +++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 390b0d0..c665983 100644 --- a/composer.json +++ b/composer.json @@ -45,6 +45,7 @@ "pb30/phpstan-composer-analysis": "^1.1", "phpstan/extension-installer": "^1.4", "phpstan/phpstan": "^2.1", + "phpstan/phpstan-deprecation-rules": "^2.0", "phpstan/phpstan-strict-rules": "^2.0", "phpstan/phpstan-symfony": "^2.0", "phpunit/phpunit": "^13", diff --git a/composer.lock b/composer.lock index f60651e..a22f967 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "0b8b0e658b7dce17f6848b7f79e34c48", + "content-hash": "9191b2f4b520ad3382f47d428fa5f251", "packages": [ { "name": "api-platform/core", @@ -8183,6 +8183,58 @@ "time": "2026-10-28T22:38:53+00:00", "published-time": "2026-10-28T22:39:06+00:00" }, + { + "name": "phpstan/phpstan-deprecation-rules", + "version": "2.0.5", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-deprecation-rules.git", + "reference": "67bedd65c24bc72840afc45aed48b1059dd44bec" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/67bedd65c24bc72840afc45aed48b1059dd44bec", + "reference": "67bedd65c24bc72840afc45aed48b1059dd44bec", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0", + "phpstan/phpstan": "^2.1.39" + }, + "require-dev": { + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/phpstan-phpunit": "^2.0", + "phpunit/phpunit": "^9.6", + "shipmonk/name-collision-detector": "^2.1" + }, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "rules.neon" + ] + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan rules for detecting usage of deprecated classes, methods, properties, constants and traits.", + "keywords": [ + "static analysis" + ], + "support": { + "issues": "https://github.com/phpstan/phpstan-deprecation-rules/issues", + "source": "https://github.com/phpstan/phpstan-deprecation-rules/tree/2.0.5" + }, + "time": "2026-07-22T06:50:43+00:00", + "published-time": "2026-07-27T15:18:00+00:00" + }, { "name": "phpstan/phpstan-strict-rules", "version": "2.1.0", diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 28235fd..7495915 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,5 +1,47 @@ parameters: ignoreErrors: + - + message: '#^Attribute class ApiPlatform\\Metadata\\ApiFilter is deprecated\: since API Platform 4\.4, use the \{@see QueryParameter\} attribute instead\. Will be removed in 6\.0\.$#' + identifier: attribute.deprecated + count: 5 + path: src/Api/Dto/DailyOccurrence.php + + - + message: '#^Attribute class ApiPlatform\\Metadata\\ApiFilter is deprecated\: since API Platform 4\.4, use the \{@see QueryParameter\} attribute instead\. Will be removed in 6\.0\.$#' + identifier: attribute.deprecated + count: 5 + path: src/Api/Dto/Event.php + + - + message: '#^Attribute class ApiPlatform\\Metadata\\ApiFilter is deprecated\: since API Platform 4\.4, use the \{@see QueryParameter\} attribute instead\. Will be removed in 6\.0\.$#' + identifier: attribute.deprecated + count: 2 + path: src/Api/Dto/Location.php + + - + message: '#^Attribute class ApiPlatform\\Metadata\\ApiFilter is deprecated\: since API Platform 4\.4, use the \{@see QueryParameter\} attribute instead\. Will be removed in 6\.0\.$#' + identifier: attribute.deprecated + count: 4 + path: src/Api/Dto/Occurrence.php + + - + message: '#^Attribute class ApiPlatform\\Metadata\\ApiFilter is deprecated\: since API Platform 4\.4, use the \{@see QueryParameter\} attribute instead\. Will be removed in 6\.0\.$#' + identifier: attribute.deprecated + count: 2 + path: src/Api/Dto/Organization.php + + - + message: '#^Attribute class ApiPlatform\\Metadata\\ApiFilter is deprecated\: since API Platform 4\.4, use the \{@see QueryParameter\} attribute instead\. Will be removed in 6\.0\.$#' + identifier: attribute.deprecated + count: 1 + path: src/Api/Dto/Tag.php + + - + message: '#^Attribute class ApiPlatform\\Metadata\\ApiFilter is deprecated\: since API Platform 4\.4, use the \{@see QueryParameter\} attribute instead\. Will be removed in 6\.0\.$#' + identifier: attribute.deprecated + count: 1 + path: src/Api/Dto/Vocabulary.php + - message: '#^Offset ''_source'' might not exist on array\|null\.$#' identifier: offsetAccess.notFound From 2dab97c16ae9c9479a2897ea6717a6d0f495d49a Mon Sep 17 00:00:00 2001 From: turegjorup Date: Sun, 8 Nov 2026 21:49:29 +0100 Subject: [PATCH 2/4] docs: add CHANGELOG entry for deprecation rules --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a4c7ab..e76d307 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ See [keep a changelog] for information about writing changes to this log. ## [Unreleased] +- [PR-XX](https://github.com/itk-dev/event-database-api/pull/XX) + Add PHPStan deprecation rules (baseline the API Platform 4.4 `#[ApiFilter]` deprecations) - [PR-77](https://github.com/itk-dev/event-database-api/pull/77) Update Symfony Flex recipes - [PR-76](https://github.com/itk-dev/event-database-api/pull/76) From 1e552ae348104d9598632cb2337804acf3cd77f5 Mon Sep 17 00:00:00 2001 From: turegjorup Date: Sun, 8 Nov 2026 21:50:46 +0100 Subject: [PATCH 3/4] chore: ignore ApiFilter deprecations with a commented rule Use an ignoreErrors rule in phpstan.dist.neon instead of baseline entries, so the reason is documented. --- CHANGELOG.md | 2 +- phpstan-baseline.neon | 42 ------------------------------------------ phpstan.dist.neon | 7 +++++++ 3 files changed, 8 insertions(+), 43 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e76d307..09a7586 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ See [keep a changelog] for information about writing changes to this log. ## [Unreleased] - [PR-XX](https://github.com/itk-dev/event-database-api/pull/XX) - Add PHPStan deprecation rules (baseline the API Platform 4.4 `#[ApiFilter]` deprecations) + Add PHPStan deprecation rules (ignore the API Platform 4.4 `#[ApiFilter]` deprecations) - [PR-77](https://github.com/itk-dev/event-database-api/pull/77) Update Symfony Flex recipes - [PR-76](https://github.com/itk-dev/event-database-api/pull/76) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 7495915..28235fd 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,47 +1,5 @@ parameters: ignoreErrors: - - - message: '#^Attribute class ApiPlatform\\Metadata\\ApiFilter is deprecated\: since API Platform 4\.4, use the \{@see QueryParameter\} attribute instead\. Will be removed in 6\.0\.$#' - identifier: attribute.deprecated - count: 5 - path: src/Api/Dto/DailyOccurrence.php - - - - message: '#^Attribute class ApiPlatform\\Metadata\\ApiFilter is deprecated\: since API Platform 4\.4, use the \{@see QueryParameter\} attribute instead\. Will be removed in 6\.0\.$#' - identifier: attribute.deprecated - count: 5 - path: src/Api/Dto/Event.php - - - - message: '#^Attribute class ApiPlatform\\Metadata\\ApiFilter is deprecated\: since API Platform 4\.4, use the \{@see QueryParameter\} attribute instead\. Will be removed in 6\.0\.$#' - identifier: attribute.deprecated - count: 2 - path: src/Api/Dto/Location.php - - - - message: '#^Attribute class ApiPlatform\\Metadata\\ApiFilter is deprecated\: since API Platform 4\.4, use the \{@see QueryParameter\} attribute instead\. Will be removed in 6\.0\.$#' - identifier: attribute.deprecated - count: 4 - path: src/Api/Dto/Occurrence.php - - - - message: '#^Attribute class ApiPlatform\\Metadata\\ApiFilter is deprecated\: since API Platform 4\.4, use the \{@see QueryParameter\} attribute instead\. Will be removed in 6\.0\.$#' - identifier: attribute.deprecated - count: 2 - path: src/Api/Dto/Organization.php - - - - message: '#^Attribute class ApiPlatform\\Metadata\\ApiFilter is deprecated\: since API Platform 4\.4, use the \{@see QueryParameter\} attribute instead\. Will be removed in 6\.0\.$#' - identifier: attribute.deprecated - count: 1 - path: src/Api/Dto/Tag.php - - - - message: '#^Attribute class ApiPlatform\\Metadata\\ApiFilter is deprecated\: since API Platform 4\.4, use the \{@see QueryParameter\} attribute instead\. Will be removed in 6\.0\.$#' - identifier: attribute.deprecated - count: 1 - path: src/Api/Dto/Vocabulary.php - - message: '#^Offset ''_source'' might not exist on array\|null\.$#' identifier: offsetAccess.notFound diff --git a/phpstan.dist.neon b/phpstan.dist.neon index d48207b..0ec6d37 100644 --- a/phpstan.dist.neon +++ b/phpstan.dist.neon @@ -17,6 +17,13 @@ parameters: - identifier: missingType.iterableValue # The ID properties are set reflectively by API Platform. - '#Property App\\Api\\Dto\\[^\\]+::\$id is unused#' + # 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 DTOs, and AbstractProvider::getFilters(), + # which reads the #[ApiFilter] attributes through api_platform.filter_locator). Remove this rule after the change. + - + identifier: attribute.deprecated + message: '#^Attribute class ApiPlatform\\Metadata\\ApiFilter is deprecated#' + path: src/Api/Dto/* # pb30/phpstan-composer-analysis: report packages used directly but only installed transitively ("shadow # dependencies") and dev packages used in production code. Unused/misplaced checks are off: bundles and # extensions are used through config, not class references, so they would all be false positives. From ac018d63e1649a3bdce700b01696b7e2c012500d Mon Sep 17 00:00:00 2001 From: turegjorup Date: Sun, 8 Nov 2026 21:51:04 +0100 Subject: [PATCH 4/4] docs: set PR number in CHANGELOG entry --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 09a7586..41af545 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ See [keep a changelog] for information about writing changes to this log. ## [Unreleased] -- [PR-XX](https://github.com/itk-dev/event-database-api/pull/XX) +- [PR-78](https://github.com/itk-dev/event-database-api/pull/78) Add PHPStan deprecation rules (ignore the API Platform 4.4 `#[ApiFilter]` deprecations) - [PR-77](https://github.com/itk-dev/event-database-api/pull/77) Update Symfony Flex recipes