From cc6bf0d1e6e19bdbd0140d9e72383494c0685b6d Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 7 Apr 2024 17:06:35 +0200 Subject: [PATCH] New developer command to test all third-party extensions * `composer run-script phpstan-third-party` * Rename the directory for generate.php to `third-party` instead of `tmp` * Take advantage of PHPStan checkMissingOverrideMethodAttribute https://phpstan.org/config-reference#checkmissingoverridemethodattribute * Detected and fixed bug in URL of https://github.com/tunbridgep/freshrss-invidious --- .eslintignore | 1 + .gitignore | 1 + .jshintignore | 1 + .markdownlintignore | 1 + .stylelintignore | 1 + .typos.toml | 1 + README.md | 11 +++ composer.json | 7 +- composer.lock | 81 ++++++++++++------- extensions.json | 11 +++ generate.php | 3 +- phpstan-next.neon | 10 +++ phpstan-third-party.neon | 24 ++++++ phpstan.neon | 4 +- repositories.json | 2 +- tests/phpstan-next.txt | 7 -- xExtension-ColorfulList/extension.php | 3 +- xExtension-ColorfulList/metadata.json | 2 +- xExtension-CustomCSS/extension.php | 4 +- xExtension-CustomCSS/metadata.json | 2 +- xExtension-CustomJS/extension.php | 4 +- xExtension-CustomJS/metadata.json | 2 +- xExtension-ImageProxy/extension.php | 2 + xExtension-ImageProxy/metadata.json | 2 +- .../Controllers/quickCollapseController.php | 3 +- xExtension-QuickCollapse/Models/View.php | 2 +- xExtension-QuickCollapse/extension.php | 3 +- xExtension-QuickCollapse/metadata.json | 2 +- xExtension-ReadingTime/extension.php | 3 +- xExtension-ReadingTime/metadata.json | 2 +- .../Controllers/shareByEmailController.php | 9 ++- xExtension-ShareByEmail/Models/View.php | 2 +- xExtension-ShareByEmail/extension.php | 3 +- xExtension-ShareByEmail/mailers/Share.php | 4 +- xExtension-ShareByEmail/metadata.json | 2 +- xExtension-StickyFeeds/extension.php | 3 +- xExtension-StickyFeeds/metadata.json | 2 +- xExtension-TTRSS_API/extension.php | 10 ++- xExtension-TTRSS_API/ttrss.php | 29 +++---- xExtension-TitleWrap/extension.php | 3 +- xExtension-TitleWrap/metadata.json | 2 +- xExtension-YouTube/extension.php | 14 +--- xExtension-YouTube/metadata.json | 2 +- xExtension-showFeedID/extension.php | 3 +- xExtension-showFeedID/metadata.json | 2 +- 45 files changed, 192 insertions(+), 100 deletions(-) create mode 100644 phpstan-next.neon create mode 100644 phpstan-third-party.neon delete mode 100644 tests/phpstan-next.txt diff --git a/.eslintignore b/.eslintignore index e25a32a..5d9bd5a 100644 --- a/.eslintignore +++ b/.eslintignore @@ -2,5 +2,6 @@ *.min.js node_modules/ symbolic/ +third-party/ tmp/ vendor/ diff --git a/.gitignore b/.gitignore index ba24d9d..239c9a7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,6 @@ bin/ node_modules/ symbolic/ +third-party/ tmp/ vendor/ diff --git a/.jshintignore b/.jshintignore index 81fdc48..686db07 100644 --- a/.jshintignore +++ b/.jshintignore @@ -1,5 +1,6 @@ .git/ node_modules/ symbolic/ +third-party/ tmp/ vendor/ diff --git a/.markdownlintignore b/.markdownlintignore index 81fdc48..686db07 100644 --- a/.markdownlintignore +++ b/.markdownlintignore @@ -1,5 +1,6 @@ .git/ node_modules/ symbolic/ +third-party/ tmp/ vendor/ diff --git a/.stylelintignore b/.stylelintignore index 81fdc48..686db07 100644 --- a/.stylelintignore +++ b/.stylelintignore @@ -1,5 +1,6 @@ .git/ node_modules/ symbolic/ +third-party/ tmp/ vendor/ diff --git a/.typos.toml b/.typos.toml index 452d6a9..5a2e687 100644 --- a/.typos.toml +++ b/.typos.toml @@ -17,6 +17,7 @@ extend-exclude = [ "bin/", "node_modules/", "symbolic/", + "third-party/", "tmp/", "vendor/", "xExtension-ReadingTime/README.md" diff --git a/README.md b/README.md index 88e3338..250b192 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,17 @@ To install an extension, download [the extension archive](https://github.com/Fre Then, upload the specific extension(s) you want on your server. Extensions must be in the `./extensions` directory of your FreshRSS installation. +## Commands for developers + +```sh +# Test this repository and its extensions +make test-all + +# Test compatibility between `../FreshRSS/` core and all known extensions from `./repositories.json` +./generate.php +composer run-script phpstan-third-party +``` + ## Third-party extensions There are some FreshRSS extensions out there, developed by community members: diff --git a/composer.json b/composer.json index 9122289..0c5d91a 100644 --- a/composer.json +++ b/composer.json @@ -45,13 +45,13 @@ "ext-pdo_pgsql": "*" }, "require-dev": { - "php": ">=8.0", + "php": ">=7.4", "ext-phar": "*", "ext-tokenizer": "*", "ext-xmlwriter": "*", "phpstan/phpstan": "^1.10", "phpstan/phpstan-strict-rules": "^1.5", - "squizlabs/php_codesniffer": "^3.7" + "squizlabs/php_codesniffer": "^3.9" }, "scripts": { "php-lint": "find . -type d -name 'vendor' -prune -o -name '*.php' -print0 | xargs -0 -n1 -P4 php -l 1>/dev/null", @@ -59,7 +59,8 @@ "phpcs": "phpcs . -s", "phpcbf": "phpcbf . -p -s", "phpstan": "phpstan analyse --memory-limit 512M .", - "phpstan-next": "phpstan analyse --level 9 --memory-limit 512M $(find . -type d -name 'vendor' -prune -o -name '*.php' -o -name '*.phtml' | grep -Fxvf ./tests/phpstan-next.txt | sort | paste -s -)", + "phpstan-next": "phpstan analyse --memory-limit 512M -c phpstan-next.neon .", + "phpstan-third-party": "phpstan analyse --memory-limit 512M -c phpstan-third-party.neon .", "test": [ "@php-lint", "@phtml-lint", diff --git a/composer.lock b/composer.lock index 269ce71..4a2e5eb 100644 --- a/composer.lock +++ b/composer.lock @@ -4,21 +4,21 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2c89b2e0c08f09d94faa394270fc16a9", + "content-hash": "bf0d2d1a05ed08841ca6bd3e7ec96b74", "packages": [], "packages-dev": [ { "name": "phpstan/phpstan", - "version": "1.10.44", + "version": "1.10.66", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "bf84367c53a23f759513985c54ffe0d0c249825b" + "reference": "94779c987e4ebd620025d9e5fdd23323903950bd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/bf84367c53a23f759513985c54ffe0d0c249825b", - "reference": "bf84367c53a23f759513985c54ffe0d0c249825b", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/94779c987e4ebd620025d9e5fdd23323903950bd", + "reference": "94779c987e4ebd620025d9e5fdd23323903950bd", "shasum": "" }, "require": { @@ -67,25 +67,25 @@ "type": "tidelift" } ], - "time": "2023-11-21T16:30:46+00:00" + "time": "2024-03-28T16:17:31+00:00" }, { "name": "phpstan/phpstan-strict-rules", - "version": "1.5.2", + "version": "1.5.3", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan-strict-rules.git", - "reference": "7a50e9662ee9f3942e4aaaf3d603653f60282542" + "reference": "568210bd301f94a0d4b1e5a0808c374c1b9cf11b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/7a50e9662ee9f3942e4aaaf3d603653f60282542", - "reference": "7a50e9662ee9f3942e4aaaf3d603653f60282542", + "url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/568210bd301f94a0d4b1e5a0808c374c1b9cf11b", + "reference": "568210bd301f94a0d4b1e5a0808c374c1b9cf11b", "shasum": "" }, "require": { "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.10.34" + "phpstan/phpstan": "^1.10.60" }, "require-dev": { "nikic/php-parser": "^4.13.0", @@ -114,22 +114,22 @@ "description": "Extra strict and opinionated rules for PHPStan", "support": { "issues": "https://github.com/phpstan/phpstan-strict-rules/issues", - "source": "https://github.com/phpstan/phpstan-strict-rules/tree/1.5.2" + "source": "https://github.com/phpstan/phpstan-strict-rules/tree/1.5.3" }, - "time": "2023-10-30T14:35:06+00:00" + "time": "2024-04-06T07:43:25+00:00" }, { "name": "squizlabs/php_codesniffer", - "version": "3.7.2", + "version": "3.9.1", "source": { "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879" + "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", + "reference": "267a4405fff1d9c847134db3a3c92f1ab7f77909" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ed8e00df0a83aa96acf703f8c2979ff33341f879", - "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/267a4405fff1d9c847134db3a3c92f1ab7f77909", + "reference": "267a4405fff1d9c847134db3a3c92f1ab7f77909", "shasum": "" }, "require": { @@ -139,11 +139,11 @@ "php": ">=5.4.0" }, "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" }, "bin": [ - "bin/phpcs", - "bin/phpcbf" + "bin/phpcbf", + "bin/phpcs" ], "type": "library", "extra": { @@ -158,22 +158,45 @@ "authors": [ { "name": "Greg Sherwood", - "role": "lead" + "role": "Former lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "Current lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors" } ], "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer", "keywords": [ "phpcs", "standards", "static analysis" ], "support": { - "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", - "source": "https://github.com/squizlabs/PHP_CodeSniffer", - "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + "issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues", + "security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy", + "source": "https://github.com/PHPCSStandards/PHP_CodeSniffer", + "wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki" }, - "time": "2023-02-22T23:07:41+00:00" + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + } + ], + "time": "2024-03-31T21:03:09+00:00" } ], "aliases": [], @@ -205,10 +228,10 @@ "ext-zlib": "*" }, "platform-dev": { - "php": ">=8.0", + "php": ">=7.4", "ext-phar": "*", "ext-tokenizer": "*", "ext-xmlwriter": "*" }, - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.3.0" } diff --git a/extensions.json b/extensions.json index 892c3f8..ef40d1f 100644 --- a/extensions.json +++ b/extensions.json @@ -221,6 +221,17 @@ "method": "git", "directory": "xExtension-Invidious" }, + { + "name": "Invidious Video Feed", + "author": "Paul Tunbridge (forked from Korbak and Kevin Papst)", + "description": "Embed YouTube feeds inside article content, but with Invidious.", + "version": "1.1", + "entrypoint": "Invidious", + "type": "user", + "url": "https://github.com/tunbridgep/freshrss-invidious", + "method": "git", + "directory": "xExtension-Invidious" + }, { "name": "Kagi Summarizer", "author": "Rudis Muiznieks", diff --git a/generate.php b/generate.php index 1891044..5796b27 100755 --- a/generate.php +++ b/generate.php @@ -6,11 +6,12 @@ // ------------------- // const VERSION = 0.1; const TYPE_GIT = 'git'; -$tempFolder = './tmp'; +$tempFolder = './third-party/'; $extensions = []; $gitRepositories = []; if (file_exists($tempFolder)) { + // TODO: Improve by keeping git copy if possible (e.g. fetch + reset) exec("rm -rf -- {$tempFolder}"); } diff --git a/phpstan-next.neon b/phpstan-next.neon new file mode 100644 index 0000000..5ddddd0 --- /dev/null +++ b/phpstan-next.neon @@ -0,0 +1,10 @@ +includes: + - phpstan.neon + +parameters: + level: 9 + excludePaths: + analyse: + - xExtension-ImageProxy/configure.phtml + - xExtension-ImageProxy/extension.php + - xExtension-TTRSS_API/ttrss.php diff --git a/phpstan-third-party.neon b/phpstan-third-party.neon new file mode 100644 index 0000000..6d6168c --- /dev/null +++ b/phpstan-third-party.neon @@ -0,0 +1,24 @@ +parameters: + level: 0 + treatPhpDocTypesAsCertain: false + fileExtensions: + - php + - phtml + paths: + - ../FreshRSS + - third-party/ + excludePaths: + analyse: + - ../FreshRSS + - third-party/*/vendor/* + analyseAndScan: + - .git/ + - node_modules/ + - symbolic/ + - third-party/*/tests/* + - tmp/ + - vendor/ + - xExtension-* + dynamicConstantNames: + - TYPE_GIT + reportMaybesInPropertyPhpDocTypes: false diff --git a/phpstan.neon b/phpstan.neon index 8cac860..02a5f8e 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,6 +1,7 @@ parameters: # TODO: Increase rule-level https://phpstan.org/user-guide/rule-levels level: 1 + phpVersion: 80399 # TODO: Remove line when moving composer.json to PHP 8+ treatPhpDocTypesAsCertain: false fileExtensions: - php @@ -16,10 +17,11 @@ parameters: - .git/ - node_modules/ - symbolic/ + - third-party/ - tmp/ - - xExtension-TTRSS_API/ dynamicConstantNames: - TYPE_GIT + checkMissingOverrideMethodAttribute: true reportMaybesInPropertyPhpDocTypes: false strictRules: allRules: false diff --git a/repositories.json b/repositories.json index faccb12..496894f 100644 --- a/repositories.json +++ b/repositories.json @@ -44,7 +44,7 @@ "url": "https://github.com/babico/xExtension-TwitchChannel2RssFeed", "type": "git" }, { - "url": "thttps://github.com/tunbridgep/freshrss-invidious", + "url": "https://github.com/tunbridgep/freshrss-invidious", "type": "git" }, { "url": "https://github.com/javerous/freshrss-greader-redate", diff --git a/tests/phpstan-next.txt b/tests/phpstan-next.txt deleted file mode 100644 index 161cef4..0000000 --- a/tests/phpstan-next.txt +++ /dev/null @@ -1,7 +0,0 @@ -# List of files, which are not yet passing PHPStan level 9 https://phpstan.org/user-guide/rule-levels -# Used for automated tests to avoid regressions in files already passing that level. -# Can be regenerated with something like: -# find . -type d -name 'vendor' -prune -o -name '*.php' -exec sh -c 'vendor/bin/phpstan analyse --level 9 --memory-limit 512M {} >/dev/null 2>/dev/null || echo {}' \; - -./xExtension-ImageProxy/configure.phtml -./xExtension-ImageProxy/extension.php diff --git a/xExtension-ColorfulList/extension.php b/xExtension-ColorfulList/extension.php index b1814d5..616dd1b 100644 --- a/xExtension-ColorfulList/extension.php +++ b/xExtension-ColorfulList/extension.php @@ -2,8 +2,9 @@ declare(strict_types=1); -class ColorfulListExtension extends Minz_Extension +final class ColorfulListExtension extends Minz_Extension { + #[Override] public function init(): void { Minz_View::appendScript($this->getFileUrl('script.js', 'js')); } diff --git a/xExtension-ColorfulList/metadata.json b/xExtension-ColorfulList/metadata.json index 945d2f5..01668cc 100644 --- a/xExtension-ColorfulList/metadata.json +++ b/xExtension-ColorfulList/metadata.json @@ -2,7 +2,7 @@ "name": "Colorful List", "author": "Claud Xiao", "description": "Colorful Entry Title based on RSS source", - "version": 0.3, + "version": "0.3.1", "entrypoint": "ColorfulList", "type": "user" } diff --git a/xExtension-CustomCSS/extension.php b/xExtension-CustomCSS/extension.php index b0df7f1..bdfe7a5 100644 --- a/xExtension-CustomCSS/extension.php +++ b/xExtension-CustomCSS/extension.php @@ -2,10 +2,11 @@ declare(strict_types=1); -class CustomCSSExtension extends Minz_Extension { +final class CustomCSSExtension extends Minz_Extension { public string $css_rules; public string $permission_problem = ''; + #[Override] public function init(): void { $this->registerTranslates(); @@ -18,6 +19,7 @@ public function init(): void { } } + #[Override] public function handleConfigureAction(): void { $this->registerTranslates(); diff --git a/xExtension-CustomCSS/metadata.json b/xExtension-CustomCSS/metadata.json index b4a45be..0646334 100644 --- a/xExtension-CustomCSS/metadata.json +++ b/xExtension-CustomCSS/metadata.json @@ -2,7 +2,7 @@ "name": "Custom CSS", "author": "Marien Fressinaud", "description": "Give possibility to overwrite the CSS with a user-specific rules.", - "version": "0.5", + "version": "0.5.1", "entrypoint": "CustomCSS", "type": "user" } diff --git a/xExtension-CustomJS/extension.php b/xExtension-CustomJS/extension.php index 6edbf38..a03d75b 100644 --- a/xExtension-CustomJS/extension.php +++ b/xExtension-CustomJS/extension.php @@ -2,10 +2,11 @@ declare(strict_types=1); -class CustomJSExtension extends Minz_Extension { +final class CustomJSExtension extends Minz_Extension { public string $js_rules; public string $permission_problem = ''; + #[Override] public function init(): void { $this->registerTranslates(); @@ -18,6 +19,7 @@ public function init(): void { } } + #[Override] public function handleConfigureAction(): void { $this->registerTranslates(); diff --git a/xExtension-CustomJS/metadata.json b/xExtension-CustomJS/metadata.json index 594cec5..c21e77e 100644 --- a/xExtension-CustomJS/metadata.json +++ b/xExtension-CustomJS/metadata.json @@ -2,7 +2,7 @@ "name": "Custom JS", "author": "Frans de Jonge", "description": "Apply custom JS.", - "version": "0.5", + "version": "0.5.1", "entrypoint": "CustomJS", "type": "user" } diff --git a/xExtension-ImageProxy/extension.php b/xExtension-ImageProxy/extension.php index 1dd1494..ccc606e 100644 --- a/xExtension-ImageProxy/extension.php +++ b/xExtension-ImageProxy/extension.php @@ -11,6 +11,7 @@ final class ImageProxyExtension extends Minz_Extension { private const SCHEME_INCLUDE = ''; private const URL_ENCODE = '1'; + #[Override] public function init(): void { if (!FreshRSS_Context::hasSystemConf()) { throw new FreshRSS_Context_Exception('System configuration not initialised!'); @@ -55,6 +56,7 @@ public function init(): void { } } + #[Override] public function handleConfigureAction(): void { $this->registerTranslates(); diff --git a/xExtension-ImageProxy/metadata.json b/xExtension-ImageProxy/metadata.json index dfd761b..cda5bd5 100644 --- a/xExtension-ImageProxy/metadata.json +++ b/xExtension-ImageProxy/metadata.json @@ -2,7 +2,7 @@ "name": "Image Proxy", "author": "Frans de Jonge", "description": "No insecure content warnings or disappearing images.", - "version": "0.7.1", + "version": "0.7.2", "entrypoint": "ImageProxy", "type": "user" } diff --git a/xExtension-QuickCollapse/Controllers/quickCollapseController.php b/xExtension-QuickCollapse/Controllers/quickCollapseController.php index b2c1332..0e6a501 100644 --- a/xExtension-QuickCollapse/Controllers/quickCollapseController.php +++ b/xExtension-QuickCollapse/Controllers/quickCollapseController.php @@ -1,6 +1,7 @@ registerTranslates(); $this->registerViews(); diff --git a/xExtension-QuickCollapse/metadata.json b/xExtension-QuickCollapse/metadata.json index 14dcbb3..dc6a113 100644 --- a/xExtension-QuickCollapse/metadata.json +++ b/xExtension-QuickCollapse/metadata.json @@ -2,7 +2,7 @@ "name": "Quick Collapse", "author": "romibi and Marien Fressinaud", "description": "Quickly change from folded to unfolded articles", - "version": "0.2", + "version": "0.2.1", "entrypoint": "QuickCollapse", "type": "user" } diff --git a/xExtension-ReadingTime/extension.php b/xExtension-ReadingTime/extension.php index d1a9a63..307d1a7 100644 --- a/xExtension-ReadingTime/extension.php +++ b/xExtension-ReadingTime/extension.php @@ -2,7 +2,8 @@ declare(strict_types=1); -class ReadingTimeExtension extends Minz_Extension { +final class ReadingTimeExtension extends Minz_Extension { + #[Override] public function init(): void { Minz_View::appendScript($this->getFileUrl('readingtime.js', 'js')); } diff --git a/xExtension-ReadingTime/metadata.json b/xExtension-ReadingTime/metadata.json index fcd17b7..0849497 100644 --- a/xExtension-ReadingTime/metadata.json +++ b/xExtension-ReadingTime/metadata.json @@ -2,7 +2,7 @@ "name": "ReadingTime", "author": "Lapineige", "description": "Add a reading time estimation next to each article", - "version": "1.5", + "version": "1.5.1", "entrypoint": "ReadingTime", "type": "user" } diff --git a/xExtension-ShareByEmail/Controllers/shareByEmailController.php b/xExtension-ShareByEmail/Controllers/shareByEmailController.php index cdeaedf..32d8833 100644 --- a/xExtension-ShareByEmail/Controllers/shareByEmailController.php +++ b/xExtension-ShareByEmail/Controllers/shareByEmailController.php @@ -2,7 +2,7 @@ declare(strict_types=1); -class FreshExtension_shareByEmail_Controller extends Minz_ActionController { +final class FreshExtension_shareByEmail_Controller extends Minz_ActionController { public ?Minz_Extension $extension; /** @var ShareByEmail\mailers\View */ @@ -12,6 +12,7 @@ public function __construct() { parent::__construct(ShareByEmail\mailers\View::class); } + #[Override] public function init(): void { $this->extension = Minz_ExtensionManager::findExtension('Share By Email'); } @@ -34,13 +35,13 @@ public function shareAction(): void { } $this->view->entry = $entry; - if (FreshRSS_Context::$system_conf === null) { + if (!FreshRSS_Context::hasSystemConf()) { throw new FreshRSS_Context_Exception('System configuration not initialised!'); } $username = Minz_Session::paramString('currentUser') ?: '_'; - $service_name = FreshRSS_Context::$system_conf->title; - $service_url = FreshRSS_Context::$system_conf->base_url; + $service_name = FreshRSS_Context::systemConf()->title; + $service_url = FreshRSS_Context::systemConf()->base_url; Minz_View::prependTitle(_t('shareByEmail.share.title') . ' · '); if ($this->extension !== null) { diff --git a/xExtension-ShareByEmail/Models/View.php b/xExtension-ShareByEmail/Models/View.php index 15449bc..bca3c4c 100644 --- a/xExtension-ShareByEmail/Models/View.php +++ b/xExtension-ShareByEmail/Models/View.php @@ -4,7 +4,7 @@ namespace ShareByEmail\mailers; -class View extends \Minz_View { +final class View extends \Minz_View { public ?\FreshRSS_Entry $entry = null; public string $content = ''; diff --git a/xExtension-ShareByEmail/extension.php b/xExtension-ShareByEmail/extension.php index b058fac..db83bb4 100644 --- a/xExtension-ShareByEmail/extension.php +++ b/xExtension-ShareByEmail/extension.php @@ -2,8 +2,9 @@ declare(strict_types=1); -class ShareByEmailExtension extends Minz_Extension { +final class ShareByEmailExtension extends Minz_Extension { + #[Override] public function init(): void { $this->registerTranslates(); diff --git a/xExtension-ShareByEmail/mailers/Share.php b/xExtension-ShareByEmail/mailers/Share.php index 1caaf1e..a047022 100644 --- a/xExtension-ShareByEmail/mailers/Share.php +++ b/xExtension-ShareByEmail/mailers/Share.php @@ -18,8 +18,8 @@ public function send_article(string $to, string $subject, string $content): bool $this->view->content = $content; - if (isset(\FreshRSS_Context::$system_conf)) { - $subject_prefix = '[' . \FreshRSS_Context::$system_conf->title . ']'; + if (\FreshRSS_Context::hasSystemConf()) { + $subject_prefix = '[' . \FreshRSS_Context::systemConf()->title . ']'; } else { $subject_prefix = ''; } diff --git a/xExtension-ShareByEmail/metadata.json b/xExtension-ShareByEmail/metadata.json index 8f689f0..fd9d5ab 100644 --- a/xExtension-ShareByEmail/metadata.json +++ b/xExtension-ShareByEmail/metadata.json @@ -2,7 +2,7 @@ "name": "Share By Email", "author": "Marien Fressinaud", "description": "Improve the sharing by email system.", - "version": "0.2.1", + "version": "0.2.2", "entrypoint": "ShareByEmail", "type": "user" } diff --git a/xExtension-StickyFeeds/extension.php b/xExtension-StickyFeeds/extension.php index 1c064de..8df1b7e 100644 --- a/xExtension-StickyFeeds/extension.php +++ b/xExtension-StickyFeeds/extension.php @@ -2,7 +2,8 @@ declare(strict_types=1); -class StickyFeedsExtension extends Minz_Extension { +final class StickyFeedsExtension extends Minz_Extension { + #[Override] public function init(): void { Minz_View::appendStyle($this->getFileUrl('style.css', 'css')); Minz_View::appendScript($this->getFileUrl('script.js', 'js')); diff --git a/xExtension-StickyFeeds/metadata.json b/xExtension-StickyFeeds/metadata.json index 639ae9a..7c49f67 100644 --- a/xExtension-StickyFeeds/metadata.json +++ b/xExtension-StickyFeeds/metadata.json @@ -2,7 +2,7 @@ "name": "Sticky Feeds", "author": "Marien Fressinaud", "description": "Set the feed aside in the main stream following the window scroll.", - "version": "0.2", + "version": "0.2.1", "entrypoint": "StickyFeeds", "type": "user" } diff --git a/xExtension-TTRSS_API/extension.php b/xExtension-TTRSS_API/extension.php index bce8bd0..a5fd1d7 100644 --- a/xExtension-TTRSS_API/extension.php +++ b/xExtension-TTRSS_API/extension.php @@ -1,14 +1,17 @@ registerHook( 'post_update', array($this, 'postUpdateHook') ); } + #[Override] public function install() { $filename = 'ttrss.php'; $file_source = join_path($this->getPath(), $filename); @@ -36,6 +39,7 @@ public function install() { return true; } + #[Override] public function uninstall() { $filename = 'ttrss.php'; $file_destination = join_path(PUBLIC_PATH, 'api', $filename); @@ -47,7 +51,7 @@ public function uninstall() { return true; } - public function postUpdateHook() { + public function postUpdateHook(): void { $res = $this->install(); if ($res !== true) { diff --git a/xExtension-TTRSS_API/ttrss.php b/xExtension-TTRSS_API/ttrss.php index 3064cfe..e11046e 100644 --- a/xExtension-TTRSS_API/ttrss.php +++ b/xExtension-TTRSS_API/ttrss.php @@ -4,16 +4,11 @@ require(LIB_PATH . '/lib_rss.php'); // Includes class autoloader -class MyPDO extends Minz_ModelPdo { - function prepare($sql) { - $sql = str_replace('%_', $this->prefix, $sql); - // Minz_Log::debug($sql); - return $this->bd->prepare($sql); - } +final class MyPDO extends Minz_ModelPdo { } -class FreshAPI_TTRSS { +final class FreshAPI_TTRSS { const API_LEVEL = 11; const STATUS_OK = 0; @@ -28,7 +23,7 @@ class FreshAPI_TTRSS { public function __construct($params) { $this->seq = isset($params['seq']) ? $params['seq'] : 0; - $this->user = Minz_Session::param('currentUser', ''); + $this->user = Minz_Session::paramString('currentUser'); $this->method = $params['op']; $this->params = $params; $this->system_conf = Minz_Configuration::get('system'); @@ -74,7 +69,7 @@ public function handle() { } if ($this->user === '' && - !in_array($this->method, array('login', 'isloggedin'))) { + !in_array($this->method, ['login', 'isloggedin'], true)) { $this->bad(array( 'error' => 'NOT_LOGGED_IN' )); @@ -121,7 +116,7 @@ public function getVersion() { public function login() { $username = $this->param('user'); $password = $this->param('password'); - $password_base64 = base64_decode($this->param('password')); + $password_base64 = base64_decode($this->param('password'), true); if ($this->auth_user($username, $password) || $this->auth_user($username, $password_base64)) { @@ -156,11 +151,13 @@ public function getCategories() { // $enable_nested = $this->param('enable_nested', true); // not supported $pdo = new MyPDO(); - $sql = 'SELECT DISTINCT c.id, c.name, COUNT(f.id) AS nb_feeds,' - . ' (SELECT COUNT(e.id) FROM %_entry e WHERE e.id_feed = f.id AND e.is_read=0) AS unread' - . ' FROM `%_category` c' - . ' LEFT JOIN `%_feed` f ON c.id = f.category' - . ' GROUP BY c.id, c.name'; + $sql = <<prepare($sql); $stm->execute(); $res = $stm->fetchAll(PDO::FETCH_ASSOC); @@ -332,7 +329,7 @@ public function getHeadlines() { 'title' => $item->title(), 'link' => $item->link(), 'tags' => $item->tags(), - 'author' => $item->author(), + 'author' => $item->authors(true), 'feed_id' => $feed->id(), 'feed_title' => $feed->name(), ); diff --git a/xExtension-TitleWrap/extension.php b/xExtension-TitleWrap/extension.php index 7e6c179..10bd93b 100644 --- a/xExtension-TitleWrap/extension.php +++ b/xExtension-TitleWrap/extension.php @@ -2,7 +2,8 @@ declare(strict_types=1); -class TitleWrapExtension extends Minz_Extension { +final class TitleWrapExtension extends Minz_Extension { + #[Override] public function init(): void { Minz_View::appendStyle($this->getFileUrl('title_wrap.css', 'css')); } diff --git a/xExtension-TitleWrap/metadata.json b/xExtension-TitleWrap/metadata.json index ec77917..6e1de1a 100644 --- a/xExtension-TitleWrap/metadata.json +++ b/xExtension-TitleWrap/metadata.json @@ -2,7 +2,7 @@ "name": "Title-Wrap", "author": "₣rans de Jonge, Joris Kinable", "description": "Applies a line-wrap to long article titles, as opposed to truncating the title when it overflows its display area.", - "version": "0.2.1", + "version": "0.2.2", "entrypoint": "TitleWrap", "type": "user" } diff --git a/xExtension-YouTube/extension.php b/xExtension-YouTube/extension.php index 03c536e..f552c1e 100644 --- a/xExtension-YouTube/extension.php +++ b/xExtension-YouTube/extension.php @@ -7,7 +7,7 @@ * * @author Kevin Papst */ -class YouTubeExtension extends Minz_Extension +final class YouTubeExtension extends Minz_Extension { /** * Video player width @@ -26,18 +26,11 @@ class YouTubeExtension extends Minz_Extension */ private bool $useNoCookie = false; - public function install() { - return true; - } - - public function uninstall() { - return true; - } - /** * Initialize this extension */ - public function init() + #[Override] + public function init(): void { $this->registerHook('entry_before_display', array($this, 'embedYouTubeVideo')); $this->registerHook('check_url_before_add', array($this, 'convertYoutubeFeedUrl')); @@ -250,6 +243,7 @@ public function getHtml(FreshRSS_Entry $entry, string $url): string * - We save configuration in case of a post. * - We (re)load configuration in all case, so they are in-sync after a save and before a page load. */ + #[Override] public function handleConfigureAction(): void { $this->registerTranslates(); diff --git a/xExtension-YouTube/metadata.json b/xExtension-YouTube/metadata.json index db9b34c..163d684 100644 --- a/xExtension-YouTube/metadata.json +++ b/xExtension-YouTube/metadata.json @@ -2,7 +2,7 @@ "name": "YouTube Video Feed", "author": "Kevin Papst", "description": "Embed YouTube feeds inside article content.", - "version": "0.10", + "version": "0.11", "entrypoint": "YouTube", "type": "user" } diff --git a/xExtension-showFeedID/extension.php b/xExtension-showFeedID/extension.php index bf4abea..b59a755 100644 --- a/xExtension-showFeedID/extension.php +++ b/xExtension-showFeedID/extension.php @@ -2,7 +2,8 @@ declare(strict_types=1); -class ShowFeedIdExtension extends Minz_Extension { +final class ShowFeedIdExtension extends Minz_Extension { + #[Override] public function init(): void { Minz_View::appendScript($this->getFileUrl('showfeedid.js', 'js')); } diff --git a/xExtension-showFeedID/metadata.json b/xExtension-showFeedID/metadata.json index 9b7e26b..5cab022 100644 --- a/xExtension-showFeedID/metadata.json +++ b/xExtension-showFeedID/metadata.json @@ -2,7 +2,7 @@ "name": "ShowFeedID", "author": "math-GH", "description": "Show the feed ID", - "version": "0.2", + "version": "0.2.1", "entrypoint": "ShowFeedID", "type": "user" }