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

docs: add correct array signatures for Modules #8106

Merged
merged 1 commit into from
Oct 28, 2023
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
4 changes: 2 additions & 2 deletions app/Config/Modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Modules extends BaseModules
* ],
* ]
*
* @var array
* @var array{only?: list<string>, exclude?: list<string>}
*/
public $composerPackages = [];

Expand All @@ -72,7 +72,7 @@ class Modules extends BaseModules
*
* If it is not listed, only the base application elements will be used.
*
* @var string[]
* @var list<string>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If list is okay with @var, we can remove @phpstan-var tags like:

     * @var array<int, string>
     * @phpstan-var list<string>

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. I think vscode intelephense has now support for this type, as well as Closure signatures.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, then let's remove @phpstan-var from now on.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm all for this; I can confirm that Intelephense (in BBEdit) supports list as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know I always ask this... these are different, right?

list<string>
string[]

I think the latter just means "values are all strings" without any indication of keys. But I can't find the answer explicitly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

/** @return ValueType[] */
In Psalm this annotation is equivalent to @psalm-return array<array-key, ValueType>.
https://psalm.dev/docs/annotating_code/type_syntax/array_types/#phpdoc-syntax

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same for phpstan

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sent PR: #8114

*/
public $aliases = [
'events',
Expand Down
5 changes: 0 additions & 5 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
<?php declare(strict_types = 1);

$ignoreErrors = [];
$ignoreErrors[] = [
'message' => '#^PHPDoc type array\\<string\\> of property Config\\\\Modules\\:\\:\\$aliases is not the same as PHPDoc type array of overridden property CodeIgniter\\\\Modules\\\\Modules\\:\\:\\$aliases\\.$#',
'count' => 1,
'path' => __DIR__ . '/app/Config/Modules.php',
];
$ignoreErrors[] = [
'message' => '#^PHPDoc type CodeIgniter\\\\HTTP\\\\CLIRequest\\|CodeIgniter\\\\HTTP\\\\IncomingRequest of property App\\\\Controllers\\\\BaseController\\:\\:\\$request is not the same as PHPDoc type CodeIgniter\\\\HTTP\\\\RequestInterface of overridden property CodeIgniter\\\\Controller\\:\\:\\$request\\.$#',
'count' => 1,
Expand Down
2 changes: 1 addition & 1 deletion system/Modules/Modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Modules
/**
* Auto-Discover Rules Handler
*
* @var array
* @var list<string>
*/
public $aliases = [];

Expand Down