From f23bcf6df43f54a09a826f09c046b59a4bff6e90 Mon Sep 17 00:00:00 2001 From: Ian Morland Date: Sun, 12 Nov 2023 17:30:37 +0000 Subject: [PATCH] chore: enable phpstan --- .github/issue_template.md | 49 ------------------- .github/workflows/backend.yml | 12 +++++ .github/workflows/{build.yml => frontend.yml} | 5 +- composer.json | 17 ++++++- phpstan.neon | 13 +++++ src/Content/Assets.php | 4 +- 6 files changed, 46 insertions(+), 54 deletions(-) delete mode 100644 .github/issue_template.md create mode 100644 .github/workflows/backend.yml rename .github/workflows/{build.yml => frontend.yml} (88%) create mode 100644 phpstan.neon diff --git a/.github/issue_template.md b/.github/issue_template.md deleted file mode 100644 index ced7148..0000000 --- a/.github/issue_template.md +++ /dev/null @@ -1,49 +0,0 @@ -### Instructions (MUST READ FIRST) - -Before we can address your issues and concerns with the behavior of our work, we require every bit of detail from you to the fullest extent of this form. If this form is not properly filled out to it's entirity, we, ReFlar, reserve the right to close your issue due to lack of information thereof as well as not following instructions. - -* [x] By agreeing to these terms, you can simply leave this checkbox checked. - -### Please Mentally Go Over the Following Items Before Filling Out this Form: - -* Can you reproduce this problem in debug mode? -* Are you running the latest version of this extension? -* Is your Flarum up-to-date? - -### Description - -[Description of the bug or feature] - -### Steps to Reproduce - -1. [First Step] -2. [Second Step] -3. [and so on...] - -**Expected Behavior:** [What you expected to happen] - -**Actual Behavior:** [What actually happened (screenshots are welcomed!)] - -### Flarum/Server/Client Information - -## Technical Details - -- Version of Flarum (x.y.z): -- Version of extension (x.y.z): -- [OPTIONAL] Website URL where the bug is visible (https://example.com): -- The webserver you are running (Apache, Nginx, etc): -- PHP version (x.y.z): -- Hosted environment (Shared, VPS, etc): -- Hosting provider (https://some-amazing-provider.com): - -## Flarum Info - -``` -Output of "php flarum info", run this in terminal in your Flarum directory. -``` - -## Log Files - -``` -Put any relevant logs here. -``` diff --git a/.github/workflows/backend.yml b/.github/workflows/backend.yml new file mode 100644 index 0000000..8ca65d2 --- /dev/null +++ b/.github/workflows/backend.yml @@ -0,0 +1,12 @@ +name: FoF Night Mode PHP + +on: [workflow_dispatch, push, pull_request] + +jobs: + run: + uses: flarum/framework/.github/workflows/REUSABLE_backend.yml@main + with: + enable_backend_testing: false + enable_phpstan: true + + backend_directory: . diff --git a/.github/workflows/build.yml b/.github/workflows/frontend.yml similarity index 88% rename from .github/workflows/build.yml rename to .github/workflows/frontend.yml index e6c7f2e..2a0b8f0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/frontend.yml @@ -1,4 +1,4 @@ -name: Javascript +name: FoF Night Mode JS on: [workflow_dispatch, push, pull_request] @@ -8,11 +8,12 @@ jobs: with: enable_bundlewatch: false enable_prettier: true - enable_typescript: false + enable_typescript: true frontend_directory: ./js backend_directory: . js_package_manager: yarn main_git_branch: master + secrets: bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} diff --git a/composer.json b/composer.json index 6730c53..1de3fc5 100644 --- a/composer.json +++ b/composer.json @@ -57,7 +57,12 @@ }, "optional-dependencies": [ "fof/default-user-preferences" - ] + ], + "flarum-cli": { + "modules": { + "githubActions": true + } + } }, "autoload": { "psr-4": { @@ -68,5 +73,15 @@ "src/Overrides/Frontend/Assets.php", "src/Overrides/Frontend/RecompileFrontendAssets.php" ] + }, + "scripts": { + "analyse:phpstan": "phpstan analyse", + "clear-cache:phpstan": "phpstan clear-result-cache" + }, + "scripts-descriptions": { + "analyse:phpstan": "Run static analysis" + }, + "require-dev": { + "flarum/phpstan": "*" } } diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..03cf261 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,13 @@ +includes: + - vendor/flarum/phpstan/extension.neon + +parameters: + # The level will be increased in Flarum 2.0 + level: 5 + paths: + - extend.php + - src + excludePaths: + - *.blade.php + checkMissingIterableValueType: false + databaseMigrationsPath: ['migrations'] diff --git a/src/Content/Assets.php b/src/Content/Assets.php index 1750dd8..d72d5c2 100644 --- a/src/Content/Assets.php +++ b/src/Content/Assets.php @@ -78,11 +78,11 @@ protected function assembleCompilers(?string $locale): array /** * @param string|null $url * @param string $type - * @param string $auto + * @param bool $auto * * @return string */ - protected function generateTag(?string $url, string $type, string $auto): string + protected function generateTag(?string $url, string $type, bool $auto): string { return sprintf( '',