Skip to content

Commit e372c25

Browse files
imorlandStyleCIBot
andauthored
[2.x] chore: increase phpstan to level 6 (#61)
* chore: increase phpstan to level 6 * Apply fixes from StyleCI --------- Co-authored-by: StyleCI Bot <bot@styleci.io>
1 parent 4e545e1 commit e372c25

File tree

8 files changed

+24
-12
lines changed

8 files changed

+24
-12
lines changed

phpstan.neon

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ includes:
22
- vendor/flarum/phpstan/extension.neon
33

44
parameters:
5-
# The level will be increased in Flarum 2.0
6-
level: 5
5+
level: 6
76
paths:
87
- extend.php
98
- src

src/Access/ScopePageVisibility.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
class ScopePageVisibility
1818
{
19-
public function __invoke(User $actor, Builder $query)
19+
public function __invoke(User $actor, Builder $query): void
2020
{
2121
if (!$actor->hasPermission('fof-pages.viewHidden')) {
2222
$query->where('is_hidden', false);

src/Api/Resource/PageResource.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,17 @@ public function model(): string
4848
return Page::class;
4949
}
5050

51+
/**
52+
* @param FlarumContext $context
53+
*/
5154
public function scope(Builder $query, Context $context): void
5255
{
5356
$query->whereVisibleTo($context->getActor());
5457
}
5558

59+
/**
60+
* @param FlarumContext $context
61+
*/
5662
public function find(string $id, Context $context): ?object
5763
{
5864
return $this->pages->findOrFail((int) $id, $context->getActor());
@@ -127,8 +133,11 @@ public function sorts(): array
127133
];
128134
}
129135

130-
/** @param Page $model */
131-
public function created($model, Context $context): ?object
136+
/**
137+
* @param Page $model
138+
* @param FlarumContext $context
139+
*/
140+
public function created(object $model, Context $context): ?object
132141
{
133142
$this->events->dispatch(
134143
new PageCreated($model, $context->getActor())
@@ -137,6 +146,10 @@ public function created($model, Context $context): ?object
137146
return parent::created($model, $context);
138147
}
139148

149+
/**
150+
* @param Page $model
151+
* @param FlarumContext $context
152+
*/
140153
public function deleted(object $model, Context $context): void
141154
{
142155
$this->events->dispatch(

src/Command/DeletePage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
class DeletePage
1717
{
1818
public function __construct(
19-
public $pageId,
19+
public int|string $pageId,
2020
public User $actor,
2121
public array $data = []
2222
) {

src/Content/AddHomePageId.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function __construct(
2121
) {
2222
}
2323

24-
public function __invoke(Document $document)
24+
public function __invoke(Document $document): void
2525
{
2626
if (($id = $this->settings->get('pages_home')) !== null) {
2727
$document->payload['fof-pages.home'] = $id;

src/Content/Page.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function __construct(
3030
) {
3131
}
3232

33-
public function __invoke(Document $document, ServerRequestInterface $request)
33+
public function __invoke(Document $document, ServerRequestInterface $request): void
3434
{
3535
$queryParams = $request->getQueryParams();
3636

@@ -45,7 +45,7 @@ public function __invoke(Document $document, ServerRequestInterface $request)
4545
$document->payload['apiDocument'] = $apiDocument;
4646
}
4747

48-
private function getApiDocument(ServerRequestInterface $request, $id)
48+
private function getApiDocument(ServerRequestInterface $request, int|string|null $id): object
4949
{
5050
$response = $this->api->withParentRequest($request)->get('/pages/'.$id);
5151

src/Page.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function getParsedContentAttribute()
8080
*
8181
* @param string $value
8282
*/
83-
public function setContentAttribute($value)
83+
public function setContentAttribute($value): void
8484
{
8585
$this->attributes['content'] = $value ? static::$formatter->parse($value, $this) : null;
8686
}
@@ -114,7 +114,7 @@ public static function getFormatter()
114114
*
115115
* @param \Flarum\Formatter\Formatter $formatter
116116
*/
117-
public static function setFormatter(Formatter $formatter)
117+
public static function setFormatter(Formatter $formatter): void
118118
{
119119
static::$formatter = $formatter;
120120
}

src/Providers/PageServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
class PageServiceProvider extends AbstractServiceProvider
2121
{
22-
public function boot()
22+
public function boot(): void
2323
{
2424
$this->container->instance('path.pages', $this->container->make(Paths::class)->base.DIRECTORY_SEPARATOR.'pages');
2525

0 commit comments

Comments
 (0)