Skip to content

Commit

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

* chore: bump js deps
  • Loading branch information
imorland authored Nov 12, 2023
1 parent 38b5006 commit 54a4497
Show file tree
Hide file tree
Showing 8 changed files with 657 additions and 577 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: FoF Prevent Necrobumping 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: .
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Javascript
name: FoF Prevent Necrobumping JS

on: [workflow_dispatch, push, pull_request]

Expand All @@ -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: npm
main_git_branch: master

secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}
18 changes: 17 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,27 @@
"color": "#fff"
},
"optional-dependencies": [
"flarum/tags"
"flarum/tags"
]
},
"flagrow": {
"discuss": "https://discuss.flarum.org/d/18312"
},
"flarum-cli": {
"modules": {
"githubActions": true
}
}
},
"require-dev": {
"flarum/phpstan": "*",
"flarum/tags": "*"
},
"scripts": {
"analyse:phpstan": "phpstan analyse",
"clear-cache:phpstan": "phpstan clear-result-cache"
},
"scripts-descriptions": {
"analyse:phpstan": "Run static analysis"
}
}
1,173 changes: 603 additions & 570 deletions js/package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
"@flarum/prettier-config": "^1.0.0",
"flarum-tsconfig": "^1.0.2",
"flarum-webpack-config": "^2.0.0",
"webpack": "^5.76.0",
"webpack-cli": "^4.10.0"
"webpack": "^5.89.0",
"webpack-cli": "^5.1.4"
},
"devDependencies": {
"prettier": "^2.7.1"
"prettier": "^3.0.3"
},
"scripts": {
"dev": "webpack --mode development --watch",
Expand Down
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']
6 changes: 5 additions & 1 deletion src/Listeners/ValidateNecrobumping.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@

class ValidateNecrobumping
{
/**
* @var NecrobumpingPostValidator
*/
protected $validator;

/**
* @var SettingsRepositoryInterface
*/
Expand All @@ -34,7 +38,7 @@ public function __construct(NecrobumpingPostValidator $validator, SettingsReposi

public function handle(Saving $event)
{
if ($event->post->exists || $event->post->number == 1) {
if ($event->post->exists || $event->post->number === 1) {
return;
}

Expand Down
1 change: 1 addition & 0 deletions src/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Util
public static function getDays(SettingsRepositoryInterface $settings, Discussion $discussion): ?int
{
$days = $settings->get('fof-prevent-necrobumping.days');
/** @phpstan-ignore-next-line */
$tags = $discussion->tags;

if ($tags && $tags->isNotEmpty()) {
Expand Down

0 comments on commit 54a4497

Please sign in to comment.