From 3de75a113ceb79f6ef65bffa0c539ad7c7aae612 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Wed, 17 Dec 2025 00:06:24 +0100 Subject: [PATCH] Enforce PHP #[Deprecated] with PHPStan Taking advantage of https://github.com/FreshRSS/FreshRSS/pull/8325 --- composer.json | 1 + composer.lock | 49 +++++++++++++++++++++++++++++++- phpstan.dist.neon | 1 + xExtension-Captcha/extension.php | 3 +- xExtension-Captcha/metadata.json | 2 +- 5 files changed, 53 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 78b2f1e..b13c587 100644 --- a/composer.json +++ b/composer.json @@ -50,6 +50,7 @@ "ext-tokenizer": "*", "ext-xmlwriter": "*", "phpstan/phpstan": "^2", + "phpstan/phpstan-deprecation-rules": "^2", "phpstan/phpstan-strict-rules": "^2", "squizlabs/php_codesniffer": "^4" }, diff --git a/composer.lock b/composer.lock index 3dd8ee6..2294668 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": "8a6dcc1afea2037b32149736705f192e", + "content-hash": "d60832133308ce3cd2a2b8aa700716f3", "packages": [], "packages-dev": [ { @@ -60,6 +60,53 @@ ], "time": "2025-11-11T15:18:17+00:00" }, + { + "name": "phpstan/phpstan-deprecation-rules", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-deprecation-rules.git", + "reference": "468e02c9176891cc901143da118f09dc9505fc2f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/468e02c9176891cc901143da118f09dc9505fc2f", + "reference": "468e02c9176891cc901143da118f09dc9505fc2f", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0", + "phpstan/phpstan": "^2.1.15" + }, + "require-dev": { + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/phpstan-phpunit": "^2.0", + "phpunit/phpunit": "^9.6" + }, + "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.", + "support": { + "issues": "https://github.com/phpstan/phpstan-deprecation-rules/issues", + "source": "https://github.com/phpstan/phpstan-deprecation-rules/tree/2.0.3" + }, + "time": "2025-05-14T10:56:57+00:00" + }, { "name": "phpstan/phpstan-strict-rules", "version": "2.0.7", diff --git a/phpstan.dist.neon b/phpstan.dist.neon index 65fcff9..a7c0c4f 100644 --- a/phpstan.dist.neon +++ b/phpstan.dist.neon @@ -43,4 +43,5 @@ parameters: ignoreErrors: - '#Only booleans are allowed in (a negated boolean|a ternary operator condition|an elseif condition|an if condition|&&|\|\|), (bool|false|int(<[0-9, max]+>)?|true|null|\|)+ given.*#' includes: + - vendor/phpstan/phpstan-deprecation-rules/rules.neon - vendor/phpstan/phpstan-strict-rules/rules.neon diff --git a/xExtension-Captcha/extension.php b/xExtension-Captcha/extension.php index e29f0b4..32635c5 100644 --- a/xExtension-Captcha/extension.php +++ b/xExtension-Captcha/extension.php @@ -35,7 +35,8 @@ public static function isProtectedPage(): bool { } public static function getClientIp(): string { - $ip = checkTrustedIP() ? ($_SERVER['HTTP_X_REAL_IP'] ?? connectionRemoteAddress()) : connectionRemoteAddress(); + $ip = FreshRSS_http_Util::checkTrustedIP() ? + ($_SERVER['HTTP_X_REAL_IP'] ?? Minz_Request::connectionRemoteAddress()) : Minz_Request::connectionRemoteAddress(); return is_string($ip) ? $ip : ''; } diff --git a/xExtension-Captcha/metadata.json b/xExtension-Captcha/metadata.json index 9612e46..ac10300 100644 --- a/xExtension-Captcha/metadata.json +++ b/xExtension-Captcha/metadata.json @@ -2,7 +2,7 @@ "name": "Form Captcha", "author": "Inverle", "description": "Protect register/login forms with captcha", - "version": "1.0.2", + "version": "1.0.3", "entrypoint": "Captcha", "type": "system" }