Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: Enable phpdoc_list_type fixer #8530

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 1 addition & 32 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,38 +43,7 @@
__DIR__ . '/spark',
]);

$overrides = [
'phpdoc_array_type' => true,
'phpdoc_no_alias_tag' => [
'replacements' => [
'type' => 'var',
'link' => 'see',
],
],
'phpdoc_align' => [
'align' => 'vertical',
'spacing' => 1,
'tags' => [
'method',
'param',
'phpstan-assert',
'phpstan-assert-if-true',
'phpstan-assert-if-false',
'phpstan-param',
'phpstan-property',
'phpstan-return',
'phpstan-type',
'phpstan-var',
'property',
'property-read',
'property-write',
'return',
'throws',
'type',
'var',
],
],
];
$overrides = [];

$options = [
'cacheFile' => 'build/.php-cs-fixer.cache',
Expand Down
27 changes: 1 addition & 26 deletions .php-cs-fixer.no-header.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,7 @@
__DIR__ . '/admin/starter/builds',
]);

$overrides = [
'phpdoc_array_type' => true,
'phpdoc_align' => [
'align' => 'vertical',
'spacing' => 1,
'tags' => [
'method',
'param',
'phpstan-assert',
'phpstan-assert-if-true',
'phpstan-assert-if-false',
'phpstan-param',
'phpstan-property',
'phpstan-return',
'phpstan-type',
'phpstan-var',
'property',
'property-read',
'property-write',
'return',
'throws',
'type',
'var',
],
],
];
$overrides = [];

$options = [
'cacheFile' => 'build/.php-cs-fixer.no-header.cache',
Expand Down
24 changes: 0 additions & 24 deletions .php-cs-fixer.user-guide.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,6 @@
'import_symbols' => false,
'leading_backslash_in_global_namespace' => true,
],
'phpdoc_array_type' => true,
'phpdoc_align' => [
'align' => 'vertical',
'spacing' => 1,
'tags' => [
'method',
'param',
'phpstan-assert',
'phpstan-assert-if-true',
'phpstan-assert-if-false',
'phpstan-param',
'phpstan-property',
'phpstan-return',
'phpstan-type',
'phpstan-var',
'property',
'property-read',
'property-write',
'return',
'throws',
'type',
'var',
],
],
];

