Skip to content

Commit a718427

Browse files
authored
Merge pull request #8530 from paulbalandan/phpdoc-list-type
style: Enable `phpdoc_list_type` fixer
2 parents ad11363 + 06353a4 commit a718427

Some content is hidden

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

61 files changed

+174
-270
lines changed

.php-cs-fixer.dist.php

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -43,38 +43,7 @@
4343
__DIR__ . '/spark',
4444
]);
4545

46-
$overrides = [
47-
'phpdoc_array_type' => true,
48-
'phpdoc_no_alias_tag' => [
49-
'replacements' => [
50-
'type' => 'var',
51-
'link' => 'see',
52-
],
53-
],
54-
'phpdoc_align' => [
55-
'align' => 'vertical',
56-
'spacing' => 1,
57-
'tags' => [
58-
'method',
59-
'param',
60-
'phpstan-assert',
61-
'phpstan-assert-if-true',
62-
'phpstan-assert-if-false',
63-
'phpstan-param',
64-
'phpstan-property',
65-
'phpstan-return',
66-
'phpstan-type',
67-
'phpstan-var',
68-
'property',
69-
'property-read',
70-
'property-write',
71-
'return',
72-
'throws',
73-
'type',
74-
'var',
75-
],
76-
],
77-
];
46+
$overrides = [];
7847

7948
$options = [
8049
'cacheFile' => 'build/.php-cs-fixer.cache',

.php-cs-fixer.no-header.php

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,32 +29,7 @@
2929
__DIR__ . '/admin/starter/builds',
3030
]);
3131

32-
$overrides = [
33-
'phpdoc_array_type' => true,
34-
'phpdoc_align' => [
35-
'align' => 'vertical',
36-
'spacing' => 1,
37-
'tags' => [
38-
'method',
39-
'param',
40-
'phpstan-assert',
41-
'phpstan-assert-if-true',
42-
'phpstan-assert-if-false',
43-
'phpstan-param',
44-
'phpstan-property',
45-
'phpstan-return',
46-
'phpstan-type',
47-
'phpstan-var',
48-
'property',
49-
'property-read',
50-
'property-write',
51-
'return',
52-
'throws',
53-
'type',
54-
'var',
55-
],
56-
],
57-
];
32+
$overrides = [];
5833

5934
$options = [
6035
'cacheFile' => 'build/.php-cs-fixer.no-header.cache',

.php-cs-fixer.user-guide.php

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -39,30 +39,6 @@
3939
'import_symbols' => false,
4040
'leading_backslash_in_global_namespace' => true,
4141
],
42-
'phpdoc_array_type' => true,
43-
'phpdoc_align' => [
44-
'align' => 'vertical',
45-
'spacing' => 1,
46-
'tags' => [
47-
'method',
48-
'param',
49-
'phpstan-assert',
50-
'phpstan-assert-if-true',
51-
'phpstan-assert-if-false',
52-
'phpstan-param',
53-
'phpstan-property',
54-
'phpstan-return',
55-
'phpstan-type',
56-
'phpstan-var',
57-
'property',
58-
'property-read',
59-
'property-write',
60-
'return',
61-
'throws',
62-
'type',
63-
'var',
64-
],
65-
],
6642
];
6743

