Skip to content

Commit 0e171dd

Browse files
authored
Merge pull request #6242 from WoltLab/62-phpstan-level6
Increase PHPStan to level 6
2 parents 78890b1 + b66a9c1 commit 0e171dd

1,392 files changed

Lines changed: 7759 additions & 5146 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

phpstan-baseline.neon

Lines changed: 7 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,6 @@ parameters:
8484
count: 2
8585
path: wcfsetup/install/files/lib/data/comment/CommentAction.class.php
8686

87-
-
88-
message: '#^Property wcf\\data\\comment\\response\\CommentResponseAction\:\:\$response \(wcf\\data\\comment\\response\\CommentResponse\) does not accept wcf\\data\\comment\\response\\CommentResponseEditor\.$#'
89-
identifier: assign.propertyType
90-
count: 1
91-
path: wcfsetup/install/files/lib/data/comment/response/CommentResponseAction.class.php
92-
93-
-
94-
message: '#^Property wcf\\data\\style\\StyleAction\:\:\$style \(wcf\\data\\style\\Style\) does not accept wcf\\data\\style\\StyleEditor\.$#'
95-
identifier: assign.propertyType
96-
count: 1
97-
path: wcfsetup/install/files/lib/data/style/StyleAction.class.php
98-
9987
-
10088
message: '#^While loop condition is always true\.$#'
10189
identifier: while.alwaysTrue
@@ -108,18 +96,6 @@ parameters:
10896
count: 1
10997
path: wcfsetup/install/files/lib/form/LostPasswordForm.class.php
11098

111-
-
112-
message: '#^Negated boolean expression is always true\.$#'
113-
identifier: booleanNot.alwaysTrue
114-
count: 1
115-
path: wcfsetup/install/files/lib/page/AbstractPage.class.php
116-
117-
-
118-
message: '#^Strict comparison using \=\=\= between int and ''og\:description'' will always evaluate to false\.$#'
119-
identifier: identical.alwaysFalse
120-
count: 1
121-
path: wcfsetup/install/files/lib/page/AbstractPage.class.php
122-
12399
-
124100
message: '#^Instanceof between wcf\\data\\search\\ISearchResultObject and wcf\\data\\search\\ISearchResultObject will always evaluate to true\.$#'
125101
identifier: instanceof.alwaysTrue
@@ -402,12 +378,6 @@ parameters:
402378
count: 1
403379
path: wcfsetup/install/files/lib/system/condition/AbstractMultiSelectCondition.class.php
404380

405-
-
406-
message: '#^PHPDoc type array of property wcf\\system\\condition\\AbstractMultiSelectCondition\:\:\$fieldValue is not covariant with PHPDoc type string of overridden property wcf\\system\\condition\\AbstractSelectCondition\:\:\$fieldValue\.$#'
407-
identifier: property.phpDocType
408-
count: 1
409-
path: wcfsetup/install/files/lib/system/condition/AbstractMultiSelectCondition.class.php
410-
411381
-
412382
message: '#^Parameter \#2 \$array of function implode expects array\|null, string given\.$#'
413383
identifier: argument.type
@@ -780,12 +750,6 @@ parameters:
780750
count: 2
781751
path: wcfsetup/install/files/lib/system/form/builder/container/wysiwyg/WysiwygFormContainer.class.php
782752

783-
-
784-
message: '#^Call to function is_array\(\) with array will always evaluate to true\.$#'
785-
identifier: function.alreadyNarrowedType
786-
count: 2
787-
path: wcfsetup/install/files/lib/system/form/builder/data/FormDataHandler.class.php
788-
789753
-
790754
message: '#^Call to function is_bool\(\) with string will always evaluate to false\.$#'
791755
identifier: function.impossibleType
@@ -1017,7 +981,7 @@ parameters:
1017981
-
1018982
message: '#^Call to function is_numeric\(\) with float\|int will always evaluate to true\.$#'
1019983
identifier: function.alreadyNarrowedType
1020-
count: 7
984+
count: 2
1021985
path: wcfsetup/install/files/lib/system/form/builder/field/UploadFormField.class.php
1022986

1023987
-
@@ -1045,7 +1009,7 @@ parameters:
10451009
path: wcfsetup/install/files/lib/system/form/builder/field/acl/AclFormField.class.php
10461010

10471011
-
1048-
message: '#^Instanceof between wcf\\data\\DatabaseObjectList and wcf\\data\\DatabaseObjectList will always evaluate to true\.$#'
1012+
message: '#^Instanceof between wcf\\data\\DatabaseObjectList<wcf\\data\\DatabaseObject> and wcf\\data\\DatabaseObjectList will always evaluate to true\.$#'
10491013
identifier: instanceof.alwaysTrue
10501014
count: 1
10511015
path: wcfsetup/install/files/lib/system/form/builder/field/dependency/ValueFormFieldDependency.class.php
@@ -1183,7 +1147,7 @@ parameters:
11831147
path: wcfsetup/install/files/lib/system/label/object/AbstractLabelObjectHandler.class.php
11841148

