Skip to content

Commit

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

* chore: npm audit fix
  • Loading branch information
imorland authored Nov 12, 2023
1 parent 78967d5 commit 9de3217
Show file tree
Hide file tree
Showing 8 changed files with 177 additions and 140 deletions.
1 change: 1 addition & 0 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ jobs:
uses: flarum/framework/.github/workflows/REUSABLE_backend.yml@main
with:
enable_backend_testing: true
enable_phpstan: true

backend_directory: .
11 changes: 8 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@
},
"require-dev": {
"flarum/bbcode": "*",
"flarum/testing": "^1.0.0"
"flarum/testing": "^1.0.0",
"flarum/phpstan": "*",
"flarum/suspend": "*"
},
"autoload-dev": {
"psr-4": {
Expand All @@ -79,12 +81,15 @@
],
"test:unit": "phpunit -c tests/phpunit.unit.xml",
"test:integration": "phpunit -c tests/phpunit.integration.xml",
"test:setup": "@php tests/integration/setup.php"
"test:setup": "@php tests/integration/setup.php",
"analyse:phpstan": "phpstan analyse",
"clear-cache:phpstan": "phpstan clear-result-cache"
},
"scripts-descriptions": {
"test": "Runs all tests.",
"test:unit": "Runs all unit tests.",
"test:integration": "Runs all integration tests.",
"test:setup": "Sets up a database for use with integration tests. Execute this only once."
"test:setup": "Sets up a database for use with integration tests. Execute this only once.",
"analyse:phpstan": "Run static analysis"
}
}
3 changes: 3 additions & 0 deletions extend.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@

new Flarum\Locales(__DIR__.'/resources/locale'),

(new Flarum\Model(User::class))
->cast('bio', 'string'),

(new Flarum\Event())
->listen(Saving::class, Listeners\SaveUserBio::class)
->listen(Saved::class, Listeners\ClearFormatterCache::class),
Expand Down
285 changes: 149 additions & 136 deletions js/package-lock.json

Large diffs are not rendered by default.

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']
1 change: 1 addition & 0 deletions src/Access/UserPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ protected function isSuspended(User $user): bool
// suspended_until is null if flarum/suspend isn't installed
// laravel sets all non existing attributes to null
// suspend_until is also null if the user isn't suspended.
/** @phpstan-ignore-next-line */
return $user->suspended_until !== null
&& $user->suspended_until instanceof Carbon
&& $user->suspended_until->isFuture();
Expand Down
2 changes: 1 addition & 1 deletion src/Formatter/FormatterServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Flarum\Foundation\AbstractServiceProvider;
use Flarum\Foundation\Paths;
use Illuminate\Cache\Repository;
use Illuminate\Container\Container;
use Illuminate\Contracts\Container\Container;

class FormatterServiceProvider extends AbstractServiceProvider
{
Expand Down
1 change: 1 addition & 0 deletions src/Formatter/UserBioFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ protected function getConfigurator()
$configurator = parent::getConfigurator();

if ($this->extensions->isEnabled('flarum-markdown')) {
/** @phpstan-ignore-next-line */
$configurator->Litedown;
}

Expand Down

0 comments on commit 9de3217

Please sign in to comment.