Skip to content

Commit

Permalink
chore: enable phpstan (#52)
Browse files Browse the repository at this point in the history
* chore: enable phpstan

* fix: phpstan errors

* chore: bump js deps, audit fix
  • Loading branch information
imorland authored Nov 12, 2023
1 parent aecb314 commit 0fa0a59
Show file tree
Hide file tree
Showing 8 changed files with 252 additions and 206 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: FoF Sitemap 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
php_versions: '["8.0", "8.1", "8.2"]'

backend_directory: .
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Javascript
name: FoF Sitemap JS

on: [workflow_dispatch, push, pull_request]

Expand All @@ -8,12 +8,12 @@ jobs:
with:
enable_bundlewatch: false
enable_prettier: true
enable_typescript: false
enable_typescript: true

frontend_directory: ./js
backend_directory: .
js_package_manager: npm
main_git_branch: master

secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}

15 changes: 14 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@
},
"flagrow": {
"discuss": "https://discuss.flarum.org/d/14941"
},
"flarum-cli": {
"modules": {
"githubActions": true
}
}
},
"replace": {
Expand All @@ -69,6 +74,14 @@
},
"require-dev": {
"flarum/tags": "*",
"fof/pages": "*"
"fof/pages": "*",
"flarum/phpstan": "*"
},
"scripts": {
"analyse:phpstan": "phpstan analyse",
"clear-cache:phpstan": "phpstan clear-result-cache"
},
"scripts-descriptions": {
"analyse:phpstan": "Run static analysis"
}
}
400 changes: 207 additions & 193 deletions js/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
"format-check": "prettier --check src"
},
"devDependencies": {
"prettier": "^2.8.8"
"prettier": "^3.0.3"
}
}
13 changes: 13 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -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']
7 changes: 0 additions & 7 deletions src/Resources/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
namespace FoF\Sitemap\Resources;

use Carbon\Carbon;
use Flarum\Database\ScopeVisibilityTrait;
use Flarum\User\Guest;
use FoF\Pages\Page as Model;
use FoF\Sitemap\Sitemap\Frequency;
Expand All @@ -23,12 +22,6 @@ class Page extends Resource
{
public function query(): Builder
{
// In pre-0.4.0 versions of fof/pages, ScopeVisibilityTrait was not used
// If such an older version is installed, we don't want to list any page by risk of listing drafts and private pages
if (!class_uses(Model::class, ScopeVisibilityTrait::class)) {
return Model::whereRaw('0=1');
}

$query = Model::whereVisibleTo(new Guest());

// If one of the pages is the homepage, it's already listed by the generator and we don't want to add it twice
Expand Down
2 changes: 1 addition & 1 deletion src/Sitemap/Sitemap.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Sitemap
{
public function __construct(
public array $sets,
Carbon $lastModified
public Carbon $lastModified
) {
}

Expand Down

0 comments on commit 0fa0a59

Please sign in to comment.