diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..f7be8f7 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" + - package-ecosystem: "composer" + directory: "/" + schedule: + interval: "monthly" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..dd3991e --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,52 @@ +name: Automated tests + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + + tests: + # https://github.com/actions/virtual-environments + runs-on: ubuntu-22.04 + defaults: + run: + working-directory: ./Extensions + + steps: + - name: Git checkout source code + uses: actions/checkout@v4 + with: + path: Extensions + + # Composer tests + + - name: Check PHP syntax + run: composer run-script php-lint + + - name: Check PHTML syntax + run: composer run-script phtml-lint + + - name: Use Composer cache + id: composer-cache + uses: actions/cache@v4 + with: + path: Extensions/vendor + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php- + + - name: Run Composer install + run: composer install --prefer-dist --no-progress + if: steps.composer-cache.outputs.cache-hit != 'true' + + - name: Git checkout FreshRSS source code + uses: actions/checkout@v4 + with: + repository: FreshRSS/FreshRSS + path: FreshRSS + + - name: PHPStan + run: composer run-script phpstan diff --git a/Controllers/readeckButtonController.php b/Controllers/readeckButtonController.php index f9b0a6f..f6dde97 100644 --- a/Controllers/readeckButtonController.php +++ b/Controllers/readeckButtonController.php @@ -22,7 +22,7 @@ public function jsVarsAction(): void ) )); - $this->view->_layout(false); + $this->view->_layout(null); $this->view->_path('readeckButton/vars.js'); header('Content-Type: application/javascript; charset=utf-8'); diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..627818f --- /dev/null +++ b/composer.json @@ -0,0 +1,55 @@ +{ + "description": "Extension for FreshRSS", + "type": "project", + "require": { + "php": ">=8.1", + "ext-ctype": "*", + "ext-curl": "*", + "ext-dom": "*", + "ext-fileinfo": "*", + "ext-gmp": "*", + "ext-intl": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-openssl": "*", + "ext-pcre": "*", + "ext-pdo": "*", + "ext-pdo_sqlite": "*", + "ext-session": "*", + "ext-simplexml": "*", + "ext-xml": "*", + "ext-xmlreader": "*", + "ext-zend-opcache": "*", + "ext-zip": "*", + "ext-zlib": "*" + }, + "suggest": { + "ext-iconv": "*", + "ext-pdo_mysql": "*", + "ext-pdo_pgsql": "*" + }, + "require-dev": { + "php": ">=8.1", + "ext-phar": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "phpstan/phpstan": "^1.11", + "phpstan/phpstan-strict-rules": "^1.6" + }, + "scripts": { + "php-lint": "find . -type d -name 'vendor' -prune -o -name '*.php' -print0 | xargs -0 -n1 -P4 php -l 1>/dev/null", + "phtml-lint": "find . -type d -name 'vendor' -prune -o -name '*.phtml' -print0 | xargs -0 -n1 -P4 php -l 1>/dev/null", + "phpstan": "phpstan analyse --memory-limit 512M .", + "test": [ + "@php-lint", + "@phtml-lint", + "@phpstan" + ] + }, + "config": { + "allow-plugins": { + "phpstan/extension-installer": false + } + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..95dcf52 --- /dev/null +++ b/composer.lock @@ -0,0 +1,153 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "bdd5cabc1199cf7269f51431ba759ccb", + "packages": [], + "packages-dev": [ + { + "name": "phpstan/phpstan", + "version": "1.12.7", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "dc2b9976bd8b0f84ec9b0e50cc35378551de7af0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/dc2b9976bd8b0f84ec9b0e50cc35378551de7af0", + "reference": "dc2b9976bd8b0f84ec9b0e50cc35378551de7af0", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", + "issues": "https://github.com/phpstan/phpstan/issues", + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + } + ], + "time": "2024-10-18T11:12:07+00:00" + }, + { + "name": "phpstan/phpstan-strict-rules", + "version": "1.6.1", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-strict-rules.git", + "reference": "daeec748b53de80a97498462513066834ec28f8b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/daeec748b53de80a97498462513066834ec28f8b", + "reference": "daeec748b53de80a97498462513066834ec28f8b", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0", + "phpstan/phpstan": "^1.12.4" + }, + "require-dev": { + "nikic/php-parser": "^4.13.0", + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/phpstan-deprecation-rules": "^1.1", + "phpstan/phpstan-phpunit": "^1.0", + "phpunit/phpunit": "^9.5" + }, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "rules.neon" + ] + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "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.6.1" + }, + "time": "2024-09-20T14:04:44+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=8.1", + "ext-ctype": "*", + "ext-curl": "*", + "ext-dom": "*", + "ext-fileinfo": "*", + "ext-gmp": "*", + "ext-intl": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-openssl": "*", + "ext-pcre": "*", + "ext-pdo": "*", + "ext-pdo_sqlite": "*", + "ext-session": "*", + "ext-simplexml": "*", + "ext-xml": "*", + "ext-xmlreader": "*", + "ext-zend-opcache": "*", + "ext-zip": "*", + "ext-zlib": "*" + }, + "platform-dev": { + "php": ">=8.1", + "ext-phar": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*" + }, + "plugin-api-version": "2.6.0" +} diff --git a/docker-compose.yaml b/docker-compose.yaml index b5b52d1..8dd62cb 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -2,12 +2,8 @@ services: freshrss: image: freshrss/freshrss:latest container_name: freshrss - restart: unless-stopped - logging: - options: - max-size: 10m volumes: - ./fresh_rss_data:/var/www/FreshRSS/data - - ./:/var/www/FreshRSS/extensions/freshrss-readeck-button + - ./:/var/www/FreshRSS/extensions/freshrss-readeck-button:ro ports: - 8080:80 diff --git a/phpstan.dist.neon b/phpstan.dist.neon new file mode 100644 index 0000000..185bbaf --- /dev/null +++ b/phpstan.dist.neon @@ -0,0 +1,44 @@ +parameters: + level: 6 # TODO: Increase to 9 + fileExtensions: + - php + - phtml + paths: + - ../FreshRSS + - . + excludePaths: + analyse: + - ../FreshRSS + - vendor/ + - fresh_rss_data/ + analyseAndScan: + - .github/ + - .vscode/ + - .git/ + - node_modules/ + checkMissingOverrideMethodAttribute: true + reportMaybesInPropertyPhpDocTypes: false + treatPhpDocTypesAsCertain: false + strictRules: + allRules: false + booleansInConditions: true + closureUsesThis: true + disallowedConstructs: false + disallowedLooseComparison: false + matchingInheritedMethodNames: true + noVariableVariables: true + numericOperandsInArithmeticOperators: true + overwriteVariablesWithLoop: true + requireParentConstructorCall: true + strictCalls: true + switchConditionsMatchingType: true + uselessCast: true + exceptions: + check: + missingCheckedExceptionInThrows: false # TODO pass + tooWideThrowType: true + implicitThrows: false + checkedExceptionClasses: + - 'Minz_Exception' +includes: + - vendor/phpstan/phpstan-strict-rules/rules.neon