Skip to content

Commit

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

* fix: phpstan complaints

* chore: bump js deps
  • Loading branch information
imorland committed Nov 12, 2023
1 parent a4c0e56 commit 4f253d8
Show file tree
Hide file tree
Showing 10 changed files with 695 additions and 791 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 Subscribed 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 Subscribed 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 }}
19 changes: 18 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,32 @@
"optional-dependencies": [
"flarum/approval",
"flarum/flags"
]
]
},
"flagrow": {
"discuss": "https://discuss.flarum.org/d/20917"
},
"flarum-cli": {
"modules": {
"githubActions": true
}
}
},
"autoload": {
"psr-4": {
"FoF\\Subscribed\\": "src/"
}
},
"require-dev": {
"flarum/phpstan": "*",
"flarum/flags": "*",
"flarum/approval": "*"
},
"scripts": {
"analyse:phpstan": "phpstan analyse",
"clear-cache:phpstan": "phpstan clear-result-cache"
},
"scripts-descriptions": {
"analyse:phpstan": "Run static analysis"
}
}
1,423 changes: 642 additions & 781 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 @@ -6,11 +6,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.9.2"
"webpack": "^5.89.0",
"webpack-cli": "^5.1.4"
},
"devDependencies": {
"prettier": "^2.6.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']
3 changes: 0 additions & 3 deletions src/AddPermissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ public function __construct(ExtensionManager $extensions)
$this->extensions = $extensions;
}

/**
* @param ForumSerializer $serializer
*/
public function __invoke(CurrentUserSerializer $serializer, User $user, array $attributes): array
{
$attributes['canSubscribeDiscussionCreated'] = $serializer->getActor()->can('subscribeDiscussionCreated');
Expand Down
3 changes: 2 additions & 1 deletion src/Listeners/DiscussionCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public function subscribe(Dispatcher $events)

public function whenDiscussionWasStarted(Started $event)
{
/** @phpstan-ignore-next-line */
if ($event->discussion->is_approved === false) {
return;
}
Expand All @@ -60,7 +61,7 @@ public function whenDiscussionWasStarted(Started $event)

public function whenDiscussionWasApproved(PostWasApproved $event)
{
if ($event->post->number != 1) {
if ($event->post->number !== 1) {
return;
}

Expand Down
1 change: 1 addition & 0 deletions src/Listeners/PostCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function whenPosted(Posted $event)
{
// We don't want to notify if this is the first post in a new disccusion, or if the post
// is not approved.
/** @phpstan-ignore-next-line */
if ($event->post->number === 1 || $event->post->is_approved === false) {
return;
}
Expand Down
1 change: 1 addition & 0 deletions src/Listeners/UnapprovedPostCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public function subscribe(Dispatcher $events)

public function whenPostWasPosted(Posted $event)
{
/** @phpstan-ignore-next-line */
if ($event->post->is_approved !== false) {
return;
}
Expand Down

0 comments on commit 4f253d8

Please sign in to comment.