$options = [
Expand Down
2 changes: 1 addition & 1 deletion app/Config/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class Cache extends BaseConfig
* ['q'] = Enabled, but only take into account the specified list
* of query parameters.
*
* @var array<string>|bool
* @var bool|list<string>
*/
public $cacheQueryString = false;

Expand Down
30 changes: 15 additions & 15 deletions app/Config/ContentSecurityPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,28 @@ class ContentSecurityPolicy extends BaseConfig
/**
* Will default to self if not overridden
*
* @var array<string>|string|null
* @var list<string>|string|null
*/
public $defaultSrc;

/**
* Lists allowed scripts' URLs.
*
* @var array<string>|string
* @var list<string>|string
*/
public $scriptSrc = 'self';

/**
* Lists allowed stylesheets' URLs.
*
* @var array<string>|string
* @var list<string>|string
*/
public $styleSrc = 'self';

/**
* Defines the origins from which images can be loaded.
*
* @var array<string>|string
* @var list<string>|string
*/
public $imageSrc = 'self';

Expand All @@ -75,36 +75,36 @@ class ContentSecurityPolicy extends BaseConfig
*
* Will default to self if not overridden
*
* @var array<string>|string|null
* @var list<string>|string|null
*/
public $baseURI;

/**
* Lists the URLs for workers and embedded frame contents
*
* @var array<string>|string
* @var list<string>|string
*/
public $childSrc = 'self';

/**
* Limits the origins that you can connect to (via XHR,
* WebSockets, and EventSource).
*
* @var array<string>|string
* @var list<string>|string
*/
public $connectSrc = 'self';

/**
* Specifies the origins that can serve web fonts.
*
* @var array<string>|string
* @var list<string>|string
*/
public $fontSrc;

/**
* Lists valid endpoints for submission from `<form>` tags.
*
* @var array<string>|string
* @var list<string>|string
*/
public $formAction = 'self';

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

Expand All @@ -129,33 +129,33 @@ class ContentSecurityPolicy extends BaseConfig
/**
* Restricts the origins allowed to deliver video and audio.
*
* @var array<string>|string|null
* @var list<string>|string|null
*/
public $mediaSrc;

/**
* Allows control over Flash and other plugins.
*
* @var array<string>|string
* @var list<string>|string
*/
public $objectSrc = 'self';

/**
* @var array<string>|string|null
* @var list<string>|string|null
*/
public $manifestSrc;

/**
* Limits the kinds of plugins a page may invoke.
*
* @var array<string>|string|null
* @var list<string>|string|null
*/
public $pluginTypes;

/**
* List of actions allowed.
*
* @var array<string>|string|null
* @var list<string>|string|null
*/
public $sandbox;

Expand Down
2 changes: 1 addition & 1 deletion app/Config/Format.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Format extends BaseConfig
* These formats are only checked when the data passed to the respond()
* method is an array.
*
* @var array<string>
* @var list<string>
*/
public array $supportedResponseFormats = [
'application/json',
Expand Down
2 changes: 1 addition & 1 deletion app/Config/Toolbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Toolbar extends BaseConfig
* List of toolbar collectors that will be called when Debug Toolbar
* fires up and collects data from.
*
* @var array<string>
* @var list<string>
*/
public array $collectors = [
Timers::class,
Expand Down
2 changes: 1 addition & 1 deletion app/Config/Validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Validation extends BaseConfig
* Stores the classes that contain the
* rules that are available.
*
* @var array<string>
* @var list<string>
*/
public array $ruleSets = [
Rules::class,
Expand Down
12 changes: 6 additions & 6 deletions app/Config/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
use CodeIgniter\View\ViewDecoratorInterface;

/**
* @phpstan-type ParserCallable (callable(mixed): mixed)
* @phpstan-type ParserCallableString (callable(mixed): mixed)&string
* @phpstan-type parser_callable (callable(mixed): mixed)
* @phpstan-type parser_callable_string (callable(mixed): mixed)&string
*/
class View extends BaseView
{
Expand Down Expand Up @@ -35,7 +35,7 @@ class View extends BaseView
* { created_on|date(Y-m-d)|esc(attr) }
*
* @var array<string, string>
* @phpstan-var array<string, ParserCallableString>
* @phpstan-var array<string, parser_callable_string>
*/
public $filters = [];

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

Expand All @@ -56,7 +56,7 @@ class View extends BaseView
*
* All classes must implement CodeIgniter\View\ViewDecoratorInterface
*
* @var array<class-string<ViewDecoratorInterface>>
* @var list<class-string<ViewDecoratorInterface>>
*/
public array $decorators = [];
}
30 changes: 10 additions & 20 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -1001,16 +1001,6 @@
'count' => 2,
'path' => __DIR__ . '/system/Database/BaseResult.php',
];
$ignoreErrors[] = [
'message' => '#^Only booleans are allowed in an if condition, array\\<array\\> given\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Database/BaseResult.php',
];
$ignoreErrors[] = [
'message' => '#^Only booleans are allowed in an if condition, array\\<object\\> given\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Database/BaseResult.php',
];
$ignoreErrors[] = [
'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\\(\\)$#',
'count' => 1,
Expand Down Expand Up @@ -1091,6 +1081,11 @@
'count' => 1,
'path' => __DIR__ . '/system/Database/Forge.php',
];
$ignoreErrors[] = [
'message' => '#^Property CodeIgniter\\\\Database\\\\Forge\\:\\:\\$fields \\(array\\<string, array\\|string\\>\\) does not accept array\\<int\\|string, int\\>\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Database/Forge.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Database\\\\Migration\\:\\:down\\(\\) has no return type specified\\.$#',
'count' => 1,
Expand Down Expand Up @@ -1256,16 +1251,6 @@
'count' => 5,
'path' => __DIR__ . '/system/Database/OCI8/Connection.php',
];
$ignoreErrors[] = [
'message' => '#^Only booleans are allowed in a negated boolean, array given\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Database/OCI8/Connection.php',
];
$ignoreErrors[] = [
'message' => '#^Only booleans are allowed in a negated boolean, array\\<stdClass\\> given\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Database/OCI8/Connection.php',
];
$ignoreErrors[] = [
'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\\.$#',
'count' => 1,
Expand Down Expand Up @@ -3121,6 +3106,11 @@
'count' => 1,
'path' => __DIR__ . '/system/Test/Mock/MockCURLRequest.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot unset offset string on array\\<int, int\\>\\|null\\.$#',
'count' => 2,
'path' => __DIR__ . '/system/Test/Mock/MockCache.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Test\\\\Mock\\\\MockCache\\:\\:assertHas\\(\\) has no return type specified\\.$#',
'count' => 1,
Expand Down
Loading
Loading