11851149
-
1186-
message: '#^Call to an undefined method wcf\\data\\DatabaseObjectList\:\:getAttachmentList\(\)\.$#'
1150+
message: '#^Call to an undefined method wcf\\data\\DatabaseObjectList<wcf\\data\\DatabaseObject>\:\:getAttachmentList\(\)\.$#'
11871151
identifier: method.notFound
11881152
count: 1
11891153
path: wcfsetup/install/files/lib/system/message/QuickReplyManager.class.php
@@ -1293,13 +1257,13 @@ parameters:
12931257
-
12941258
message: '#^Call to function assert\(\) with true will always evaluate to true\.$#'
12951259
identifier: function.alreadyNarrowedType
1296-
count: 1
1260+
count: 2
12971261
path: wcfsetup/install/files/lib/system/package/plugin/ACPMenuPackageInstallationPlugin.class.php
12981262

12991263
-
13001264
message: '#^Instanceof between DOMElement and DOMElement will always evaluate to true\.$#'
13011265
identifier: instanceof.alwaysTrue
1302-
count: 1
1266+
count: 2
13031267
path: wcfsetup/install/files/lib/system/package/plugin/ACPMenuPackageInstallationPlugin.class.php
13041268

13051269
-
@@ -1311,13 +1275,13 @@ parameters:
13111275
-
13121276
message: '#^Call to function assert\(\) with true will always evaluate to true\.$#'
13131277
identifier: function.alreadyNarrowedType
1314-
count: 1
1278+
count: 2
13151279
path: wcfsetup/install/files/lib/system/package/plugin/UserMenuPackageInstallationPlugin.class.php
13161280

13171281
-
13181282
message: '#^Instanceof between DOMElement and DOMElement will always evaluate to true\.$#'
13191283
identifier: instanceof.alwaysTrue
1320-
count: 1
1284+
count: 2
13211285
path: wcfsetup/install/files/lib/system/package/plugin/UserMenuPackageInstallationPlugin.class.php
13221286

13231287
-

phpstan.neon

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ includes:
22
- phpstan-baseline.neon
33

44
parameters:
5-
level: 5
5+
level: 6
66
paths:
77
- wcfsetup/install/files
88
excludePaths:
@@ -12,6 +12,7 @@ parameters:
1212
- constants.php
1313
ignoreErrors:
1414
- identifier: match.unhandled
15+
- identifier: method.unused
1516
- identifier: new.static
1617
- identifier: trait.unused
1718
universalObjectCratesClasses:

wcfsetup/install/files/lib/acp/action/DashboardConfigureAction.class.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@
2424
final class DashboardConfigureAction implements RequestHandlerInterface
2525
{
2626
private AcpDashboard $dashboard;
27+
28+
/**
29+
* @var array<string, array{
30+
* boxName: string,
31+
* userID: int,
32+
* enabled: int,
33+
* showOrder: int,
34+
* }>
35+
*/
2736
private array $userConfiguration;
2837

2938
public function __construct()
@@ -88,6 +97,9 @@ private function getForm(): Psr15DialogForm
8897
return $form;
8998
}
9099

100+
/**
101+
* @return list<string>
102+
*/
91103
private function getSelectedBoxNames(): array
92104
{
93105
$selectedBoxNames = [];
@@ -111,6 +123,9 @@ private function getConfigurationFormField(): MultipleSelectionFormField
111123
};
112124
}
113125

126+
/**
127+
* @return array<string, string>
128+
*/
114129
private function getBoxOptions(): array
115130
{
116131
$options = [];
@@ -123,6 +138,9 @@ private function getBoxOptions(): array
123138
return $options;
124139
}
125140