6844
$options = [

app/Config/Cache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class Cache extends BaseConfig
6161
* ['q'] = Enabled, but only take into account the specified list
6262
* of query parameters.
6363
*
64-
* @var array<string>|bool
64+
* @var bool|list<string>
6565
*/
6666
public $cacheQueryString = false;
6767

app/Config/ContentSecurityPolicy.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,28 +45,28 @@ class ContentSecurityPolicy extends BaseConfig
4545
/**
4646
* Will default to self if not overridden
4747
*
48-
* @var array<string>|string|null
48+
* @var list<string>|string|null
4949
*/
5050
public $defaultSrc;
5151

5252
/**
5353
* Lists allowed scripts' URLs.
5454
*
55-
* @var array<string>|string
55+
* @var list<string>|string
5656
*/
5757
public $scriptSrc = 'self';
5858

5959
/**
6060
* Lists allowed stylesheets' URLs.
6161
*
62-
* @var array<string>|string
62+
* @var list<string>|string
6363
*/
6464
public $styleSrc = 'self';
6565

6666
/**
6767
* Defines the origins from which images can be loaded.
6868
*
69-
* @var array<string>|string
69+
* @var list<string>|string
7070
*/
7171
public $imageSrc = 'self';
7272

@@ -75,36 +75,36 @@ class ContentSecurityPolicy extends BaseConfig
7575
*
7676
* Will default to self if not overridden
7777
*
78-
* @var array<string>|string|null
78+
* @var list<string>|string|null
7979
*/
8080
public $baseURI;
8181

8282
/**
8383
* Lists the URLs for workers and embedded frame contents
8484
*
85-
* @var array<string>|string
85+
* @var list<string>|string
8686
*/
8787
public $childSrc = 'self';
8888

8989
/**
9090
* Limits the origins that you can connect to (via XHR,
9191
* WebSockets, and EventSource).
9292
*
93-
* @var array<string>|string
93+
* @var list<string>|string
9494
*/
9595
public $connectSrc = 'self';
9696

9797
/**
9898
* Specifies the origins that can serve web fonts.
9999
*
100-
* @var array<string>|string
100+
* @var list<string>|string
101101
*/
102102
public $fontSrc;
103103

104104
/**
105105
* Lists valid endpoints for submission from `<form>` tags.
106106
*
107-
* @var array<string>|string
107+
* @var list<string>|string
108108
*/
109109
public $formAction = 'self';
110110

@@ -114,7 +114,7 @@ class ContentSecurityPolicy extends BaseConfig
114114
* and `<applet>` tags. This directive can't be used in
115115
* `<meta>` tags and applies only to non-HTML resources.
116116
*
117-
* @var array<string>|string|null
117+
* @var list<string>|string|null
118118
*/
119119
public $frameAncestors;
120120

@@ -129,33 +129,33 @@ class ContentSecurityPolicy extends BaseConfig
129129
/**
130130
* Restricts the origins allowed to deliver video and audio.
131131
*
132-
* @var array<string>|string|null
132+
* @var list<string>|string|null
133133
*/
134134
public $mediaSrc;
135135

136136
/**
137137
* Allows control over Flash and other plugins.
138138
*
139-
* @var array<string>|string
139+
* @var list<string>|string
140140
*/
141141
public $objectSrc = 'self';
142142

143143
/**
144-
* @var array<string>|string|null
144+
* @var list<string>|string|null
145145
*/
146146
public $manifestSrc;
147147

148148
/**
149149
* Limits the kinds of plugins a page may invoke.
150150
*
151-
* @var array<string>|string|null
151+
* @var list<string>|string|null
152152
*/
153153
public $pluginTypes;
154154

155155
/**
156156
* List of actions allowed.
157157
*
158-
* @var array<string>|string|null
158+
* @var list<string>|string|null
159159
*/
160160
public $sandbox;
161161

app/Config/Format.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Format extends BaseConfig
2222
* These formats are only checked when the data passed to the respond()
2323
* method is an array.
2424
*
25-
* @var array<string>
25+
* @var list<string>
2626
*/
2727
public array $supportedResponseFormats = [
2828
'application/json',

app/Config/Toolbar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Toolbar extends BaseConfig
3131
* List of toolbar collectors that will be called when Debug Toolbar
3232
* fires up and collects data from.
3333
*
34-
* @var array<string>
34+
* @var list<string>
3535
*/
3636
public array $collectors = [
3737
Timers::class,

app/Config/Validation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Validation extends BaseConfig
1818
* Stores the classes that contain the
1919
* rules that are available.
2020
*
21-
* @var array<string>
21+
* @var list<string>
2222
*/
2323
public array $ruleSets = [
2424
Rules::class,

app/Config/View.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
use CodeIgniter\View\ViewDecoratorInterface;
77

88
/**
9-
* @phpstan-type ParserCallable (callable(mixed): mixed)
10-
* @phpstan-type ParserCallableString (callable(mixed): mixed)&string
9+
* @phpstan-type parser_callable (callable(mixed): mixed)
10+
* @phpstan-type parser_callable_string (callable(mixed): mixed)&string
1111
*/
1212
class View extends BaseView
1313
{
@@ -35,7 +35,7 @@ class View extends BaseView
3535
* { created_on|date(Y-m-d)|esc(attr) }
3636
*
3737
* @var array<string, string>
38-
* @phpstan-var array<string, ParserCallableString>
38+
* @phpstan-var array<string, parser_callable_string>
3939
*/
4040
public $filters = [];
4141

@@ -44,8 +44,8 @@ class View extends BaseView
4444
* by the core Parser by creating aliases that will be replaced with
4545
* any callable. Can be single or tag pair.
4646
*
47-
* @var array<string, array<string>|callable|string>
48-
* @phpstan-var array<string, array<ParserCallableString>|ParserCallableString|ParserCallable>
47+
* @var array<string, callable|list<string>|string>
48+
* @phpstan-var array<string, list<parser_callable_string>|parser_callable_string|parser_callable>
4949
*/
5050
public $plugins = [];
5151

@@ -56,7 +56,7 @@ class View extends BaseView
5656
*
5757
* All classes must implement CodeIgniter\View\ViewDecoratorInterface
5858
*
59-
* @var array<class-string<ViewDecoratorInterface>>
59+
* @var list<class-string<ViewDecoratorInterface>>
6060
*/
6161
public array $decorators = [];
6262
}

phpstan-baseline.php

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,16 +1001,6 @@
10011001
'count' => 2,
10021002
'path' => __DIR__ . '/system/Database/BaseResult.php',
10031003
];
1004-
$ignoreErrors[] = [
1005-
'message' => '#^Only booleans are allowed in an if condition, array\\<array\\> given\\.$#',
1006-
'count' => 1,
1007-
'path' => __DIR__ . '/system/Database/BaseResult.php',
1008-
];
1009-
$ignoreErrors[] = [
1010-
'message' => '#^Only booleans are allowed in an if condition, array\\<object\\> given\\.$#',
1011-
'count' => 1,
1012-
'path' => __DIR__ . '/system/Database/BaseResult.php',
1013-
];
10141004
$ignoreErrors[] = [
10151005
'message' => '#^Parameter \\#1 \\$className \\(class\\-string\\) of method CodeIgniter\\\\Database\\\\BaseResult\\:\\:getCustomResultObject\\(\\) should be contravariant with parameter \\$className \\(string\\) of method CodeIgniter\\\\Database\\\\ResultInterface\\<TConnection,TResult\\>\\:\\:getCustomResultObject\\(\\)$#',
10161006
'count' => 1,
@@ -1091,6 +1081,11 @@
10911081
'count' => 1,
10921082
'path' => __DIR__ . '/system/Database/Forge.php',
10931083
];
1084+
$ignoreErrors[] = [
1085+
'message' => '#^Property CodeIgniter\\\\Database\\\\Forge\\:\\:\\$fields \\(array\\<string, array\\|string\\>\\) does not accept array\\<int\\|string, int\\>\\.$#',
1086+
'count' => 1,
1087+
'path' => __DIR__ . '/system/Database/Forge.php',
1088+
];
10941089
$ignoreErrors[] = [
10951090
'message' => '#^Method CodeIgniter\\\\Database\\\\Migration\\:\\:down\\(\\) has no return type specified\\.$#',
10961091
'count' => 1,
@@ -1256,16 +1251,6 @@
12561251
'count' => 5,
12571252
'path' => __DIR__ . '/system/Database/OCI8/Connection.php',
12581253
];
1259-
$ignoreErrors[] = [
1260-
'message' => '#^Only booleans are allowed in a negated boolean, array given\\.$#',
1261-
'count' => 1,
1262-
'path' => __DIR__ . '/system/Database/OCI8/Connection.php',
1263-
];
1264-
$ignoreErrors[] = [
1265-
'message' => '#^Only booleans are allowed in a negated boolean, array\\<stdClass\\> given\\.$#',
1266-
'count' => 1,
1267-
'path' => __DIR__ . '/system/Database/OCI8/Connection.php',
1268-
];
12691254
$ignoreErrors[] = [
12701255
'message' => '#^PHPDoc type string of property CodeIgniter\\\\Database\\\\OCI8\\\\Connection\\:\\:\\$escapeChar is not the same as PHPDoc type array\\|string of overridden property CodeIgniter\\\\Database\\\\BaseConnection\\<resource,resource\\>\\:\\:\\$escapeChar\\.$#',
12711256
'count' => 1,
@@ -3121,6 +3106,11 @@
31213106
'count' => 1,
31223107
'path' => __DIR__ . '/system/Test/Mock/MockCURLRequest.php',
31233108
];
3109+
$ignoreErrors[] = [
3110+
'message' => '#^Cannot unset offset string on array\\<int, int\\>\\|null\\.$#',
3111+
'count' => 2,
3112+
'path' => __DIR__ . '/system/Test/Mock/MockCache.php',
3113+
];
31243114
$ignoreErrors[] = [
31253115
'message' => '#^Method CodeIgniter\\\\Test\\\\Mock\\\\MockCache\\:\\:assertHas\\(\\) has no return type specified\\.$#',
31263116
'count' => 1,

0 commit comments

Comments
 (0)