141+
/**
142+
* @param array<string, string> &$options
143+
*/
126144
private function sortBoxOptions(array &$options): void
127145
{
128146
\uksort($options, function (string $boxNameA, string $boxNameB) {

wcfsetup/install/files/lib/acp/action/FullLogoutAction.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ final class FullLogoutAction extends LogoutAction
1919
/**
2020
* @inheritDoc
2121
*/
22-
public function execute()
22+
public function execute(): RedirectResponse
2323
{
2424
AbstractSecureAction::execute();
2525

wcfsetup/install/files/lib/acp/action/TagSynonymAction.class.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ public function handle(ServerRequestInterface $request): ResponseInterface
8181
}
8282
}
8383

84+
/**
85+
* @param Tag[] $tags
86+
*/
8487
private function getForm(array $tags): Psr15DialogForm
8588
{
8689
$form = new Psr15DialogForm(

wcfsetup/install/files/lib/acp/action/UninstallPackageAction.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function readParameters()
7575
}
7676
}
7777

78-
public function execute()
78+
public function execute(): ResponseInterface
7979
{
8080
parent::execute();
8181

wcfsetup/install/files/lib/acp/action/UserExportGdprAction.class.php

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace wcf\acp\action;
44

55
use Laminas\Diactoros\Response\JsonResponse;
6+
use Psr\Http\Message\ResponseInterface;
67
use wcf\action\AbstractAction;
78
use wcf\data\package\PackageCache;
89
use wcf\data\user\cover\photo\DefaultUserCoverPhoto;
@@ -35,7 +36,7 @@ final class UserExportGdprAction extends AbstractAction
3536
/**
3637
* export data
3738
*
38-
* @var array
39+
* @var mixed[]
3940
*/
4041
public $data = [];
4142

@@ -149,7 +150,7 @@ public function readParameters()
149150
/**
150151
* @inheritDoc
151152
*/
152-
public function execute()
153+
public function execute(): ResponseInterface
153154
{
154155
// you MUST NOT use the `execute` event to provide data, use `export` (see below) instead!
155156
parent::execute();
@@ -249,7 +250,7 @@ public function execute()
249250
* @param string $ipAddressColumn
250251
* @param string $timeColumn
251252
* @param string $userIDColumn
252-
* @return array
253+
* @return mixed[]
253254
*/
254255
public function exportIpAddresses($databaseTable, $ipAddressColumn, $timeColumn, $userIDColumn)
255256
{
@@ -263,6 +264,11 @@ public function exportIpAddresses($databaseTable, $ipAddressColumn, $timeColumn,
263264
return $this->fetchIpAddresses($statement, $ipAddressColumn, $timeColumn);
264265
}
265266

267+
/**
268+
* @param string $tableName
269+
* @param string $userIDColumn
270+
* @return mixed[]
271+
*/
266272
protected function dumpTable($tableName, $userIDColumn)
267273
{
268274
$sql = "SELECT *
@@ -279,6 +285,11 @@ protected function dumpTable($tableName, $userIDColumn)
279285
return $data;
280286
}
281287

288+
/**
289+
* @param string $ipAddressColumn
290+
* @param string $timeColumn
291+
* @return array{ipAddress: string, time: mixed}[]
292+
*/
282293
protected function fetchIpAddresses(PreparedStatement $statement, $ipAddressColumn, $timeColumn)
283294
{
284295
$ipAddresses = [];
@@ -297,6 +308,9 @@ protected function fetchIpAddresses(PreparedStatement $statement, $ipAddressColu
297308
return $ipAddresses;
298309
}
299310

311+
/**
312+
* @return array{session: mixed[], acpSessionLog: mixed[]}
313+
*/
300314
protected function exportSessionIpAddresses()
301315
{
302316
$data = [
@@ -323,6 +337,9 @@ protected function exportSessionIpAddresses()
323337
return $data;
324338
}
325339

340+
/**
341+
* @return array<string, mixed>
342+
*/
326343
protected function exportUser()
327344
{
328345
$data = ['languageCode' => $this->user->getLanguage()->getFixedLanguageCode()];
@@ -351,6 +368,9 @@ protected function exportUser()
351368
return $data;
352369
}
353370

371+
/**
372+
* @return mixed[]
373+
*/
354374
protected function exportUserOptions()
355375
{
356376
$optionHandler = new UserOptionHandler(false, '', '');
@@ -365,6 +385,11 @@ protected function exportUserOptions()
365385
return $data;
366386
}
367387

388+
/**
389+
* @param mixed[] &$data
390+
* @param mixed[] $optionTree
391+
* @return void
392+
*/
368393
protected function exportUserOptionCategory(array &$data, array $optionTree)
369394
{
370395
if (!empty($optionTree['options'])) {

wcfsetup/install/files/lib/acp/action/UserQuickSearchAction.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function readParameters()
8383
/**
8484
* @inheritDoc
8585
*/
86-
public function execute()
86+
public function execute(): RedirectResponse
8787
{
8888
ACPMenu::getInstance()->setActiveMenuItem('wcf.acp.menu.link.user.search');
8989

wcfsetup/install/files/lib/acp/action/WorkerProxyAction.class.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ final class WorkerProxyAction extends AJAXInvokeAction
3232

3333
/**
3434
* parameters for worker action
35-
* @var array
35+
* @var array<string, mixed>
3636
*/
3737
protected $parameters = [];
3838

@@ -42,6 +42,9 @@ final class WorkerProxyAction extends AJAXInvokeAction
4242
*/
4343
protected $worker;
4444

45+
/**
46+
* @var string[]
47+
*/
4548
public static $allowInvoke = [];
4649

4750
/**
@@ -66,6 +69,8 @@ public function readParameters()
6669

6770
/**
6871
* Validates class name.
72+
*
73+
* @return void
6974
*/
7075
protected function validate()
7176
{
@@ -112,8 +117,9 @@ public function execute()
112117
* Sends a JSON-encoded response.
113118
*
114119
* @param int $progress
115-
* @param array $parameters
120+
* @param ?array<string, mixed> $parameters
116121
* @param string $proceedURL
122+
* @return void
117123
*/
118124
protected function sendResponse($progress = 0, ?array $parameters = null, $proceedURL = '')
119125
{

0 commit comments

Comments
 (0)